我一直在尝试使我的导航栏品牌徽标和旋转木马都具有响应能力,但似乎没有任何效果。如果我减小屏幕尺寸,品牌形象就会在导航栏上溢出,而轮播会显得拉长且笨拙。我的代码在下面。
CAROUSEL HTML
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-12">
<div class = "carousel">
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="#" class="d-block w-100" alt="...">
<div class="carousel-caption d-none d-md-block">
<h3></h3>
</div>
</div>
<div class="carousel-item">
<img src="#" class="d-block w-100" alt="...">
<div class="carousel-caption d-none d-md-block">
<h3></h3>
</div>
</div>
NAVBAR HTML
<nav class="navbar navbar-custom navbar-expand-lg fixed-top">
<a class="navbar-brand" href="#">
<img class="img-responsive" src="" width="30" height="50" alt="">
</a>
...
</nav>
答案 0 :(得分:0)
我通过添加图像测试了您的代码,看起来一切都已正确配置。但是,您可能想看看如何配置CSS。
尝试添加(最新的最小CSS):
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" />
此外,您可能会混合使用不同的Bootstrap 4和3元素(我看到您使用img-responsive
作为徽标-在Bootstrap 4中不再使用,现在是img-fluid
)。如果是这种情况,请尝试以下导航栏:
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#"><img src="https://via.placeholder.com/50" class="d-block w-100" alt="..."></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</li>
</ul>
</div>
</nav>
答案 1 :(得分:0)
对于导航栏,
在导航中添加navbar-dark bg-dark
导航栏类。
<nav class="navbar navbar-expand-lg fixed-top navbar-dark bg-dark navbar">
<a class="navbar-brand" href="#">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="nav-content" aria-expanded="true" aria-label="Toggle-navigation">
<img class="img-responsive" src="Images/img1.png" width="30" height="50" alt="">
</button>
</a>
</nav>
答案 2 :(得分:0)
对于轮播,
通过在引导程序4中添加img-fluid类或在引导程序3中添加img响应类,使图像具有响应性
<div class="col-12">
<div id="imageCarousel" class="carousel slide" data-interval="2000">
<ul class="carousel-indicators">
<li data-target="#imageCarousel" data-slide-to="0" class="active"></li>
<li data-target="#imageCarousel" data-slide-to="1"></li>
<li data-target="#imageCarousel" data-slide-to="2"></li>
<li data-target="#imageCarousel" data-slide-to="3"></li>
</ul>
<a href="#imageCarousel" class="carousel-control-prev" data-slide="prev"><span class="carousel-control-prev-icon"></span></a>
<div class="carousel-inner" style="background-color:Gray">
<div class="carousel-item active" >
<img src="Images/jellyfish.jpg" class="img-fluid mx-auto d-block" width="75%" />
<div class="carousel-caption">
<h3>JellyFish</h3>
<p>JellyFish Image Description</p>
</div>
</div>
<div class="carousel-item">
<img src="Images/Desert.jpeg" class="img-fluid mx-auto d-block" width="75%" />
<div class="carousel-caption">
<h3>desert</h3>
<p>Beutiful desert</p>
</div>
</div>
<div class="carousel-item">
<img src="Images/lighthouse.jpeg" class="img-fluid mx-auto d-block" width="75%" />
<div class="carousel-caption">
<h3>Lighthouse</h3>
<p>Lighthouse Image Description</p>
</div>
</div>
<div class="carousel-item">
<img src="Images/Penguin.jpg" class="img-fluid d-block" width="75%" />
<div class="carousel-caption">
<h3>Penguin</h3>
<p>Penguin Image Description</p>
</div>
</div>
</div>
<a href="#imageCarousel" class="carousel-control-next" data-slide="next"><span class="carousel-control-next-icon"></span></a>
</div>
</div>