【发布时间】:2017-06-23 23:05:18
【问题描述】:
在this页面的底部,我试图将版权文本下的灰线设置为30%,所以它比文本短。我的问题是,当设置为小于文本长度的 % 时,它会将文本放在 2 行上。我想要一行文字。
版权箱代码:
.copyright-container{
box-sizing: border-box;
padding-right:20px;padding-left:20px;
background-color: black;
text-align: center;
position:relative;
bottom:0;
width:100%;
height:220px;
color: white;
}
.vert-align{
position: relative;
top: 50%;
}
.headline {
width: 30%;
line-height: 1.5em;
border-bottom:2px solid #6d6666;
margin:0px auto;
color:white;
}
其他代码:
<div class="copyright-container">
<div class="vert-align">
<p class="headline">Copyright © 2017 RyanTeaches - All Rights Reserved.</p>
</div>
</div>
我是 html 和 css 新手
非常感谢, 瑞恩
【问题讨论】:
-
仅使用
border-bottom规则是无法实现的。边框总是跨越它所附着的整个元素。您可以在<p class='headline'>中创建一个宽度为 30% 的新元素,将height设置为2px并将background设置为gray。
标签: javascript css html containers