[英]how to make carousel slider image responsive
I tried lot but didn't find the solution how to make image responsive and my caption also not in responsive.我尝试了很多,但没有找到如何使图像响应的解决方案,我的标题也没有响应。
here is my html code:这是我的 html 代码:
<section id="banner">
<div class="banner-bg">
<div class="banner-bg-item"><div class="textoverlay"><h3 id="caption1">Suburban Mumbai’s Best Serviced Apartment</h3><h3 id="caption2">The Perfect Home Away From Home</h3>
</div>
<img class='img-responsive' src="<?php echo base_url('assets/img/slider-1.jpg'); ?>" alt="">
</div>
<div class="banner-bg-item"><div class="textoverlay"><h3 id="caption1">Suburban Mumbai’s Best Serviced Apartment</h3><h3 id="caption2">The Perfect Home Away From Home</h3>
</div>
<img class='img-responsive' src="<?php echo base_url('assets/img/slider-2.jpg'); ?>" alt="">
</div>
<div class="banner-bg-item"><div class="textoverlay"><h3 id="caption1">Suburban Mumbai’s Best Serviced Apartment</h3><h3 id="caption2">The Perfect Home Away From Home</h3>
</div>
<img class='img-responsive' src="<?php echo base_url('assets/img/slider-3.jpg'); ?>" alt="">
</div>
<div class="banner-bg-item"><div class="textoverlay"><h3 id="caption1">Suburban Mumbai’s Best Serviced Apartment</h3><h3 id="caption2">The Perfect Home Away From Home</h3>
</div>
<img class='img-responsive' src="<?php echo base_url('assets/img/slider-4.jpg'); ?>" alt="">
</div>
<div class="banner-bg-item"><div class="textoverlay"><h3 id="caption1">Suburban Mumbai’s Best Serviced Apartment</h3><h3 id="caption2">The Perfect Home Away From Home</h3>
</div>
<img class='img-responsive' src="<?php echo base_url('assets/img/slider-5.jpg'); ?>" alt="">
</div>
</div>
</div>
Here is my css code:这是我的 css 代码:
#banner .banner-bg .banner-bg-item {
height: 100vh;
min-height: 650px;
background-size: cover;
background-position: center;
}
#banner .banner-bg .banner-bg-item .img-responsive{
max-width: 100%;
height: auto !important;
display:block;
}
@media (max-width: 768px) {
#banner .banner-bg .banner-bg-item {
min-height: 920px;
}
.banner-bg .banner-bg-item .textoverlay{
padding-top: 30%;
padding-left: 12%;
color: white;
}
.banner-bg .banner-bg-item .textoverlay #caption1{
background-color: rgba(0, 26, 9, 0.3);
width: 640px;
}
.banner-bg .banner-bg-item .textoverlay #caption2{
background-color: rgba(0, 26, 9, 0.3);
width: 500px;
}
I provide the html and css code of my website .我提供了我网站的 html 和 css 代码。 i tried it lot but cant able to make my image responsive.
我尝试了很多,但无法使我的图像响应。 for the slider i used owl.crousle ..please help me to find out any way to slove this problem.I searched on google but i didn't find any article ..please help me to find the solution.
对于滑块,我使用了 owl.crousle ..请帮我找出解决这个问题的任何方法。我在谷歌上搜索,但没有找到任何文章..请帮我找到解决方案。
Try this尝试这个
.banner-bg .banner-bg-item .textoverlay{
padding-top: 30%;
padding-left: 12%;
color: white;
}
.banner-bg .banner-bg-item .textoverlay #caption1{
background-color: rgba(0, 26, 9, 0.3);
width: 100%;
}
.banner-bg .banner-bg-item .textoverlay #caption2{
background-color: rgba(0, 26, 9, 0.3);
width: 100%;
}
Use this slider startbootstrap-full-slider使用这个滑块startbootstrap-full-slider
Try this CSS,试试这个 CSS,
#banner .banner-bg .banner-bg-item {
height: 75%;
min-height: 250px;
background-size: cover;
background-position: center;
width: 50%;
}
.textoverlay {
height: 10%;
}
#banner .banner-bg .banner-bg-item .img-responsive{
max-width: 100%;
display: block;
height: 90%;
}
@media (max-width: 768px) {
#banner .banner-bg .banner-bg-item {
min-height: 920px;
}
.banner-bg .banner-bg-item .textoverlay{
padding-top: 30%;
padding-left: 12%;
color: white;
}
.banner-bg .banner-bg-item .textoverlay #caption1{
background-color: rgba(0, 26, 9, 0.3);
width: 640px;
}
.banner-bg .banner-bg-item .textoverlay #caption2{
background-color: rgba(0, 26, 9, 0.3);
width: 500px;
}
For making Responsive Images, its good to specify the height and width in ' % ', or use @media to specify the size for particular screen.为了制作响应式图像,最好在 ' % ' 中指定高度和宽度,或者使用@media指定特定屏幕的大小。 size in ' % ' can change the size of images, but you have to use @media and specify the font size for text .
' % ' 中的 size 可以改变图像的大小,但你必须使用@media并指定text的字体大小。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.