【发布时间】:2016-01-20 15:39:53
【问题描述】:
我在我添加文本的地方制作了一个全宽图像。 很长一段时间以来,我一直在挠头。 我正在尝试找到添加上下边框文本的最佳解决方案。
但是,我希望边框的长度只有一半或更短,但我就是想不通。
在标记类之前,我尝试在文本容器 div 上使用边框,但在将文本居中和对齐时遇到了问题。
现在是这样的:
CSS:
.adcontainer {
position: relative;
width: 100%;
height: auto;
}
.adcontainer img {
width: 100%;
height: auto;
}
.adcontainertext {
position: absolute;
top: 25%;
left: 15%;
z-index: 0;
padding: 0;
padding: 1.2em;
font-size: .5em;
text-align: center;
}
.advertheading
{
font-size: 20px;
border-bottom: 1px solid white;
border-top: 1px solid white;
line-height: 100px;
display:inline-block
}
HTML:
<div style="clear: both;">
<div class="adcontainer"><img src="https://cdn.shopify.com/s/files/1/0786/5107/files/LARGE_BANNER-BELOW.jpg?5938182738858039286" />
<div class="adcontainertext">
<h2 class="advertheading" style="font-weight: normal; color: #ffffff;">Join the club</h2>
</div>
</div>
</div>
最好的问候, 罗宾。
【问题讨论】: