Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/81.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
Html (背景尺寸:封面)覆盖衬垫_Html_Css - Fatal编程技术网

Html (背景尺寸:封面)覆盖衬垫

Html (背景尺寸:封面)覆盖衬垫,html,css,Html,Css,我正在寻找关于背景尺寸:封面的帮助 所以我遇到的问题是,我的图像框上有填充物,但是在CSS中设置背景图像似乎使图像覆盖了图像框填充物,而不是填充物内部 我想知道是否有任何方法可以通过background:url()和background size将其放在填充中而不是覆盖填充 到目前为止,我所拥有的: .image容器{ 背景:#eee; 宽度:100%; 高度:120px; } .image容器div.image{ 背景:#ee1; 身高:100%; 宽度:50%; 显示:内联块; 浮动:左;

我正在寻找关于
背景尺寸:封面的帮助

所以我遇到的问题是,我的图像框上有填充物,但是在
CSS
中设置背景图像似乎使图像覆盖了图像框填充物,而不是填充物内部

我想知道是否有任何方法可以通过
background:url()
background size
将其放在填充中而不是覆盖填充

到目前为止,我所拥有的:

.image容器{
背景:#eee;
宽度:100%;
高度:120px;
}
.image容器div.image{
背景:#ee1;
身高:100%;
宽度:50%;
显示:内联块;
浮动:左;
填充:4px0px;
背景:url(“https://static.pexels.com/photos/14621/Warsaw-at-night-free-license-CC0.jpg");
背景尺寸:封面;
}

您可以使用边框而不是填充

比如:

.image-container div.image {
  padding: 4px 0px; /* remove this */
  ...
  border-top: 4px solid transparent; /* or whatever color */
  border-bottom: 4px solid transparent; /* or whatever color */
  box-sizing: border-box;
  background-size: cover;
}
.image容器{
背景:#eee;
宽度:100%;
高度:120px;
}
.image容器div.image{
背景:#ee1;
身高:100%;
宽度:50%;
显示:内联块;
浮动:左;
边框顶部:4px纯绿色;/*使用仅用于演示的颜色*/
边框底部:4px纯绿色;/*使用仅用于演示的颜色*/
框大小:边框框;
背景:url(“https://static.pexels.com/photos/14621/Warsaw-at-night-free-license-CC0.jpg");
背景尺寸:封面;
}

你不能用边距代替填充吗?嘿,克里斯,你想要这个吗