gpt4 book ai didi

html - Bootstrap 响应式图像尝试在 Safari、Chrome、FF 中表现不同

转载 作者:太空宇宙 更新时间:2023-11-04 08:22:54 24 4
gpt4 key购买 nike

我正在尝试设置适合网站导航栏并用作 Logo 的图像样式。我遇到的问题是它在三个主要浏览器中的显示方式不同。

明确地说,当我使用 height 属性并使图像在 FF 中显示良好时,对于 Safari 来说它变得太大了,反之亦然。对于 Chrome,这种行为甚至更奇怪。出于某种原因,它甚至拒绝承认相关类的存在。当我 checkin Page Source Code 并导航到有问题的 CSS 时,该类不存在。缺少的类在下面的代码中称为 .logo-img

HTML:

<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<a href="index.html" class="navbar-brand"><img src="{% static "tshirt-theme/img/logo-kindbook.png" %}" class="logo-img" alt="Shirt Store"></a>
<div class="navbar-buttons">
<button type="button" data-toggle="collapse" data-target=".navbar-collapse" class="navbar-toggle navbar-btn">Menu<i class="fa fa-align-justify"></i></button>
</div>
</div>

为简洁起见省略了其余部分

CSS:

.navbar-default {
background-color: #ffffff;
border-bottom-color: transparent;
}
.navbar-default .navbar-brand {
color: #333333;
}

img.logo-img {
height: 300%; !important
}

.logo-img > img {
height: 300%; !important
}

请原谅 !important,因为我正在使用它来尝试进行故障排除和破解。

火狐:

enter image description here

Safari : enter image description here

Chrome :图片放大到全分辨率并占据整个页面。

问题是为什么会发生这种情况(尤其是 Chrome 没有注册 CSS 类),我怎样才能想出一些跨浏览器兼容的东西?

最佳答案

如果您使用的是 bootstrap 3,那么您应该减小图像大小,然后移除 navbar-brand 填充。

更多详情 bootstrap navbar

.navbar-brand {
padding: 0px !important;
}
.largeImg .navbar{
min-height:151px;
}
.largeImg .navbar-nav>li>a{
padding-top:65px;
padding-bottom:65px;
}
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class=container>
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><img src="http://www.placehold.it/70x50"></a>
</div>

<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li>
<li><a href="#">Link</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">Separated link</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
</ul>

</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
<div class="largeImg">
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><img src="http://www.placehold.it/150x150"></a>
</div>

<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li>
<li><a href="#">Link</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">Separated link</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
</ul>

</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
</div>
</div>

关于html - Bootstrap 响应式图像尝试在 Safari、Chrome、FF 中表现不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45406226/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com