Here is my CSS and html:
.container {
background-image: url('./images/bg.jpg');
height: 500px;
width: 960px;
margin: auto;
}
.logo {
margin: auto;
text-align: center;
width: 960px;
height: 100px;
position: relative;
top: 200px;
}
ul {
list-style: none;
}
li {
display: inline;
}
.nav {
margin: auto;
text-align: center;
padding-right: 35px;
clear: both;
}
<div class="container">
<div class="logo">
<h1>My Page</h1>
</div>
<div class="nav">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
I don't think they way I've positioned the <div class="logo"></div>
is probably correct but I'm not sure how to centre content within a div and any solution I find seems to affect the positioning of <div class="nav"></div>
.
So this question is two-fold - how can I position <div class="logo"></div>
centrally within <div class="container"></div>
and then how can I place <div class="nav"></div>
below <div class="logo"></div>
?
Thanks for any help.
You can use
flexbox
to do that.https://jsfiddle.net/bjdvz1km/