gpt4 book ai didi

html - Div 在 CSS 中重叠

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

我知道这个问题已经得到解答,但我不明白为什么我的 div 会重叠。今天早些时候,标题与导航栏重叠,现在容器与标题和导航栏重叠。

这就是它的样子 -> http://i.imgur.com/pqeyZUx.png

CSS 和 HTML

@font-face {
font-family: 'HaloOutline';
src: url('/core/HaloOutline.ttf') format('truetype');
}

sup {
font-size:14px; font-family:HaloOutline!important;
}

/* Dropdown Button */
.dropbtn {
cursor: pointer;
}
#showUser {
display:none; position:relative; z-index:100; background:#1b272c; opacity: 0.5;
}

body
{
min-height:100%;
background-color: #131416 ;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;

}

.dialog { display:none; }

.wrapper {
display: flex;
flex-direction: column;
}
#container {
width: 80%;
display: flex;
margin: 0px auto;
background: #1c1e21;
opacity: 0.9;
}
/* NAVIGATION section ====================== */

.navbar {
display: flex;
/* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#1c1e21+0,2f3237+50,26282c+51,383c42+100 */
background: #1c1e21;
/* Old browsers */
background: -moz-linear-gradient(top, #1c1e21 0%, #2f3237 50%, #26282c 51%, #383c42 100%);
/* FF3.6-15 */
background: -webkit-linear-gradient(top, #1c1e21 0%, #2f3237 50%, #26282c 51%, #383c42 100%);
/* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, #1c1e21 0%, #2f3237 50%, #26282c 51%, #383c42 100%);
/* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#1c1e21', endColorstr='#383c42', GradientType=0);
/* IE6-9 */
height: 15px;
width: 80%;
max-width: 80%;
font-weight: bold;
letter-spacing: 0.1em;
margin: auto;
}
.navbar ul {
list-style-type: none;
text-align: center;
margin: auto;
padding: 6px;
min-width: 100%;
}
.navbar > ul > li {
min-width: 25%;
text-align: center;
}
.navbar > ul > li > ul {
display: none;
}
.navbar > ul > li:hover > ul {
display: block;
}
.navbar ul li a {
text-decoration: none;
font-family: Arial;
padding: .2em 1em;
color: #bcc1c7;
}
.navbar ul li a:hover {
border: solid 1px #5d646f;
color: #858c99;
background-color: #2e3238;
border-top-right-radius: .2em;
border-bottom-left-radius: .2em;
}
/* HEADER section ========================== */

header {
height: 200px;
width: 100%;
color: white;
background-image: url("http://vignette2.wikia.nocookie.net/halo/images/c/c1/Forge_world.png/revision/latest/scale-to-width-down/2000?cb=20100723045607");
background-position: center center;
position: relative;
transition: background-image 1s ease-in-out;
}
header {
height: 200px;
width: 80%;
margin: 0 auto;
margin-top:2.5%;
color: white;
background-image: url("http://vignette2.wikia.nocookie.net/halo/images/c/c1/Forge_world.png/revision/latest/scale-to-width-down/2000?cb=20100723045607");
background-position: center center;
position: relative;
transition: background-image 1s ease-in-out;
}
header img {
margin-left: auto;
margin-right: auto;
left: 0;
right: 0;
position: absolute;
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;
}
header:hover {
background-image: url("http://images.gamersyde.com/image_halo_reach-13325-1852_0004.jpg");
}
header img.top:hover {
opacity: 0;
}
aside {
margin-bottom: 20px;
display: flex;
width: 20%;
line-height: 100%;
background: #2e3338!important;
}
aside hr {
width: 90%;
}
aside img {
width: 90%;
}
aside ul {
width: 90%;
text-align: justify;
margin-top: auto;
margin-bottom: auto;
margin-left: -10%;
margin-right: auto;
opacity: 1.0;
padding: 10px;
list-style-type: none;
}
aside ul li {
min-width: 100%;
margin-left: 25%;
margin-right: 25%;
}
aside ul li a {
text-decoration: none;
font-family: Arial;
color: #bcc1c7;
}
aside ul li a:hover {
color: #25282c;
padding: 4px;
background-color: #c7cbd1;
}
aside h3 {
background: #202020;
text-align: center;
color: white;
}


/* MAIN ========================================= */

main
{
float: left;
display:block;
width: 77%;
color: white;
font-family: Arial;
font-size: 16px;
padding:10px;
border-bottom-right-radius:1em;

}

main a {
text-decoration: none;
color:grey;
}

main a:hover {
text-decoration:none;
color: #60808F;
}

hr {
border-color: #25282c;
width: 760px;
}

p {
margin: 20px;
color: #bcc1c7;
}

j {
margin: 1px;
color: #bcc1c7;
}

article {
background: url("img/Panellong.png");
background-size: contain;
background-repeat: no-repeat;
background-position: center;
padding: 20px;
}

h2 {
text-align: center;
color: #bcc1c7;
letter-spacing: 0.1em;
}

h1 {
text-align: center;
color: #bcc1c7;
letter-spacing: 0.1em;
}

img {
max-width: 100%;
max-height: 100%;
display: block;
margin-left: auto;
margin-right: auto;
}

/* FOOTER ========================================= */

#footer {
clear:both;
color: #bcc1c7;
text-align: center;
border-top:1px dashed grey !important;
margin-top: 40px;
border-bottom-left-radius:1em;
border-bottom-right-radius:1em;
padding: 15px;
font-size: 90%;
font-family: Arial;
background-color: #2e3338;
max-width: 100%;
position:relative;
bottom:0;
left:0;
right:0;
}

#footer a {
text-decoration: none;
color:grey;
}

