如何将CSS应用到由css通过background: url('..')属性导入的图像上。 例如:我想在 image.jpg 上应用 border-radius 。
<div></div>
div {
background: url('image.jpg');
}
最佳答案
您无法直接设置背景图像的样式。您可以设置图像作为背景的元素的样式;在此示例中,为 div
。如果您想要边框半径,只需在 CSS 中添加 border-radius
即可。
即使您在 div
上设置了边框半径,它仍然会有一个方形边框:
div {
width: 200px;
height: 200px;
background: url('http://lorempixel.com/200/200/');
border-radius: 50%;
}
<div>
Text in here is not automatically inside the "circle."
</div>
关于jquery - 如何在CSS导入的图像上应用CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27645181/