html - 如何向 html 边框添加填充/类似效果

标签 html css

我有这条线

<div class="fixedwidthDiv HRSeparator"></div>

我继承的整个html代码。 它分隔文本的段落。 我想要的是在这条水平线的左右两侧添加 15px 的填充,因为我使用 Bootstrap col-md-12 类也添加了这个并且我有

<div class="fixedwidthDiv col-md-12">

也在我的 html 中的多个位置。所以我想对齐文本起始位置和水平线。

http://jsfiddle.net/Ne5GE/1/

最佳答案

如果您希望将元素下方的文本与水平线对齐,请将所有内容包裹在填充容器中。

HTML

<div id="container">
<div class="fixedwidthDiv HRSeparator"></div>
    <p>This is some text that will align with the HRSeparator</p>
</div>

CSS

.container{
    margin: 0px 15px;
}
.HRSeparator {
    border-bottom: 1px solid;
    margin-bottom: 2em;
    margin-top: 2em;
}
.fixedwidthDiv {
   overflow: hidden;
   max-width: 900px;
}

JS fiddle : http://jsfiddle.net/Ne5GE/2/

关于html - 如何向 html 边框添加填充/类似效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20968841/

相关文章:

php - 关于邮寄 ascii 图像 -php

html - 仅在换行上使用文本缩进

css - IE7 float 错误。是否有维护 html 的修复程序?

css - 限制高度与页面底部的距离

css - 我怎样才能打破网格?有这方面的普遍做法吗?

css - 样式表中的 Url.Content()?

javascript - jquery 只克隆文本而不是属性不起作用

html - .card 类中的列不会相互内联

javascript - CSS margin-top 和 top 没有绑定(bind)

javascript - 将文件拖放到隐藏元素上