我该如何让人力资源部坐在divs上面?还是去掉空白



请帮帮我。我只想让我的两个div连接起来,让hr坐在他们相遇的地方。我做了很多研究,就是找不到我想要的答案。

body {
font-family: "Lato", sans-serif;
margin: 0%;
padding: 0%;
}
hr{
margin: 0 auto;
padding: 0 auto;
width: 25%;
align-self: center;
border-style: dotted;
border-bottom: none;
border-left: none;
border-right: none;
border-color: lightgrey;
border-width: 6px;
}
.top-nav{
background-color: #111;
height: 75px;
}
#top-container{
height: 500px;
width: 100%;
background-image: linear-gradient(to bottom right, rgb(204, 231, 229), rgb(33, 55, 95));
display:inline-block;
}
#middle-container{
height: 500px;
width: 100%;
background-image: linear-gradient(to bottom right, rgb(204, 231, 229), rgb(33, 55, 95));
display: inline-block;
}

.sidebar {
height: 100%;
width: 0;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: #111;
overflow-x: hidden;
transition: 0.5s;
padding-top: 60px;
}

.sidebar a {
padding: 8px 8px 8px 32px;
text-decoration: none;
font-size: 25px;
color: #818181;
display: block;
transition: 0.3s;
}

.sidebar a:hover {
color: #f1f1f1;
}

.sidebar .closebtn {
position: absolute;
top: 0;
right: 25px;
font-size: 36px;
margin-left: 50px;
}

.openbtn {
font-size: 20px;
cursor: pointer;
background-color: #111;
color: white;
padding: 10px 15px;
border: none;
}

.openbtn:hover {
background-color: #444;
}

#main {
transition: margin-left .5s;
padding: 16px;
}

/* On smaller screens, where height is less than 450px, change the style of the sidenav (less padding and a smaller font size) */
@media screen and (max-height: 450px) {
.sidebar {padding-top: 15px;}
.sidebar a {font-size: 18px;}
}
<!DOCTYPE html>
<head>
<title>Darrell Walker II</title>
<link rel="stylesheet" text="text/css" href="HomeCss.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
</head>
<body>

<div id="mySidebar" class="sidebar">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>
<a href="#"><i class="material-icons">&#xe88a</i> Home</a>
<a href="#"><i class="material-icons">&#xe87c</i> About</a>
<a href="#"><i class="material-icons">&#xe8a3</i> Contact</a>
<a href="#"><i class="material-icons">&#xf041</i> Donate</a>
</div>
<nav class='top-nav'>
<div id="main">
<button class="openbtn" onclick="openNav()">☰ Menu</button>  
</div>
</nav>

<div id='top-container'>
<h1>Hello</h1>
</div>
<hr>
<div id='middle-container'>
<p>world</p>
</div>


<script>
function openNav() {
document.getElementById("mySidebar").style.width = "250px";
document.getElementById("main").style.marginLeft = "250px";
}

function closeNav() {
document.getElementById("mySidebar").style.width = "0";
document.getElementById("main").style.marginLeft= "0";
}
</script>
</body>
</html>

将此css添加到您的hr

hr{   
margin-top: -10px;    
position: relative;   
z-index:9;
}

最新更新