Foundation Dropdown Menu
Foundation dropdown menus allow users to select a value from a predefined dropdown list:
Example
<a href="#" data-dropdown="id01" class="button dropdown">Dropdown Button</a>
<!-- Dropdown content -->
<ul id="id01" data-dropdown-content class="f-dropdown">
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
</ul>
<!-- Initialize Foundation JS -->
<script>
$(document).ready(function() {
$(document).foundation();
})
</script>
Try it Yourself »
Example analysis
.dropdownThe class adds a downward arrow symbol icon to the button.
Using a button or link'sdata-dropdown="id"attribute to open the dropdown menu.
idThe value needs to match the content of the dropdown menu (id01).
In <div>, <nav>,<ul>Add to.f-dropdownclass anddata-dropdown-contentattribute to create the content of the dropdown menu.
Finally, initialize Foundation JS.
Note:On small screens, all dropdown menus are 100% in width.
Dropdown menu size
Usage.tiny, .small, .medium, .largeor.megato modify the width of the dropdown menu.
Note:On small screens, all dropdown menus are 100% in width.
Example
<ul id="id01" data-dropdown-content class="f-dropdown tiny">..
<!-- Small Dropdown: max-width is 300px -->
<ul id="id02" data-dropdown-content class="f-dropdown small">..
<!-- Medium Dropdown: max-width is 500px -->
<ul id="id03" data-dropdown-content class="f-dropdown medium">
<!-- Large Dropdown: max-width is 800px -->
<ul id="id04" data-dropdown-content class="f-dropdown large">..
<!-- Mega Dropdown: 100% width -->
<ul id="id04" data-dropdown-content class="f-dropdown mega">..
Try it Yourself »
Dropdown menu margin
You can use.contentclass to add padding to the dropdown menu:
Example
<ul id="id01" data-dropdown-content class="f-dropdown">..
<!-- Dropdown with padding -->
<ul id="id02" data-dropdown-content class="f-dropdown content">..
Try it Yourself »
More examples
Add multimedia elements to the <div> dropdown menu:
Example
<div id="id01" data-dropdown-content class="f-dropdown medium content">
<h4>Paris Title</h4>
<p>Some text.. some text..</p>
<img src="paris.jpg" alt="Paris" width="400" height="300">
<p>Paris, je t'aime.</p>
</div>
Try it Yourself »
Dropdown menu direction
By default, the dropdown menu appears at the bottom; you can change this by addingdata-options="align:left|right|top"to modify its direction:
Example
<a href="#" data-dropdown="id02" data-options="align:top" class="button dropdown">Top</a>
<a href="#" data-dropdown="id03" data-options="align:bottom" class="button dropdown">Bottom</a>
<a href="#" data-dropdown="id04" data-options="align:left" class="button dropdown">Left</a>
Try it Yourself »
Dropdown Menu Trigger Conditions
By default, the dropdown menu is displayed after clicking the button. If you need it to display when hovering, you can use it on the button.data-options="is_hover:true"Property:
Example
<ul id="id01" data-dropdown-content class="f-dropdown">
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
</ul>
Try it Yourself »
Split Button
We can add on the button.splitUse the class to create a split button, and after splitting, a downward-pointing icon button is generated on the <span> element.
Example
<span data-dropdown="id01"></span>
</button>
<ul id="id01" data-dropdown-content class="f-dropdown">
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
</ul>
<!-- Initialize Foundation JS -->
<script>
$(document).ready(function() {
$(document).foundation();
})
</script>
Try it Yourself »