Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/79.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/1/wordpress/12.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 Can';t添加高度:自动添加到背景_Html_Wordpress_Css - Fatal编程技术网

Html Can';t添加高度:自动添加到背景

Html Can';t添加高度:自动添加到背景,html,wordpress,css,Html,Wordpress,Css,请看 我想给评论区加一个纯色。此背景色应根据评论区域放大。如果有很多评论的话,它应该有一个很大的高度,很少的评论,很少的高度 我在名为的新div中添加了,并给出了以下css: #commentsbackground { width: 6000px; margin-left: -1172px; background-color: #A6A8AF; } section.comment { height: 500px; margin-left: 1172px;} 有了这个,我成功地添加了大

请看

我想给评论区加一个纯色。此背景色应根据评论区域放大。如果有很多评论的话,它应该有一个很大的高度,很少的评论,很少的高度

我在名为
的新div中添加了
,并给出了以下css:

#commentsbackground {
width: 6000px;
margin-left: -1172px;
background-color: #A6A8AF;
    }

section.comment {
height: 500px;
margin-left: 1172px;}
有了这个,我成功地添加了大背景,应该可以与所有大显示器的分辨率一起工作。不知道是否有一个简单的方法来做。。。。但肯定不是我想的那样

我想要
height:auto,但它不起作用

我希望你能帮助我有一个不同的背景颜色的评论区。 这应该是最终结果:

-张贴区->白色
-评论区->灰色

-页脚->黑色
好吧,如果您使用溢出自动,所有灰色背景将填满所有屏幕:p

#commentsbackground {
width: 6000px;
margin-left: -1172px; /*Idk, why do you use that*/
background-color: #A6A8AF;
overflow:auto;
    }

将容器更改为float:left或添加清除方法:

左边距:-1172px?考虑学习CSS的位置,谢谢你的建议。我会尝试使用<代码>浮点,用于代码里面的所有对象。它起作用了。我使用
左边距:-1172px
因为我尝试了很多方法让背景色存在于
中,但我找不到任何解决方案。因此,我必须创建
,使其宽度非常大,但当我将其变大时,它会将注释移到右侧,这就是为什么我必须将
边距设置为如此大的值。
我不知道任何其他可能的更具逻辑性的解决方案OK,你想让我为你编辑这个问题吗?或者,您满意吗?我知道有一种更好的方法可以实现同样的效果,而无需使用
左边距:-1172px?如果是的话,我很高兴知道怎么做。不知道为什么我被降价了?我的答案是两种解决问题的正确方法。