2
I’m studying flexbox and decided to create a menu, everything works well, but this getting a spacing without me having given, so I know the flex: 1 takes up all the space, but that’s not what is happening.
Code: HTML
<ul class="nav">
<li class="nav-item"><a href="#">Item 1</a></li>
<li class="nav-item"><a href="#">Item 2</a></li>
<li class="nav-item"><a href="#">Item 3</a></li>
<li class="nav-item"><a href="#">Item 4</a></li>
<li class="nav-item"><a href="#">Item 5</a></li>
</ul>
Code: CSS
.nav {
background: #ED4343;
display: flex;
flex-direction: row;
flex-wrap: wrap;
list-style: none;
}
.nav-item {
flex: 1;
list-style: none;
text-align: center;
}
a {
display: block;
padding: 20px;
border: 1px solid #FFFFFF;
color: #FFFFFF;
text-decoration: none
}
It was perfect, I was a little surprised to know that by default ul has a padding, this because I always created menus using the float and did not give this spacing, but thanks, this information is very useful
– Pedro Silva
@Pedrosilva gives a look at this link https://answall.com/questions/165937/o-que-%C3%A9-user-agent-stylesheets you will see that by default the Browser can establish some CSS basa for the stylesheet, may or may not be different from those suggested by W3C... so there are some Normalizer.css and reset.css to try to reset or match the css defaut of all browsers
– hugocsl
@Pedrosilva another link that will interest you to better understand what happened. These are readings that will serve you for the rest of dev’s life. it is worth stopping for a minute to read https://answall.com/questions/100044/css-reset-ou-normalize
– hugocsl