简体   繁体   English

如何使文本显示在该引导轮播中的叠加层上方?

[英]How do I get the text to show above the overlay in this bootstrap carousel?

I'm currently working on a project and I want to use this full screen carousel ( http://bootsnipp.com/snippets/ZkRvj ). 我目前正在从事一个项目,并且希望使用此全屏轮播( http://bootsnipp.com/snippets/ZkRvj )。 I'm currently using the latest bootstrap 3 version (3.3.7) however this particular snippet was built for 3.2.0. 我目前正在使用最新的bootstrap 3版本(3.3.7),但是此特定代码段是为3.2.0构建的。

(If you change the bootstrap version in bootsnipp to the latest, you can also replicate the problem) (如果将bootsnipp中的引导程序版本更改为最新版本,则也可以复制该问题)

The issue I am having is that the DIV .overlay used to darken the background of each slide in the carousel is also overlapping the text and button which means the text and button is also getting darkened. 我遇到的问题是,用于使轮播中每张幻灯片的背景变暗的DIV .overlay也与文本和按钮重叠,这意味着文本和按钮也越来越暗。 I have tried giving the .hero class (used for the text and button) and the child elements a higher z-index however this does not fix the problem. 我尝试给.hero类(用于文本和按钮)和子元素赋予更高的z-index,但这不能解决问题。 I have also tried lowering the overlay z-index but this also doesn't work. 我也曾尝试降低叠加层的Z-index,但这也行不通。

This issue does not show in bootstrap 3.2.0 but in 3.3.7 it does and I have no idea how to get around this issue. 此问题在bootstrap 3.2.0中未显示,但在3.3.7中显示,并且我不知道如何解决此问题。

Thanks 谢谢

I don't know why the change in bootstrap version should give this issue, though it obviously does... 我不知道为什么引导程序版本的更改应该会引起此问题,尽管它显然可以...

I got around your problem using 3 steps: 我通过3个步骤解决了您的问题:

1) Give .carousel-inner a background-color: #000; 1)给.carousel-inner一个background-color: #000; .

2) Delete the '.overlay' div. 2)删除“ .overlay” div。

3) In your .slide-x rule (where you set the background image), add opacity: 0.4; 3)在.slide-x规则中(设置背景图片),添加opacity: 0.4; .

Basically, this makes the image semi opaque, but not your hero. 基本上,这会使图像变得不透明,但对您的英雄却不透明。 As you can see through the image to the (now) black background of the slide container you get exactly the same effect without the z-index heartache. 您可以从图像中看到幻灯片容器的(现在)黑色背景,您可以获得完全相同的效果,而没有z-index心痛。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM