Issue
I'm practicing creating a website, and am currently trying to replicate this site. At the moment I am working on the navigation bar, but I am unable to vertically align the button vertically in the nav.
.header {
background-color: red;
padding: 40px 20px;
}
.header h1 {
background-color: yellow;
float: left;
}
.header h1 img {
display: block;
}
.header__nav {
background-color: aqua;
float: right;
}
.header__nav li {
float: left;
height: 38px;
}
.header__nav li a {
padding: 0 20px;
display: inline-block;
line-height: 38px;
}
.contents {
background-color: green;
}
.footer {
background-color: blue;
}
<header class="header clearfix">
<h1>
<a href="#"><img src="https://pixelicons.com/wp-content/themes/pexelicons/assets/pic/site-logo/logo.png" alt="Logo"></a>
</h1>
<nav class="header__nav">
<ul class="clearfix">
<li><a href="#">View icons</a></li>
<li><a href="#">Buy now</a></li>
<li><button class="menu">menu</button></li>
</ul>
</nav>
</header>
<section class="contents">
contents
</section>
<footer class="footer">
footer
</footer>
I wanna align the top-right button of the nav bar vertically. I know this can be solved using display: flex;
, but I wanna solve it another way. Is there a proper way to solve this issue?
Solution
Even though your solution using display: flex
seems perfectly fine to me, you could fix it using vertical-align: middle;
and display: inline-block
on all of the items (the two links and the button)
Answered By - Janis Jansen Answer Checked By - Cary Denson (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.