Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
167 views
in Technique[技术] by (71.8m points)

html - Navigationbar height adapts to Img

I'm currently learning html and css, but I have a problem that the height of the navigation bar adapts to the picture. How can I change that? I've tried a lot, unfortunately without success: /

html {
    overflow-x: hidden;
    display: block;
}
body {
    font-family: Arial;
}

header {
    background: #424242;
    height: 200px;
}

.navbar-logo {
    width: 200px;
    height: auto;
}

.navbar-items {
    margin: 0px 10px 0px 0px;
    display: inline;
}

.navbar-items li{
    margin: 0px 10px 0px 0px;
    display: inline;
    padding: 20px 5px 20px 5px;
    list-style-type: none;
}


.navbar-items a {
    color: black;
}
<header>
    <!--Navbar-->
    <nav class="navbar-expand">
        <img src="assets/images/logo2.png" class="navbar-logo" alt="navbar logo"></a>
        <ul class="navbar-items">
            <li class="nav-item"><a href=".">Home</a></li>
            <li class="nav-item"><a href="">About me</a></li>
            <li class="nav-item"><a href="">Kontakt</a></li>
        </ul>
    </nav>
</header>
question from:https://stackoverflow.com/questions/65865634/navigationbar-height-adapts-to-img

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

the picture is a inline content of tag NAV, so the NAV will always adjust to contain the picture, you have to adjust the picture's height.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...