I have the following div which contains a background image and at the bottom a menu, my question is how can I center the items of my menu in the full width of my screen, currently they are displayed on the left.
this is my code:
<div class="principal movil_principal">
<div class="fondo_principal">
<div id="barra_horizontal_login">
<ul class="barra_horizontal_ul">
<li class="barra_horizontal_li">
<a href><i class="material-icons">help</i> Dato informativo</a>
</li>
<li class="barra_horizontal_li">
<a href><i class="material-icons">help</i> Dato informativo</a>
</li>
<li class="barra_horizontal_li">
<a href><i class="material-icons">help</i> Dato informativo</a>
</li>
</ul>
</div>
</div>
</div>
CSS:
.principal{
background-image: url('https://www.oxmoorhyundai.com/wp-content/themes/DealerInspireDealerTheme/images/video-fallback-background.jpg');
background-repeat: no-repeat;
background-position: 100%;
background-size: cover;
margin: 0 auto 1em;
padding-top: 25%;
position: relative;
}
.fondo_principal{
background-color: rgba(66, 66, 66, 0.5);
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
#barra_horizontal_login{
width: 100%;
position: absolute;
bottom: 0;
right: 0;
}
.barra_horizontal_ul{
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: rgba(0,0,0,0.3);
}
.barra_horizontal_li{
float: left;
}
.barra_horizontal_li a{
color: #bdbdbd;
display: block;
font-size: 10px;
text-align: center;
padding: 10px;
text-decoration: none;
display: inline-flex;
vertical-align: middle;
}
.barra_horizontal_li a:hover{
color: #424242;
}
.barra_horizontal_li i{
color: #bdbdbd;
font-size: 13px;
}
Finally I share my jsfiddle div-example
A quick fix is with Flexbox, adding two lines of CSS to the list class
<ul class="barra_horizontal_ul">
.In the first added line
display: flex;
we define a flexbox container, and in the secondjustify-content: space-around;
we tell said container that its "inner" elements, in this case,<li>
will have space around each of them equal to the division between the total unused space in the line or container, divided by the number of elements contained and finally divided by two, and said space is added to each side of each of the elements.To center elements on a screen and that it is also any screen size, if you are not using bootstrap I would use the @media query of css
https://www.w3schools.com/css/css_rwd_mediaqueries.asp
You put in your div class="row" and in each list menu you give it the size you want with col-3 col-m-3 or whatever you want and it stays centered for any screen size.