#footer a:hover {
text-decoration:none;
color: #60808F;
}

fieldset {
padding: 20px;
margin: 20px 0;
border: 1px solid #5d646f;
}

legend {
padding: 10px;
font-size: 18px;
letter-spacing: 0.1em;
color: #bcc1c7;
}

input[type="password"],
input[type="username"],
input[type="name"],
input[type="email"],
input[type="age"],
input[type="text"]{
display: block;
margin-bottom: 20px;
padding: 10px 10px 10px 25px;
border: 0;
border-radius: 3px;
background-color: #25282c;
color: #fff;
width: 300px
}

textarea {
display: block;
padding: 10px 10px 10px 25px;
border: 0;
border-radius: 3px;
background-color: #25282c;
color: #fff;
width: 70%;
height:200px;
}

label {
padding: 5px;
font-size: 14px;
letter-spacing: 0.1em;
color: #bcc1c7;
}

input[type="submit"],
input[type="button"],
button {
border: solid 1px #5d646f;
background: #25282c;
width:150px;
height: 30px;
border-top-right-radius: 1em;
border-bottom-left-radius: 1em;
letter-spacing: 0.1em;
color: #bcc1c7;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Halo Editing Community</title>
<link type="text/css" rel="stylesheet" href="/core/style.css" />
<link rel="stylesheet" href="//halovau.lt/js/vader-jquery-ui.css" />
<script src="//halovau.lt/js/jquery-3.1.0.js"></script>
<script src="//halovau.lt/js/jquery-3.1.0.min.js"></script>
<script src="//halovau.lt/js/jquery-ui.js"></script>
<script src="//cdn.jsdelivr.net/fingerprintjs2/1.4.1/fingerprint2.min.js"></script>
<script>
<!--
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}
//-->

</script>


</head>

<body>




<div class='dialog' id='dialog0' title='Allied Websites'>
<center><a href='//halovau.lt'><b>HaloVault</b></b><img src='https://cdn.discordapp.com/attachments/227232976763748355/237104871386513409/halovauliconSAFE3.png' width='50%' alt='HALO VAULT' title='HaloVault' /></a>
<a href="http://www.xboxchaos.com"><b>Xbox Chaos</b><img alt="" border="0" src="http://i.imgur.com/gelB8qc.png" /> </a>
<br />
<a href="http://www.macgamingmods.com"><b>Mac Gaming Mods</b><img alt="" border="0" src="http://i.imgur.com/CzwS1LZ.png" /> </a>
<br />
<a href="http://www.halo3archives.com"><b>Halo 3 Archives</b><img alt="" border="0" src="https://halo3archives.com/images/banner.jpg" />
<br /></center>
</div>
<?php if (!isset($_USER['id'])) {$staff = "<li><a href=\"/application.php\">Recruitment</a></li>";}
elseif (isset($_USER['id']) OR isset($_SESSION['uname'])) {
$panel=''; if ($_USER['group'] > 1){ $panel = "<a href='/leg3ndary'>♛ Staff Panel</a><br />"; }
$staff = "<li><a href='javascript:void();' class='uClick' onclick=\"toggle_visibility('showUser')\" class='dropbtn'>".$_USER['name']." ▼</a>\n"
."<div id='showUser''><center><img title='Click to view your profile.' style='cursor:pointer;' onclick=\"location.href='/members.php?id=".$_USER['id']."';\" width='110' src=\"".$_USER['img']."\" /><br />\n
<a href='/articles.php?new=link'>☲ Submit Download</a><br />\n
<a href='/articles.php?new=tutorial'>☲ Submit Tutorial</a><br />\n
".$panel."\n
<a href='/logout.php'>&#128274; Logout</a></center></li></div>";
} ?>
<div class="wrapper">

<div class="navbar">

