When it comes to responsive design, the choice between utilizing ul
and div
elements is crucial, especially in regards to the navigation bar.
After observing many other developers, I initially opted for ul
but soon realized that for certain navigation behaviors, using the display: flex
property makes things much simpler. Here's an example:
<div class="navbar">
<div><a href="#">LOGIN</a></div>
<div><a href="#">REGISTER</a></div>
<div><a href="#">BASKET</a></div>
</div>
CSS:
.navbar {
display: flex;
justify-content: space-between;
border: solid 1px;
border-style: dotted;
font: bold 1.2em/45px "Times New Roman", Georgia, Serif;
text-decoration: none;
background-color: black;
}
.navbar a {
text-decoration: none;
font: bold 1.2em/45px "Times New Roman", Georgia, Serif;
padding: 20px;
color: white;
}
Are there any drawbacks to using this approach?