jquery - 如何在CSS导入的图像上应用CSS

标签 jquery css

如何将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/

相关文章:

javascript - 选择框更改后提醒元素

javascript - 一个Jquery元素引用占用多少内存?

javascript - 如何借助 javascript 查找打印机列表?

html - nav-tabs 不滚动 overflow-x : scroll

css - 如何使用 CSS 将按钮移动到新行?

html - 标题居中但副标题居中 "right"

带有 + 和 - 的 jQuery Accordion 式常见问题解答

php - 如何将ajax中的数据显示到smarty模板中?

html - 链接标签内的图像

google-chrome - 将 css3 旋转到 Chrome 中的 DIV,然后背景附件 :fixed creating bug