Below are my HTML and CSS for my nav on a website. As it stands the words sit at the top of the bar when I want them centered.
How can I do this? And what other things should I do?
nav ul {
background-color: #6699CC;
height: 100px;
margin: 0;
padding: 0;
position: -webkit-sticky;
position: sticky;
width: 100%;
}
nav ul li {
display: inline;
}
nav ul li a {
color: white;
font-size: 35px;
text-decoration: none;
margin: 80px;
padding-top: 25px;
}
nav ul li a:hover {
background-color: #003B6D;
}
<ul>
<li><a href="index2.html">Home</a> </li>
<li><a href="hardware.html">Computer Hardware</a> </li>
<li><a href="software.html">Computer Software</a> </li>
<li><a href="internet.html">The Internet</a> </li>
</ul>
2
Answers
You have to put the parent around the children and make it flex. So in your code, you can put display: flex to the ul.
Here is the code and some of the codes are comments.
here is its pen.
This probably gives you what you need.
display: flex
in combination withalign-items: center
ensure the items are centered vertically inside thenav
element.