[英]How to set inline rails image_tag as background image?
=image_tag "#{user.image}", :class => "user-photo"
this code above set the image, but I want all images to be circular. 上面的这段代码设置了图像,但是我希望所有图像都是圆形的。 If a user uploads a photo with the wrong dimensions, setting the border radius to 50% results in an oval photo, instead of a circular one. 如果用户上传尺寸错误的照片,则将边框半径设置为50%会生成椭圆形的照片,而不是圆形的照片。
I'm thinking if I can set the interpolated image inline as a background image, I can then make them all circular. 我在想是否可以将内插图像设置为背景图像,然后使它们全部为圆形。
.circular {
width: 300px;
height: 300px;
border-radius: 150px;
-webkit-border-radius: 150px;
-moz-border-radius: 150px;
background: url(http://link-to-your/image.jpg) no-repeat;
}
http://bavotasan.com/2011/circular-images-with-css3/ http://bavotasan.com/2011/circular-images-with-css3/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.