中间带有图像图标的分隔符

Seperator with image icon in the middle

我正在尝试制作一个中间有图像的分隔符。这也是响应式的。

我无法以全尺寸显示行中间的 icon/image。它似乎切断了顶部和底部。有人可以看一下代码吗?

<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%;
}

https://jsfiddle.net/L5p8khya/

这就是你想要的吗?只需给图像一个高度。还要添加等于图像一半的边距顶部(在本例中为 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;
}
<div class='line-icon'></div>

这是您想要得到的。检查结果

.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%);
}
<div class='line-icon'></div>