Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何设置css内容图像的大小?_Css_Pseudo Element - Fatal编程技术网

如何设置css内容图像的大小?

如何设置css内容图像的大小?,css,pseudo-element,Css,Pseudo Element,我有一个伪元素,看起来像这样。我想通过缩小50%来改变图像的大小,这样它也可以在高分辨率屏幕上工作。如何执行此操作?您只需将“宽度”和“高度”属性设置为50%。这将根据浏览器窗口对其进行缩放 祝你好运 此外,您可以将内容设置为空字符串并使用背景图像。或者 .upper-menu .search-form::after { content: url('../images/search.png'); position: absolute; height: 10px; top: 5px

我有一个伪元素,看起来像这样。我想通过缩小50%来改变图像的大小,这样它也可以在高分辨率屏幕上工作。如何执行此操作?

您只需将“宽度”和“高度”属性设置为50%。这将根据浏览器窗口对其进行缩放


祝你好运

此外,您可以将内容设置为空字符串并使用背景图像。或者

.upper-menu .search-form::after {
  content: url('../images/search.png');
  position: absolute;
  height: 10px;
  top: 5px;
  right: 22px;
}

实际上,它将相对于搜索表单而不是浏览器窗口进行缩放。实际上,它将精确缩放到指定的尺寸-即10px。尝试背景尺寸:10px 5px;
.upper-menu .search-form::after {
  content: ' ';
  display: inline-block;
  position: absolute;
  background: #bada55 url("img_2x.png") no-repeat;
  background-size: contain;
  height: 10px;
  width: 10px;
  top: 5px;
  right: 22px;
}