我试图在中间创建一个带有图像的分隔符。这也是响应。
我无法在线条中间以完整尺寸显示图标/图像。它似乎切断了顶部和底部。有人可以看看代码吗?
<div class='line-icon'></div>
.line-icon {
text-align: center;
background-image: url('http://www.welzendesign.com/startransfer/wp-content/uploads/2015/10/ster.png');
background-repeat: no-repeat;
background-position: center center;
}
.line-icon::before, .line-icon::after {
width: 25%;
height: 1px;
border-top: 1px solid #837048;
display: inline-block;
content:'';
padding-top: 0.5em;
margin-left: 5%;
margin-right: 5%;
}
答案 0 :(得分:2)
这是你想要得到的。检查结果
.line-icon {
box-sizing: border-box;
position:relative;
text-align: center;
background-image: url('http://www.welzendesign.com/startransfer/wp-content/uploads/2015/10/ster.png');
background-repeat: no-repeat;
background-position: center center;
font-size:0;
height: 40px;
}
.line-icon::before, .line-icon::after {
box-sizing: border-box;
width: 40%;
height: 1px;
border-top: 1px solid #837048;
display: inline-block;
content:'';
margin-left: 5%;
margin-right: 5%;
position:relative;
top: 50%;
-moz-transform: translatey(-50%);
-ms-transform: translatey(-50%);
-o-transform: translatey(-50%);
-webkit-transform: translatey(-50%);
transform: translatey(-50%);
}
&#13;
<div class='line-icon'></div>
&#13;
答案 1 :(得分:1)
认为这是你之后的事吗?只需给图像一个高度。还要添加一个等于图像一半的margin-top(在这种情况下为20px)。
.line-icon {
text-align: center;
background-image: url('http://www.welzendesign.com/startransfer/wp-content/uploads/2015/10/ster.png');
height: 40px;
background-repeat: no-repeat;
background-position: center center;
}
.line-icon::before, .line-icon::after {
width: 25%;
height: 1px;
border-top: 1px solid #837048;
display: inline-block;
content:'';
padding-top: 0.5em;
margin-left: 5%;
margin-right: 5%;
margin-top: 20px;
}
&#13;
<div class='line-icon'></div>
&#13;