Html dropdown with images

Содержание
  1. Dropdown Select With Images
  2. Dropdown select with images
  3. select and display an image from a dropdown menu
  4. want to show image/icons in dropdown list
  5. Display Image Based on 2 Dropdown Values
  6. CSS Dropdowns
  7. Example
  8. Example Explained
  9. Dropdown Menu
  10. Example
  11. 26 CSS Dropdown Menus
  12. Related Articles
  13. Author
  14. Links
  15. Made with
  16. About a code
  17. Dropdown Dark/Light
  18. Author
  19. Links
  20. Made with
  21. About a code
  22. Gooey Dropdown Menu
  23. Author
  24. Links
  25. Made with
  26. About a code
  27. Drop Down Menu
  28. Author
  29. Links
  30. Made with
  31. About a code
  32. Navigation with Sub-Navigation
  33. Author
  34. Links
  35. Made with
  36. About a code
  37. Pure CSS Dropdown Menu
  38. Author
  39. Links
  40. Made with
  41. About a code
  42. The More Menu
  43. Author
  44. Links
  45. Made with
  46. About the code
  47. Drop Down Menu
  48. Author
  49. Links
  50. Made with
  51. About the code
  52. Molten Menu
  53. Author
  54. Links
  55. Made with
  56. About the code
  57. HTML & CSS Dropdown Menu
  58. Author
  59. Links
  60. Made with
  61. About the code
  62. Gradient Menu
  63. Author
  64. Links
  65. Made with
  66. About the code
  67. Main Menu
  68. Author
  69. Links
  70. Made with
  71. About the code
  72. CSS Menu
  73. Author
  74. Links
  75. Made with
  76. About the code
  77. CSS Dropdown Menu
  78. Author
  79. Links
  80. Made with
  81. About the code
  82. Horizontal Dropdown Menu
  83. Author
  84. Links
  85. Made with
  86. About the code
  87. Dropdown Menu
  88. Author
  89. Links
  90. Made with
  91. About the code
  92. Fancy Menu
  93. Author
  94. Links
  95. Made with
  96. About the code
  97. Recursive Hover Navigation
  98. Author
  99. Links
  100. Made with
  101. About the code
  102. Cool Dropdown Menu Effects
  103. Author
  104. Links
  105. Made with
  106. About the code
  107. CSS Dropdown Menu
  108. Author
  109. Links
  110. Made with
  111. About the code
  112. Dropdown Menu
  113. Author
  114. Links
  115. Made with
  116. About the code
  117. Simple Pure CSS Dropdown Menu
  118. Author
  119. Links
  120. Made with
  121. About the code
  122. Simple Pure CSS Dropdown Menu
  123. Author
Читайте также:  Confluence api python example

In Firefox you can just add background image to option:

Better yet, you can separate HTML and CSS like that

select#gender option[value=»male»] < background-image:url(male.png); >
select#gender option[value=»female»] < background-image:url(female.png); >
select#gender option[value=»others»]

In other browsers the only way of doing that would be using some JS widget library, like for example jQuery UI, e.g. using Selectable.

From jQuery UI 1.11, Selectmenu widget is available, which is very close to what you want.

Check this example .. everything has been done easily http://jsfiddle.net/GHzfD/

EDIT: Updated/working as of 2013, July 02: jsfiddle.net/GHzfD/357

#webmenu width:340px;
>









$("body select").msDropDown();

select and display an image from a dropdown menu

You must need to keep your file inside your project .

images is the folder name which inside your project.

xampp or wampp not consider the local path files.

And it won’t display the images as well.

Hope this Helpful.

I have changed two places in your code.

 

$folder = 'images\\'; // changed here

echo ''."\n".''."\n".''."\n".' ';
function image_filenames($dir)
$handle = @opendir($dir)
or die("I cannot open the directory '$dir' for reading.");
$images = array();
while (false !== ($file = readdir($handle)))
if (preg_match('/^.*\.(jpg|jpeg|png|gif|svg)$/', $file))
$images[] = $file;
>
>
closedir($handle);
return $images;
>
function dropdown($options_array, $selected = null)
$return = null;
foreach($options_array as $option)
$return .= ' '."\n";
>
return $return;
>


if (isset($_POST['submit']))
echo ''; // changed here



