我正在工作,我的第一个网站由扫描,现在我面临一些挑战,以给它的外观,我想。
基于引导,我将在万宝管内的帖子标题,以特色图像为背景。为了使其更加可见,我想要放置一个重叠的虚线div,而不是编辑每一个图像更暗,以匹配我的帖子标题。
我取得了几乎所有的成功,但我不能把标题放在圆点之上,所以它也被涵盖了。
<div id="capa" class="jumbotron text-center" style="background-image:url('PHP TAG FOR FEATURED IMAGE');">
<h1 class="titulo-post"><?php the_title(); ?></h1>
<p class="data-post"><?php echo ucfirst(get_the_time('l, j \d\e F \d\e Y')); ?></p>
<div id="dot-matrix"></div>下面是CSS:
.jumbotron {
margin-top:-30px;
padding: 100px 0;
background-position:center;
background-repeat:no-repeat;
background-size:cover;
}
#capa {
background-size: 100% auto;
border-radius: 6px;
margin-top: -20px;
position: relative;
}
#capa h1 {
z-index: 9999;
}
#dot-matrix {
background: url(http://www.the215guys.com/wp-content/themes/the215guys/images/graphics/pattern-1.png);
height: 100%;
width: 100%;
position: absolute;
top: 0;
z-index: 1;
}谁来帮我?提前感谢!
发布于 2015-09-03 21:09:34
您的问题是“z索引”顺序尝试如下:
这里的工作示例:http://codepen.io/Tmeister/pen/qOEmVy
.jumbotron {
margin-top:-30px;
padding: 100px 0;
background-position:center;
background-repeat:no-repeat;
background-size:cover;
}
#capa {
background-size: 100% auto;
border-radius: 6px;
margin-top: -20px;
position: relative;
z-index: 1
}
#capa h1 {
z-index: 2;
color: white;
font-size: 5em;
}
#dot-matrix {
background: url(http://www.the215guys.com/wp-content/themes/the215guys/images/graphics/pattern-1.png);
height: 100%;
width: 100%;
position: absolute;
top: 0;
z-index: -1;
}发布于 2015-09-03 21:07:20
要使用z-index,必须显式地将元素的位置设置为absolute、fixed或relative。
<div id="capa" class="jumbotron text-center" style="background-image:url('PHP TAG FOR FEATURED IMAGE');">
<div id="dot-matrix"></div>
<h1 class="titulo-post"><?php the_title(); ?></h1>
<p class="data-post"><?php echo ucfirst(get_the_time('l, j \d\e F \d\e Y')); ?></p>
</div>CSS:
.jumbotron {
margin-top:-30px;
padding: 100px 0;
height: 300px;
background-position:center;
background-repeat:no-repeat;
background-size:cover;
}
#capa {
background-size: 100% auto;
border-radius: 6px;
margin-top: -20px;
position: relative;
}
#capa h1 {
z-index: 0;
position: absolute;
left: 0;
right: 0;
color: white;
}
.data-post {
position: absolute;
left: 0;
right: 0;
top: 200px;
color: white;
}
#dot-matrix {
background: url(http://www.the215guys.com/wp-content/themes/the215guys/images/graphics/pattern-1.png);
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 1;
}下面是一个工作示例的小提琴:小提琴
https://stackoverflow.com/questions/32385054
复制相似问题