2017-02-15 93 views
-1

我可以在CSS中的图像上使用display:block;border-radius?这是违背CSS原则吗?我可以在图像CSS上使用border-radious吗?

+3

的可能的复制[如何获得在所有浏览器中的图像完美的边界半径?](http://stackoverflow.com/questions/8444645/how-to-get-perfect-border-radius-on-图像功能于所有的浏览器) – jrn

+2

如果你拼了'边界radius',肯定;) –

回答

1

当然可以。 :)

您可以轻松地给图像的任何你喜欢的号码border-radius
50%或以上的和圆形的图像。您也可以使用px


例如:

您在HTML文档中的某个地方有一个形象:

<img id="image" src="Your source"> 

在你的CSS文件,你可以简单的写:

#image { 
    border-radius: 50px; <-- example number 
} 
0

检查this answer优素福:

.img-border{ 
    border-radius:15px; 
    -moz-border-radius:15px; 
    -webkit-border-radius:15px; 
    border:3px solid red; 
} 
0

是,IMG标签是inline-block的元素,但你可以改变它的宽度和高度,像块元素。

喜欢本作例子:

.img-circular{ 
    width: 200px; 
    height: 200px; 
    background-image: url('http://strawberry-fest.org/wp-content/uploads/2012/01/Coca-Cola-logo.jpg'); 
    background-size: cover; 
    display: block; 
    border-radius: 100px; 
    -webkit-border-radius: 100px; 
    -moz-border-radius: 100px; 
    } 
相关问题