Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.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,我怎么能忽略一个宽度 假设我有这样一个代码: HTML: 我也会设置一个填充,而不是宽度,如: padding-left:20% padding-right20% 然后,我希望我的图像比它所在的容器有更大的宽度 #content-container img { width:1000px; } 但这现在确实起作用了,因为图像不会从它的容器中出来 除了使用position:absolute之外,还有其他解决方案吗或某些负边距值?将容器宽度更改为大 #content-container

我怎么能忽略一个宽度

假设我有这样一个代码:

HTML:

我也会设置一个填充,而不是宽度,如:

padding-left:20%
padding-right20%
然后,我希望我的图像比它所在的容器有更大的宽度

#content-container img {
  width:1000px;
}
但这现在确实起作用了,因为图像不会从它的容器中出来


除了使用
position:absolute之外,还有其他解决方案吗或某些负边距值?

将容器宽度更改为大

    #content-container {
  margin: 0 auto;
  width: 100%;
}
并更改图像宽度

    #content-container img {
  width:100%;
}
您的图像宽度必须小于容器或等于容器的宽度

请尝试此代码

#content-container img {width:100%;}

呜呜声。那只是问题中的一个错误。我的密码里没有。这只是一个例子。你不应该把东西放在一个容器里,如果它要比容器大/在容器外面的话。把它放在容器的上方或下方。我可以帮你,但我还是不明白你想达到什么目的。是否希望图像大于div,是否将图像调整为div大小,还是将div调整为图像大小?是否希望在图像的div内填充,并在div内留有一些间距?
    #content-container img {
  width:100%;
}
#content-container img {width:100%;}