<ul class="navbar">
<li><a href="/index.php">Home</a>
</li>
<li><a href="/members.php">Members</a>
</li>
<li><a href="/archive.php">Archive ▼</a>
<ul>
<li><a href="#">Community Portal</a>
</li>
<li><a href="#">Blog Posts</a>
</li>
<li><a href="#">Mod/Map Downloads</a>
</li>
</ul>
</li>
<?=$staff;?>
</ul>
</div>
<header>
<img class="bottom" src='/core/img/logolight.png' />
<img class="top" src='/core/img/logo.png' />
</header>



<div id="container">

<aside>
<ul>
<br />
<?php if(!isset($_USER[ 'id'])) { ?>
<li><a href="login.php">Login Page</a>
</li>
<?php } ?>
<br />
<li><a class='dialog_link' data-dialog='dialog0' href="javascript:void();">Allied Websites</a>
</li>
<br />
<li><a href="changelog.php">Change Log</a>
</li>
<br />
<li><a href="/articles.php?cat=tutorials">Getting Started</a>
</li>
<br />
</ul>
<br />

</aside>

</div>

<?php require_once "core/structure.php"; include_once "core/top.php"; ?>


<main>
<article>
<h2>Halo Editing Community<sup>alpha</sup></h2>
</article>
<br /><br /><p>Welcome to the Halo Editing Community, a place where we preserve and archive the beauty of Halo as it lasted under it's original founders Bungie. Here you can find all sorts of Halo mods, tips and tutorials. </p>
<br />
<br />
<hr />
<img src="https://s16.postimg.org/ywmshllmd/framed.png">
<h2>
Holiday Cards
</h2>
<p>
"Wake up! The enemy!" - To other Grunts.
</p>
</main>

<?php include_once "core/bottom.php"; ?>

最佳答案

您可以使用 display:flex 代替 float 布局。检查这个片段

@font-face {
font-family: 'HaloOutline';
src: url('/core/HaloOutline.ttf') format('truetype');
}
sup {
font-size: 14px;
font-family: HaloOutline!important;
}
/* Dropdown Button */

.dropbtn {
cursor: pointer;
}
#showUser {
display: none;
position: relative;
z-index: 100;
background: #1b272c;
opacity: 0.5;
}
body {
min-height: 100%;
background-color: #131416;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
}
.dialog {
display: none;
}
.wrapper {
display: flex;
flex-direction: column;
}
#container {
width: 80%;
display: flex;
margin: 0px auto;
background: #1c1e21;
opacity: 0.9;
}

