gpt4 book ai didi

html - 强制div垂直相互接触

转载 作者:太空狗 更新时间:2023-10-29 16:35:43 26 4
gpt4 key购买 nike

我想要一个类似 this 的页面.

在尝试了一些 CSSHTML 代码之后:CSS 代码:

html,body{
margin:0px;
background-color:#CCC;
}
#header{
background-color:#FFF;
height:350px;
width:750px;
display:block;
}
#menu{
background-color:#096;
height:60px;
width:100%;
display:block;
}
#content{
background-color:#03F;
width:750px;
height:400px;
}
#footer{
background-color:#900;
height:120px;
width:750px;
display:block;
bottom:0px;
position:relative;
}

HTML 代码:

<center>
<div id="header">

</div>
<div id="menu">

</div>
<div id="content">

</div>
<div id="footer">

</div>
</center>

它是同一件事,但在将一些文本放入“内容”部分后,div 分开了。像这样This .

我的 CSS 代码有什么问题?

最佳答案

这是因为p标签有一些默认的margin

像这样添加CSS

p{
margin:0px;
}

Fiddle

关于html - 强制div垂直相互接触,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31044020/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com