>
?>

want to show image/icons in dropdown list

Display Image Based on 2 Dropdown Values

The variable you stored the image filename is different from the variable you passed as the value in for the image’s src tag

$('select.form-control').change(function() var filename = $('#shape').val() + '-' + $('#waist').val() + '.jpg'; 
$('#imgToChange').attr('src', filename);
>);

You can also try using the .attr() method in place of the .prop() method like i did

Updated See code below
HTML

Brown Head


Brown Body

var imageSrc;
var imgFolder = "/path/to/image/folder/"; // specify the path to the folder containing the imgs in this variable

$("select").change(function() imageSrc = imgFolder + $("#select-1").val() + "-" + $("#select-2").val() + ".jpg";
$("#imgElem").attr("src", imageSrc);
$("p").text(imageSrc);
>);

UPDATED ONCE AGAIN

This update creates the img tag each time an option is selected, replacing the previous img tag. This is to prevent the img src(undefined) error on page load.

To archive this, i added a div in the html to hold the img element, and simply change the divs html content.

HTML UPDATED

Brown Head


Brown Body

// specify the path to the folder containing the imgs in this variable
var imgFolder = "/path/to/image/folder/";

$("select").change(function() var src; // variable to hold the src

src = imgFolder + $("#select-1").val() + "-" + $("#select-2").val() + ".jpg";
// append src to a p element just for debugging sake(i.e to see the change in the src)
$("p").text(src);

// create an img element with the src each time and append to the image wrap div
$(".img-wrap").html(``);
>);

UPDATED ONCE AGAIN

To make it show the image with the default selected options both on page load and on option select, i tweaked the code again

NEW JS CODE

function getImageSrc() // specify the path to the folder containing the imgs in this variable 
var imgFolder = "/path/to/image/folder/";

// loop through each select element
$("select").each(function() // fire function to get src
getSrc();

// fire function to get src on change
$(this).change(function() getSrc();
>)
>);

function getSrc() var src; // variable to hold the src

src = imgFolder + $("#select-1").val() + "-" + $("#select-2").val() + ".jpg";
$("#imgElem").attr("src", src);
// append src to a p element just for debugging sake(i.e to see the change in the src)
$("p").text(src);

// create a an img element with the src each time and append to the image wrap div
$(".img-wrap").html(``);
>
>

// fire function on page-load
$(document).ready(function() getImageSrc();
>)

Источник

CSS Dropdowns

Cinque Terre

Create a dropdown box that appears when the user moves the mouse over an element.

Example

.dropdown-content display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
padding: 12px 16px;
z-index: 1;
>

.dropdown:hover .dropdown-content display: block;
>

Example Explained

HTML) Use any element to open the dropdown content, e.g. a , or a element.

Use a container element (like ) to create the dropdown content and add whatever you want inside of it.

Wrap a element around the elements to position the dropdown content correctly with CSS.

CSS) The .dropdown class uses position:relative , which is needed when we want the dropdown content to be placed right below the dropdown button (using position:absolute ).

The .dropdown-content class holds the actual dropdown content. It is hidden by default, and will be displayed on hover (see below). Note the min-width is set to 160px. Feel free to change this. Tip: If you want the width of the dropdown content to be as wide as the dropdown button, set the width to 100% (and overflow:auto to enable scroll on small screens).

Instead of using a border, we have used the CSS box-shadow property to make the dropdown menu look like a «card».

The :hover selector is used to show the dropdown menu when the user moves the mouse over the dropdown button.

Create a dropdown menu that allows the user to choose an option from a list:

This example is similar to the previous one, except that we add links inside the dropdown box and style them to fit a styled dropdown button:

Example

/* The container — needed to position the dropdown content */
.dropdown position: relative;
display: inline-block;
>

/* Dropdown Content (Hidden by Default) */
.dropdown-content display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
>

/* Links inside the dropdown */
.dropdown-content a color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
>

/* Change color of dropdown links on hover */
.dropdown-content a:hover

/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content display: block;
>

/* Change the background color of the dropdown button when the dropdown content is shown */
.dropdown:hover .dropbtn background-color: #3e8e41;
>

Источник

26 CSS Dropdown Menus

