我对引导程序和Web开发真的很陌生,我不知道该怎么做。我为必须为计算机科学课程制作的网站制作了一个轮播,但是后来我添加了标题,现在,当我将网站缩小到移动大小时,标题就消失了。这是我的轮播HTML:
<div id="carouselExampleFade" class="carousel slide carousel-fade" data-ride="carousel">
<div class="carousel-prev"></div>
<div class="carousel-next"></div>
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="christmas.jpg" alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="christmas2.jpg" alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="christmas3.jpg" alt="Third slide">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleFade" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleFade" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
<div class="carousel-caption d-none d-md-block">
<h5 class="myText">Our shop</h5>
<p>Browse our catalog and discover great discounts</p>
</div>
</div>
这是我的CSS:
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
.carousel-image {
height: 100vh;
}
.full-screen {
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
.z-index-1 {
z-index: 1;
}
.z-index-2 {
z-index: 2;
position: absolute;
width: 100%
}
.myText {
font-size: 70px;
-webkit-text-stroke: 4px red;
}
.controls {
margin-top: 0%;
}
.myHR {
border-width: 4px;
border-color: white;
margin-left: 30%;
margin-right: 30%;
}
.carousel-paragraph {
font-size: 25px;
}
.carousel-caption {
top: 40%;
position: absolute;
}
这是我的javascript:
var $item = $('.carousel-item');
var $wHeight = $(window).height();
$item.eq(0).addClass('active');
$item.height($wHeight);
$item.addClass('full-screen');
$('.carousel img').each(function() {
var $src = $(this).attr('src');
var $color = $(this).attr('data-color');
$(this).parent().css({
'background-image' : 'url(' + $src + ')',
'background-color' : $color
});
$(this).remove();
});
$(window).on('resize', function (){
$wHeight = $(window).height();
$item.height($wHeight);
});
$('.carousel').carousel({
interval: 6000,
pause: "false"
});
答案 0 :(得分:0)
没关系,我只是从标题部门中删除了d-none类。看来对我有用。
<div class="carousel-caption d-md-block">
<h5 class="myText">Our shop</h5>
<p>Browse our catalog and discover great discounts</p>
</div>