gpt4 book ai didi

html - 如何删除div之间的空间?

转载 作者:太空宇宙 更新时间:2023-11-03 20:41:54 27 4
gpt4 key购买 nike

我需要删除 .

之间的空格

我试过 margin 0 但没有成功。

知道怎么解决吗?

http://jsfiddle.net/554yz/


<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<title></title>
<style>
body {
margin: 0;
padding: 0;
background: transparent;
width: 1280px;
height: 720px;
}

#content {
position: fixed;
top: 0px;
left: 0px;
width: 1280px;
height: 720px;
outline: 1px solid red;
}

ul {
list-style-type: none;
margin: 0px;
padding: 0px;
}

#bar-header, #bar-footer {
position: fixed;
left: 0px;
width: 1280px;
height: 30px;
background-color: darkgray;
}
#bar-header {
top: 0px;
}

#bar-footer {
top: 690px;
}
.content-section {
background-color: lightgray;
outline: 1px solid black;
height: 300px;
}

</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
function start() {
};
</script>
</head>
<body onclick="start();">
<div id="page">
<div id="bar-header">Header</div>
<div id="content">
<div class="content-section">
<h2>Content 1</h2>
<a name="section-1"></a>
</div>
<div class="content-section">
<h2>Content 2</h2>
<a name="section-2"></a>
</div>
<div class="content-section">
<h2>Content 2</h2>
<a name="section-2"></a>
</div>
<div class="content-section">
<h2>Content 4</h2>
<a name="section-2"></a>
</div>
</div>
<div id="bar-footer">Footer</div>
</div>
</body>
</html>

编辑:

我也试过

.内容部分{ 背景色:浅灰色; 轮廓:1px 纯黑色; 高度:300px; 底部边距:-20px;

它有效,但我宁愿选择替代解决方案。

最佳答案

将样式添加到 content-section div 中的 h2 标签

.content-section h2 {
margin-top: 0px;
}

.content-section:first-of-type h2 {
margin-top: 27px;
}

JSfiddle

关于html - 如何删除div之间的空间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24932777/

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