HTML structure
The navigation bar is a very common component in web pages. Usually, we use unordered lists to make navigation bars. for example
<div id="nav">
<ul class="navMenu">
<li><a href="">Home</a></li>
<li><a href="">Group tour</a></li>
<li><a href="">Self-guided tour</a></li>
<li><a href="">Cruise</a></li>
<li><a href="">Self-driving</a></li>
</ul>
</div>
Some navigation bars have drop-down secondary menus, so we add a list at the corresponding position to form a secondary menu, such as
<div id="nav">
<ul class="navMenu">
<li><a href="">Home</a></li>
<li><a href="">Group tour</a>
<ul class="subMenu">
<li><a href="">Outbound tour group</a></li>
<li><a href="">Domestic tour group</a></li>
<li><a href="">Peripheral tours</a></li>
<li><a href="">Local tour</a></li>
</ul>
</li>
<li><a href="">Self-guided tour</a>
<ul class="subMenu" >
<li><a href="">Outbound self-service</a></li>
<li><a href="">Domestic self-service</a></li>
<li><a href="">Flight + Hotel</a></li>
<li><a href="">Train + Hotel</a></li>
</ul>
</li>
<li><a href="">Cruise</a>
<ul class="subMenu">
<li><a href="">Exclusive charter boat</a></li>
<li><a href="">Japan and South Korea routes</a></li>
<li><a href="">European routes</a></li>
<li><a href="">Three Gorges Route</a></li>
<li><a href="">American routes</a></li>
</ul>
</li>
<li><a href="">Self-driving</a>
<ul class="subMenu">
<li><a href="">Self-driving around the area</a></li>
<li><a href="">Domestic self-driving</a></li>
<li><a href="">Outbound self-driving</a></li>
</ul>
</li>
</ul>
</div>
Basic CSS styles
The list is arranged vertically by default, while the common navigation bar main menu is arranged horizontally, and the secondary drop-down menu is arranged vertically, so we need to float the li element of the main menu so that it can be arranged horizontally. After setting the float, you should remember to clear it. You can use class as a common float and clear-float style, then add the corresponding class to the element that needs to be floated, and add the clear-float class to the parent element of the floated element.