.navbar-container {
position:relative;
/* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#1c1e21+0,2f3237+50,26282c+51,383c42+100 */
background: #1c1e21;
/* Old browsers */
background: -moz-linear-gradient(top, #1c1e21 0%, #2f3237 50%, #26282c 51%, #383c42 100%);
/* FF3.6-15 */
background: -webkit-linear-gradient(top, #1c1e21 0%, #2f3237 50%, #26282c 51%, #383c42 100%);
/* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, #1c1e21 0%, #2f3237 50%, #26282c 51%, #383c42 100%);
/* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#1c1e21', endColorstr='#383c42', GradientType=0);
/* IE6-9 */
height: 25px;
width: 80%;
max-width: 80%;
letter-spacing: 0.1em;
margin: auto;
padding:5px;
}
ul.navbar {
display: flex;
list-style-type: none;
text-align: center;
margin: auto;

min-width: 100%;
}
ul li{
letter-spacing: 0.1em;
font-weight:bold;
text-decoration:none;
}

ul.navbar > li {
min-width: 25%;
text-align: center;
}
ul.navbar > li > ul {
list-style-type:none;
display: none;
position:absolute;
right:10;
z-index:1;
}
ul.navbar > li:hover > ul {
display: block;
padding:10px;
}
.navbar li a {
text-decoration: none;
font-family: Arial;
padding: .2em 1em;
color: #bcc1c7;
}
.navbar ul li a:hover {
border: solid 1px #5d646f;
color: #858c99;
background-color: #2e3238;
border-top-right-radius: .2em;
border-bottom-left-radius: .2em;
}
/* HEADER section ========================== */

header {
height: 200px;
width: 100%;
color: white;
background-image: url("http://vignette2.wikia.nocookie.net/halo/images/c/c1/Forge_world.png/revision/latest/scale-to-width-down/2000?cb=20100723045607");
background-position: center center;
position: relative;
transition: background-image 1s ease-in-out;
}
header {
height: 200px;
width: 80%;
margin: 0 auto;
color: white;
background-image: url("http://vignette2.wikia.nocookie.net/halo/images/c/c1/Forge_world.png/revision/latest/scale-to-width-down/2000?cb=20100723045607");
background-position: center center;
position: relative;
transition: background-image 1s ease-in-out;
}
header img {
margin-left: auto;
margin-right: auto;
left: 0;
right: 0;
position: absolute;
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;
}
header:hover {
background-image: url("http://images.gamersyde.com/image_halo_reach-13325-1852_0004.jpg");
}
header img.top:hover {
opacity: 0;
}
aside {
margin-bottom: 20px;
display: flex;
width: 20%;
line-height: 100%;
background: #2e3338!important;
}
aside hr {
width: 90%;
}
aside img {
width: 90%;
}
aside ul {
width: 90%;
text-align: justify;
margin-top: auto;
margin-bottom: auto;
margin-left: -10%;
margin-right: auto;
opacity: 1.0;
padding: 10px;
list-style-type: none;
}
aside ul li {
min-width: 100%;
margin-left: 25%;
margin-right: 25%;
}
aside ul li a {
text-decoration: none;
font-family: Arial;
color: #bcc1c7;
}
aside ul li a:hover {
color: #25282c;
padding: 4px;
background-color: #c7cbd1;
}
aside h3 {
background: #202020;
text-align: center;
color: white;
}
/* MAIN ========================================= */

main {
float: left;
display: block;
width: 77%;
color: white;
font-family: Arial;
font-size: 16px;
padding: 10px;
border-bottom-right-radius: 1em;
}
main a {
text-decoration: none;
color: grey;
}
main a:hover {
text-decoration: none;
color: #60808F;
}
hr {
border-color: #25282c;
width: 760px;
}
p {
margin: 20px;
color: #bcc1c7;
}
j {
margin: 1px;
color: #bcc1c7;
}
article {
background: url("img/Panellong.png");
background-size: contain;
background-repeat: no-repeat;
background-position: center;
padding: 20px;
}
h2 {
text-align: center;
color: #bcc1c7;
letter-spacing: 0.1em;
}
h1 {
text-align: center;
color: #bcc1c7;
letter-spacing: 0.1em;
}
img {
max-width: 100%;
max-height: 100%;
display: block;
margin-left: auto;
margin-right: auto;
}
/* FOOTER ========================================= */

#footer {
clear: both;
color: #bcc1c7;
text-align: center;
border-top: 1px dashed grey !important;
margin-top: 40px;
border-bottom-left-radius: 1em;
border-bottom-right-radius: 1em;
padding: 15px;
font-size: 90%;
font-family: Arial;
background-color: #2e3338;
max-width: 100%;
position: relative;
bottom: 0;
left: 0;
right: 0;
}
#footer a {
text-decoration: none;
color: grey;
}
#footer a:hover {
text-decoration: none;
color: #60808F;
}
fieldset {
padding: 20px;
margin: 20px 0;
border: 1px solid #5d646f;
}
legend {
padding: 10px;
font-size: 18px;
letter-spacing: 0.1em;
color: #bcc1c7;
}
input[type="password"],
input[type="username"],
input[type="name"],
input[type="email"],
input[type="age"],
input[type="text"] {
display: block;
margin-bottom: 20px;
padding: 10px 10px 10px 25px;
border: 0;
border-radius: 3px;
background-color: #25282c;
color: #fff;
width: 300px
}
textarea {
display: block;
padding: 10px 10px 10px 25px;
border: 0;
border-radius: 3px;
background-color: #25282c;
color: #fff;
width: 70%;
height: 200px;
}
label {
padding: 5px;
font-size: 14px;
letter-spacing: 0.1em;
color: #bcc1c7;
}
input[type="submit"],
input[type="button"],
button {
border: solid 1px #5d646f;
background: #25282c;
width: 150px;
height: 30px;
border-top-right-radius: 1em;
border-bottom-left-radius: 1em;
letter-spacing: 0.1em;
color: #bcc1c7;
}
<div class="wrapper">

<div class="navbar-container">

<ul class="navbar">
<li><a href="/index.php">Home</a></li>
<li><a href="/members.php">Members</a></li>
<li><a href="/archive.php">Archive ▼</a>
<ul>
<li><a href="#">Community Portal</a></li>
<li><a href="#">Blog Posts</a></li>
<li><a href="#">Mod/Map Downloads</a></li>
</ul>
</li>
<?=$staff;?>
</ul>
</div>
<header>
<img class="bottom" src='/core/img/logolight.png' />
<img class="top" src='/core/img/logo.png' />
</header>



<div id="container">

<aside>
<ul>
<br />
<?php if(!isset($_USER['id'])) { ?><li><a href="login.php">Login Page</a></li> <?php } ?>
<br />
<li><a class='dialog_link' data-dialog='dialog0' href="javascript:void();">Allied Websites</a></li>
<br />
<li><a href="changelog.php">Change Log</a></li>
<br />
<li><a href="/articles.php?cat=tutorials">Getting Started</a></li>
<br />
</ul>
<br />

</aside>

</div>



</div>

希望对你有帮助

关于html - Div 在 CSS 中重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40813479/

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