Collection of hand-picked free HTML and CSS dropdown menu code examples from codepen and other resources. Update of July 2019 collection. 9 new items.

Author

Made with

About a code

Pure CSS dropdown dark/light.

Compatible browsers: Chrome, Edge, Firefox, Opera, Safari

Author

Made with

About a code

Gooey Dropdown Menu

Compatible browsers: Chrome, Edge, Opera, Safari

Author

Made with

About a code

Compatible browsers: Chrome, Edge, Firefox, Opera, Safari

Author

Made with

About a code

Compatible browsers: Chrome, Edge, Firefox, Opera, Safari

Author

Made with

About a code

Pure CSS Dropdown Menu

Compatible browsers: Chrome, Edge, Firefox, Opera, Safari

Author

Made with

About a code

The More Menu

Using clip-path times two to make an irregular shaped object fill out a cut-out shape in an unfold open menu effect.

Compatible browsers: Chrome, Edge, Firefox, Opera, Safari

Author

Made with

About the code

Compatible browsers: Chrome, Edge, Firefox, Opera, Safari

Author

Made with

About the code

Molten Menu

This combines a CSS drop down menu, and the oozing effects of liquid flame.

Compatible browsers: Chrome, Edge, Firefox, Opera, Safari

Demo image: HTML & CSS Dropdown Menu

Author

Made with

About the code

HTML & CSS Dropdown Menu

Compatible browsers: Chrome, Firefox, Opera, Safari

Demo image: Gradient Menu

Author

Made with

About the code

Gradient Menu

Responsive gradient dropdown menu.

Compatible browsers: Chrome, Firefox, Opera, Safari

Author

Made with

About the code

Horizontal menu with dropdown effects in HTML and CSS.

Compatible browsers: Chrome, Edge, Firefox, Opera, Safari

Demo image: CSS Menu

Author

Made with

About the code

CSS Menu

No JS — be sure to check out the mobile menu.

Compatible browsers: Chrome, Edge, Firefox, Opera, Safari

Demo image: CSS Dropdown Menu

Author

Made with

About the code

CSS Dropdown Menu

HTML and CSS dropdown menu with nice effect.

Compatible browsers: Chrome, Firefox, Opera, Safari

Author

Made with

About the code

Horizontal Dropdown Menu

Pure CSS horizontal dropdown menu with nice transitions and beautiful palette.

Compatible browsers: Chrome, Edge, Firefox, Opera, Safari

Demo image: Dropdown Menu

Author

Made with

About the code

Cool HTML & CSS dropdown menu.

Compatible browsers: Chrome, Edge, Firefox, Opera, Safari

Demo image: Fancy Menu

Author

Made with

About the code

Fancy Menu

Fancy dropdown menu in HTML and CSS. Inspired by https://dribbble.com/shots/1075480-Ui-Kit-Hotel

Compatible browsers: Chrome, Edge, Firefox, Opera, Safari

Demo image: Recursive Hover Navigation

Author

Made with

About the code

Recursive Hover Navigation

Only CSS recursive hover nav.

Compatible browsers: Chrome, Edge, Firefox, Opera, Safari

Demo image: Cool Dropdown Menu Effects

Author

Made with

About the code

Cool Dropdown Menu Effects

Cool dropdown menu pure CSS effects.

Compatible browsers: Chrome, Edge, Firefox, Opera, Safari

Author

Made with

About the code

CSS Dropdown Menu

Full CSS dropdown navigation. Drops down on click by the use of a hidden checkbox.

Demo image: Dropdown Menu

Author

Made with

About the code

Compatible browsers: Chrome, Edge, Firefox, Opera, Safari

Demo image: Simple Pure CSS Dropdown Menu

Author

Made with

About the code

Simple Pure CSS Dropdown Menu

Menu with dropdown made only in CSS, with a line that follow the hover on the line.

Compatible browsers: Chrome, Edge, Firefox, Opera, Safari

Demo image: Simple Pure CSS Dropdown Menu

Author

Made with

About the code

Simple Pure CSS Dropdown Menu

Simple, sleek looking dropdown menu effect achieved using pure CSS. Simple functionality, method can be extended to create a secondary dropdown block with few edits.

Compatible browsers: Chrome, Edge, Firefox, Opera, Safari

Author

Источник

Оцените статью