2016-02-24 122 views
-3

我正在尝试在图像中绘制边框,但是从边缘分离而没有任何成功。请,看一个例子如何在图像中绘制边框?

enter image description here

+0

提供一些编码 –

+0

请提供一些代码。它可能是有用的。 –

回答

1

将一个格上的第二格另一个使用绝对定位顶部,并且相对于在第一。然后将您的图像设置为底部div的背景。顶部div然后需要有边框和透明背景:https://jsfiddle.net/5r1st8cL/

<div class="one"> 
    <div class="two"></div> 
</div> 

    .one { 
    background-image: url(''); 
    background-size: cover; 
    width: 600px; 
    height: 400px; 
    background: yellow; 
    position: relative; 
} 
.two { 
    width: 500px; 
    height: 300px; 
    position: absolute; 
    border: 3px solid black; 
    top: 50px; 
    left: 50px; 
    background: transparent; 
    } 
+0

https://jsfiddle.net/5r1st8cL/1/ – lucasjohnson

1

请尝试以下代码。 ref

img { 
    outline: 1px solid white; 
    outline-offset: -4px; 
} 
+0

非常感谢大家。我终于测试了Microsmsn提供的解决方案,并且它完美地工作。最简单和最好的解决方案 – alvarola