我正在使用Bootstrap v4创建一个包含带有标题文本的图像的轮播。我希望图像褪色但文本不受影响。我尝试了各种非Bootstrap解决方案,但我无法获得任何工作。请帮忙:(
链接到开发站点; http://www.atlasestateagents.co.uk/mlb/
代码:
<div id="home-page-carousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#home-page-carousel" data-slide-to="0" class="active"></li>
<li data-target="#home-page-carousel" data-slide-to="1"></li>
</ol>
<!-- Content -->
<div class="carousel-inner" role="listbox">
<!-- Slide 1 -->
<div class="carousel-item active"> <img src="<?php echo SITE_IMG . 'L1.jpg'; ?>" alt="Liverpool City Centre">
<div class="carousel-caption">
<h3>This is a title</h3>
<p>This is some text that is relevant to the title above</p>
</div>
</div>
<!-- Slide 2 -->
<div class="carousel-item"> <img src="<?php echo SITE_IMG . 'L1.jpg'; ?>" alt="Liverpool City Centre">
<div class="carousel-caption">
<h3>This is a title</h3>
<p>This is some text that is relevant to the title above</p>
</div>
</div>
</div>
<!-- Previous/Next controls -->
<a class="left carousel-control" href="#home-page-carousel" role="button" data-slide="prev"> <span class="icon-prev" aria-hidden="true"></span> <span class="sr-only">Previous</span> </a> <a class="right carousel-control" href="#home-page-carousel" role="button" data-slide="next"> <span class="icon-next" aria-hidden="true"></span> <span class="sr-only">Next</span> </a> </div>
<!-- Center the image -->
<style scoped>
.carousel-item img{
margin: 0 auto;
}
</style>
答案 0 :(得分:1)
基于此HTML
<div class="carousel-item"> <img src="<?php echo SITE_IMG . 'L1.jpg'; ?>" alt="Liverpool City Centre">
<div class="carousel-caption">
<h3>This is a title</h3>
<p>This is some text that is relevant to the title above</p>
</div>
</div>
</div>
你要求:
.carousel-item img {
opacity: /* whatever */
}
答案 1 :(得分:0)
在我看来,你只需要减少图像本身的不透明度:
.carousel-item img {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; /* IE 8 */
filter: alpha(opacity=50); /* IE 5-7 */
-moz-opacity: 0.5; /* Netscape/Firefox */
-khtml-opacity: 0.5; /* Safari 1.x */
opacity: 0.5; /* Good browsers */
}