【发布时间】:2017-03-26 17:59:18
【问题描述】:
我正在尝试从具有背景图像的元素的中心显示文本。如果我将动画的背景设为纯色,那么该纯色会出现在文本周围,直到动画完成。如果我在文本后面放置与包含元素后面相同的背景图像,那么在我的文本周围会出现相同图像的不同版本。有什么建议吗?
html:
<div class="container-big" id="the-wall">
<div class="chapter-hed">
<h5>PART 1</h5>
<h4 class="showhead">My heading</h4>
</div>
</div>
css:
#the-wall {
background-image: url(../img/wopo-3.png);
background-position: center;
background-size: cover;
background-color: black;
}
.chapter-hed h4 {
font-family: 'proxima-nova';
font-weight: 700;
font-size: 5rem;
letter-spacing: -2.4px;
line-height: 6.2rem;
text-align: center;
color: white;
margin: 0 auto;
border-bottom: 10px solid #e40d0d;
}
.chapter-hed h4:before {
left:0;
}
.chapter-hed h4:after {
right:0;
}
.chapter-hed h4:after,.chapter-hed h4:before {
position:absolute;
content:"";
height:100%;
height: 109px;
/*background:black;*/
background-image: url(../img/wopo-3.png);
background-position: center;
background-size: cover;
background-color: black;
}
.showhead:after, .showhead:before {
animation: revealText 4s;
animation-fill-mode:forwards;
}
@keyframes revealText {
0% {
width:50%
}
100% {
width:0%
}
}
【问题讨论】:
标签: css background-image css-animations