我目前使用下面的代码得到以下内容,似乎无法完全满足我的需要.
我的CSS:
hr:after {
background: url('../img/green_leaf.png') no-repeat top center;
content: "";
display: block;
height: 18px; /* height of the ornament */
position: relative;
top: -9px; /* half the height of the ornament */
border: 0;
color: #d7d7d7;
}
Run Code Online (Sandbox Code Playgroud)
我想加粗线条,如果可能的话,在图像周围添加空间(不要让green_leaf.png有白色bg).
Ale*_*ara 13
如何在hr元素中设置图像,使用:before和:after创建线条?这样您就不必在图像上设置背景来掩盖单行.
hr {
background: url('http://i.stack.imgur.com/37Aip.png') no-repeat top center;
background-size: contain;
display: block;
height: 18px;
border: 0;
position: relative;
}
hr:before,
hr:after {
content: '';
display: block;
position: absolute;
background: #d7d7d7;
height: 2px;
top: 8px;
}
hr:before {
left: 0;
right: 50%;
margin-right: 10px;
}
hr:after {
right: 0;
left: 50%;
margin-left: 10px;
}Run Code Online (Sandbox Code Playgroud)
<hr />Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5520 次 |
| 最近记录: |