I have a logo inside a navbar-header like this:
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<span><a class="navbar-brand toplogo" href="#"><img src="img/beta.png"/></a></span>
</div>
<div>
<ul class="nav navbar-nav navbar-right">
<li class="active"><a href="#">Login</a></li>
<li><a href="#">Sign up!</a></li>
<li><a href="#">Home</a></li>
</ul>
</div>
<div>
</nav
My CSS is here:
.toplogo {
height : 30%;
width : 30%;
margin-top: 5px;
}
I tried many different combinations in .toplogo, but the image size never changes. I tried cascading .navbar-brand .toplogo
, but that didn't work either. Does anyone know how I can resize the logo in the header? Thanks in advance!
将.toplogo放在<img>
标记中
<img class="toplogo" src="img/beta.png"/>
For the image to resize like you want it, you have to target .toplogo img
and not just toplogo
.
Your CSS should look like this:
.toplogo {
margin-top: 5px;
}
.toplogo img {
height : 30%;
width : 30%;
}
You have two ways to do it
.toplogo img {
height : 30%;
width : 30%;
margin-top: 5px;
}
<img class="toplogo" src="img/beta.png"/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.