html - 如何使用::after/::before 伪元素更改内容 url 图片的大小

标签 html css

首先是我要更改的代码。

<style>
  h1::after {
    content: url(sig01.png);
  }
</style>

第二个是我尝试过的,但没有用。

<style>
    h1::after {
        content: url(sig01.png);
        display: inline-block;
        width: 200px;
        height: 200px;
    }
</style>

我做错了什么?

最佳答案

您无法调整内容图像的大小,但您可以使用 background-image 而不是 content 来变通。

<style>
h1::after {
  content: '';
  display: inline-block;
  width: 200px;
  height: 200px;
  background-image: url(sig01.png);
  background-size: 200px;
}
</style>

关于html - 如何使用::after/::before 伪元素更改内容 url 图片的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58902930/

相关文章:

javascript - Bootstrap 模型传递的文本显示为原始文本而不是 html(示例 </br> 显示而不是新行)

css - 如何在同一个类之间隐藏带有CSS的元素

html - Bootstrap 在中间垂直对齐内容

javascript - 无法在屏蔽的电话号码中通过退格键删除

html - ie8中内容下的子菜单

html - bootstrap-将头像放在带下拉菜单的标题的最右侧

html - 如何在 Bootstrap 列中居中图像

html - 哪些网络浏览器(以及哪些版本)实现了 autocomplete=off 功能?

jquery - 将输入分组到 Jquery Mobile 中的同一行

html - 如何将 <div> 定位在另一个 <div> 的正下方