Html Div冲突css
我的HTML/CSS代码有问题。我正在为我爸爸开发一个网站,但有点不对劲,代码目前有两个div,但它们相互冲突 HTML: 拿Html Div冲突css,html,css,Html,Css,我的HTML/CSS代码有问题。我正在为我爸爸开发一个网站,但有点不对劲,代码目前有两个div,但它们相互冲突 HTML: 拿 position: absolute; 在你的菜单上 div#menu { background-color: #3e4040; position: absolute; <<<<<<<this you have to take away height: 50px;
position: absolute;
在你的菜单上
div#menu {
background-color: #3e4040;
position: absolute; <<<<<<<this you have to take away
height: 50px;
width: 100%;
div#菜单{
背景色:#3e4040;
position:absolute;属性position:absolute
从文档流中删除#menu
div,因此您需要为#main
提供一个与#menu
中的大小相等的边距,以避免重叠。或者,您也可以对该div使用position:absolute
,但这取决于你想要达到的目标
查看此属性不同选项的详细信息。您将“菜单位置”设置为“绝对”,这会将其从文档流计算中删除。@MarcB我应该将其设置为什么?根据Marc指出的,如果您只需要#菜单
就可以捕捉到它有arpos:abs
的任何子项,请将其设置为toposition:relative;
相反。如果不使用top
或其类似项,pos:rel
只会使它捕获子位置元素。由于缺少top
和co。在我们显示的代码片段中,我建议将其替换为relative
而不是将其禁用-这可能是预期的#menu位置:绝对的菜单的孩子,用位置:相对的;
,而不是删除所有的位置,你就不会输。这就是我刚才说的g、 啊,好的,对不起,是的,你说得对,我的英语不是最强的,但现在我明白了
position: absolute;
div#menu {
background-color: #3e4040;
position: absolute; <<<<<<<this you have to take away
height: 50px;
width: 100%;