gpt4 book ai didi

当文本放置在其中时,DIV 部分之间的 HTML 间隙

转载 作者:行者123 更新时间:2023-11-28 02:46:02 24 4
gpt4 key购买 nike

每当我插入文本或标题时,我的两个 div 部分之间都有间隙。这两个部分之间没有填充(这两个部分是 .navtop.welcome),并且出于某种原因,当我希望它们是如果有意义的话,互相接触。我已经尝试了目前我所知道的一切来修复它们,但似乎没有任何效果。我早些时候这样做过,一切正常,但我添加了一些东西,却忘记了是什么破坏了它。谁能帮帮我吗?

// JavaScript Document
$(function() {
//$("#para").hide();
});

$(".close").click(function() {
$(".notice").slideUp(500);
});
/* Sass Document */

html {
font-family: 'Ubuntu', sans-serif;
background-color: white;
color: #34495e;
}

.navigation {
position: sticky;
border-color: black;
background-color: white;
vertical-align: middle;
padding: 0 0px;
margin: 0px;
color: white;
width: auto;
font-size: 16px;
}

a:link {
color: hotpink;
text-decoration: none;
}

ul {
list-style: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
height: 44px;
}

li {
float: left;
color: hotpink;
}

li a {
display: block;
border-radius: 50%;
color: hotpink;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}


/* Notice Box */

.notice {
text-align: center;
background-color: hotpink;
line-height: normal;
padding-top: 16px;
font-size: 16px;
display: block;
}

.subtitle {
position: relative;
bottom: 30px;
font-size: 18px;
}

.news {
position: relative;
bottom: 45px;
text-align: center;
color: aliceblue;
}

.close {
position: relative;
top: 0px;
left: 250px;
font-size: 20px;
color: black;
background-color: transparent;
border: none;
}

.close:hover {
font-size: 18px;
color: grey;
}


/* Welcome Box */

.welcome {
background-color: #333;
justify-content: center;
padding-top: 20px;
color: hotpink;
text-align: center;
padding-bottom: 20px;
}

.welcome-title {
font-size: 36px;
}

.welcome-text {
font-size: 24px;
}


/* Footer */

.navbot {
padding-top: 10px;
}

footer {
text-align: center;
align-content: center;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!doctype html>
<html>

<head>
<meta charset="utf-8">
<link rel="stylesheet" href="index.css">
<title>Home Page</title>
</head>

<div class="navtop">
<nav class="navigation">
<ul>
<li><a href="">Home</a></li>
<li><a href="">Level Up</a></li>
<li><a href="">Trade</a></li>
</ul>
</nav>
</div>

<div class="notice">
<div class="button">
<button type="button" class="close">×</button>
</div>
<h3 class="subtitle">Important</h3>
<p class="news">test</p>
</div>

<div class="welcome">
<dive class="welcome-message">
text goes here
</dive>
</div>

<footer>
<div class="navbot">
<nav class="navigation">
<ul>
<li><a href="about.html">About Us</a></li>
<li><a href="">Terms of Service</a></li>
<li><a href="">Help</a></li>
</ul>
</nav>
</div>

<div class="footer">
Copyright 2017
<p><a class="ToS" href="">Terms of service</a></p>
</div>

</footer>

<script type="text/javascript" src="jquery-3.2.1.js"></script>
<script type="text/javascript" src="index.js"></script>

</html>

最佳答案

更改答案和新片段:

1.) 仍然和以前一样:您的 .navbot 规则有 padding-top: 10px; 将其设置为零。

2.) 将 margin: 0 添加到 .news:它有一个相对位置,虽然你将它向上移动到 bottom setting, relative 意味着它的原始空间是为它保留的,就像如果 bottom 设置不存在一样。这包括一个默认的 margin-bottom(由浏览器添加),它扩展了父元素 - 也称为“折叠边距”的现象(如果你搜索它,你会发现很多在 SO 或其他地方)

// JavaScript Document
$(function() {
//$("#para").hide();
});

$(".close").click(function() {
$(".notice").slideUp(500);
});
/* Sass Document */

html {
font-family: 'Ubuntu', sans-serif;
background-color: white;
color: #34495e;
}

.navigation {
position: sticky;
border-color: black;
background-color: white;
vertical-align: middle;
padding: 0 0px;
margin: 0px;
color: white;
width: auto;
font-size: 16px;
}

a:link {
color: hotpink;
text-decoration: none;
}

ul {
list-style: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
height: 44px;
}

li {
float: left;
color: hotpink;
}

li a {
display: block;
border-radius: 50%;
color: hotpink;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}


/* Notice Box */

.notice {
text-align: center;
background-color: hotpink;
line-height: normal;
padding-top: 16px;
font-size: 16px;
display: block;
}

.subtitle {
position: relative;
bottom: 30px;
font-size: 18px;
}

.news {
position: relative;
bottom: 45px;
text-align: center;
color: aliceblue;
margin: 0;
}

.close {
position: relative;
top: 0px;
left: 250px;
font-size: 20px;
color: black;
background-color: transparent;
border: none;
}

.close:hover {
font-size: 18px;
color: grey;
}


/* Welcome Box */

.welcome {
background-color: #333;
justify-content: center;
padding-top: 20px;
color: hotpink;
text-align: center;
padding-bottom: 20px;
}

.welcome-title {
font-size: 36px;
}

.welcome-text {
font-size: 24px;
}


/* Footer */

.navbot {
padding-top: 0px;
}

footer {
text-align: center;
align-content: center;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!doctype html>
<html>

<head>
<meta charset="utf-8">
<link rel="stylesheet" href="index.css">
<title>Home Page</title>
</head>

<div class="navtop">
<nav class="navigation">
<ul>
<li><a href="">Home</a></li>
<li><a href="">Level Up</a></li>
<li><a href="">Trade</a></li>
</ul>
</nav>
</div>

<div class="notice">
<div class="button">
<button type="button" class="close">×</button>
</div>
<h3 class="subtitle">Important</h3>
<p class="news">test</p>
</div>

<div class="welcome">
<dive class="welcome-message">
text goes here
</dive>
</div>

<footer>
<div class="navbot">
<nav class="navigation">
<ul>
<li><a href="about.html">About Us</a></li>
<li><a href="">Terms of Service</a></li>
<li><a href="">Help</a></li>
</ul>
</nav>
</div>

<div class="footer">
Copyright 2017
<p><a class="ToS" href="">Terms of service</a></p>
</div>

</footer>

<script type="text/javascript" src="jquery-3.2.1.js"></script>
<script type="text/javascript" src="index.js"></script>

</html>

关于当文本放置在其中时,DIV 部分之间的 HTML 间隙,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46921692/

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