2017-02-14 52 views
1

此代码创建一个(大致看起来像)灰色的1px固体边框。我将图像边框设置为无,但不会删除边框。无法从标签内部的img中删除边框

下面的代码:

<label> 
 
    <img style="width:200px;height:200px"> 
 
</label>

+0

你的CSS看起来像img和label? – Rahi

+0

http://stackoverflow.com/questions/10441362/how-can-i-remove-the-border-around-an-image-without-a-source –

回答

3

这是你的HTML是无效的副作用。使用a validator

一个img元素必须有一个src。指定要加载的图像以及边框消失。

<label> 
 
    <img src="https://images.vexels.com/media/users/3/137685/isolated/lists/c078654c8b1501b4c9ee784a330210e5-logo-geometric-polygonal.png" style="width:200px;height:200px"> 
 
</label>

如果你想一定尺寸的盒子,而无需加载图像:使用div或不同的元素。

+0

不错,havnt甚至注意到该html无效... –

0

您的img标记语法错误。您有:

<label> 
    <img style="width:200px;height:200px;"> 
</label> 

,但它应该是:

<label> 
    <img src="myimage.jpg" style="width:200px;height:200px;"> 
</label> 

则边框将消失!如果你只是想一个白色正方形用途:

<label> 
    <div style="width:200px; height: 200px;"></div> 
</label> 

让我知道如果你需要任何更多的澄清!