Ruby on Rails:通过Carrierwave应用阴影 [英] Ruby on Rails: apply drop shadow with Carrierwave
问题描述
如何为使用载波保存的图像添加阴影?我找不到有关如何执行此操作的示例。
How do I apply a drop shadow to my images saved with carrierwave? I can't find any examples on how to do this.
更新:
使用CSS向图像添加阴影的示例。如果您不喜欢图片周围的白色1px边框,则可以删除填充和边距。
Update: Example for adding a shadow to images with CSS. You can remove the padding and margin if you don't like the white 1px border around the image. It looks nice though...
.dropSmallShadow {
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.255);
margin-left: 1px;
padding: 1px;
}
最诚挚的问候
AsbjørnMorell
Best regards Asbjørn Morell
推荐答案
我的建议是不要在图像中添加边框/阴影(因为稍后可能要以不同的方式显示它们),而是使用CSS添加它们。
My recommendation is to not add the border/dropshadow in the image (since you may want to display them differently later on), but instead add them using CSS.
例如,您可以在图像周围添加5 px的白色填充,然后使用 http://www.css3.info/preview/box-shadow/
for example, you can add a 5 px white padding around the image, and then a box-shadow using http://www.css3.info/preview/box-shadow/
IE会降级为仅具有宝丽来的白色边框。
IE will degrade to just having the white border like a polaroid.
这篇关于Ruby on Rails:通过Carrierwave应用阴影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!