首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >带虚线叠加和帖子标题的Jumbotron

带虚线叠加和帖子标题的Jumbotron
EN

Stack Overflow用户
提问于 2015-09-03 20:41:40
回答 2查看 159关注 0票数 0

我正在工作,我的第一个网站由扫描,现在我面临一些挑战,以给它的外观,我想。

基于引导,我将在万宝管内的帖子标题,以特色图像为背景。为了使其更加可见,我想要放置一个重叠的虚线div,而不是编辑每一个图像更暗,以匹配我的帖子标题。

我取得了几乎所有的成功,但我不能把标题放在圆点之上,所以它也被涵盖了。

代码语言:javascript
复制
<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:

代码语言:javascript
复制
.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;
}

谁来帮我?提前感谢!

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-09-03 21:09:34

您的问题是“z索引”顺序尝试如下:

这里的工作示例:http://codepen.io/Tmeister/pen/qOEmVy

代码语言:javascript
复制
.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;
}
票数 0
EN

Stack Overflow用户

发布于 2015-09-03 21:07:20

要使用z-index,必须显式地将元素的位置设置为absolutefixedrelative

代码语言:javascript
复制
<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:

代码语言:javascript
复制
.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;
}

下面是一个工作示例的小提琴:小提琴

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32385054

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档