引导:如何修复两个重叠的内容



我正在尝试使用这个代码笔创建一个网站(在此处输入链接描述(。我遇到的问题是,当我缩小窗口大小时,配置文件部分和主要内容部分开始重叠。我认为代码笔在这里使用的是引导网格系统,所以我真的不明白为什么会发生这种情况。

内容重叠图像

这是代码。

HTML

<!--navbar-->
<nav class="navbar navbar-expand-lg navbar-dark fixed-top" id="mainNav">
<div class="container">
<a class="navbar-brand js-scroll-trigger" href="#page-top">Bootstrap</a>
<div>
<ul class="navbar-nav text-uppercase ml-auto">
<li class="nav-item">
<a class="btn btn-primary my-2 my-sm-0" type="submit"><i class="fa fa-sign-out"></i> Log out</a>
</li>
</ul>
</div>
</div>
</nav>
<!--our content goes here-->
<div class="container content">
<div class="row profile">
<div class="col-md-3">
<div class="profile-sidebar position-fixed">
<!-- SIDEBAR USERPIC -->
<div class="profile-userpic">
<img src="https://media.rockstargames.com/chinatownwars/global/downloads/avatars/zhou_256x256.jpg" class="img-responsive" alt="">
</div>
<!-- END SIDEBAR USERPIC -->
<!-- SIDEBAR USER TITLE -->
<div class="profile-usertitle">
<div class="profile-usertitle-name">
Jason Davis
</div>
<div class="profile-usertitle-job">
Developer
</div>
</div>
<!-- END SIDEBAR USER TITLE -->
<!-- SIDEBAR BUTTONS -->
<div class="profile-userbuttons">
<button type="button" class="btn btn-success btn-sm">Follow</button>
<button type="button" class="btn btn-danger btn-sm">Message</button>
</div>
<!-- END SIDEBAR BUTTONS -->
<!-- SIDEBAR MENU -->
<div class="profile-usermenu sidebar-sticky">
<ul class="nav flex-column">
<li class="active nav-item">
<a href="#" class="nav-link active">
<i class="fa fa-home"></i>
Overview </a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://codepen.io/jasondavis/pen/jVRwaG?editors=1000">
<i class="fa fa-user"></i>
Account Settings </a>
</li>
<li class="nav-item">
<a class="nav-link" href="#" target="_blank">
<i class="fa fa-check"></i>
Tasks </a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<i class="fa fa-flag"></i>
Help </a>
</li>
</ul>
</div>
<!-- END MENU -->
</div>
</div>
<div class="col-md-9">
<div class="profile-content">
Some user related content goes here...
<h1>test</h1>
<h1>test</h1>
<h1>test</h1>
<h1>test</h1>
<h1>test</h1>
<h1>test</h1>
<h1>test</h1>
<h1>test</h1>
<h1>test</h1>
<h1>test</h1>
<h1>test</h1>
<h1>test</h1>
<h1>test</h1>
<h1>test</h1>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-3">
</div>
<div class="col-md-9 ft">
<footer class="footer">
<div class="row">
<div class="col-md-4">
<span class="copyright">Copyright &copy; Your Website 2018</span>
</div>
<div class="col-md-4">
<ul class="list-inline social-buttons">
<li class="list-inline-item">
<a href="https://github.com/ELMORABITYounes">
<i class="fa fa-github"></i>
</a>
</li>
<li class="list-inline-item">
<a href="https://www.facebook.com/younes.elmorabit.92">
<i class="fa fa-facebook"></i>
</a>
</li>
<li class="list-inline-item">
<a href="https://www.linkedin.com/in/younes-elmorabit-2a162310b/">
<i class="fa fa-linkedin"></i>
</a>
</li>
</ul>
</div>
<div class="col-md-4">
<ul class="list-inline quicklinks">
<li class="list-inline-item">
<a href="#">Privacy Policy</a>
</li>
<li class="list-inline-item">
<a href="#">Terms of Use</a>
</li>
</ul>
</div>
</div>
</footer>
</div>
</div>
</div>

CSS

html, body {
height: 100%;
}
body {
display: flex;
flex-direction: column;
background: #F1F3FA;
}
body { 
overflow-x:hidden;
}
#mainNav {
background-color: darkslategrey;
color:white;
}
#mainNav .navbar-brand {
color: #fed136;
font-family: 'Kaushan Script', 'Helvetica Neue', Helvetica, Arial, cursive;
}

.content {
flex: 1 0 auto;
}
.footer {
flex-shrink: 0;
}

footer {
text-align: center;
background-color: white;
}
.ft{
padding-left:22px;
padding-right:31px;
}
footer span.copyright {
font-size: 90%;
line-height: 40px;
text-transform: none;
font-family: 'Montserrat', 'Helvetica Neue', Helvetica, Arial, sans-serif;
color:blak;
}
footer ul.quicklinks {
font-size: 90%;
line-height: 40px;
margin-bottom: 0;
text-transform: none;
font-family: 'Montserrat', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
ul.social-buttons {
margin-bottom: 0;
}
ul.social-buttons li a {
font-size: 20px;
line-height: 40px;
display: block;
width: 40px;
height: 40px;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
transition: all 0.3s;
color: white;
border-radius: 100%;
outline: none;
background-color: #212529;
}
ul.social-buttons li a:active, ul.social-buttons li a:focus, ul.social-buttons li a:hover {
background-color: #fed136;
}
.content{
margin-top:60px;
}

/* Profile container */
.profile {
margin: 20px 0;
}
/* Profile sidebar */
.profile-sidebar {
padding: 20px 0 10px 0;
background: #fff;
}
.profile-userpic img {
float: none;
display:block;
margin:auto;
width: 50%;
height: 50%;
-webkit-border-radius: 50% !important;
-moz-border-radius: 50% !important;
border-radius: 50% !important;
}
.profile-usertitle {
text-align: center;
margin-top: 20px;
}
.profile-usertitle-name {
color: #5a7391;
font-size: 16px;
font-weight: 600;
margin-bottom: 7px;
}
.profile-usertitle-job {
text-transform: uppercase;
color: #5b9bd1;
font-size: 12px;
font-weight: 600;
margin-bottom: 15px;
}
.profile-userbuttons {
text-align: center;
margin-top: 10px;
}
.profile-userbuttons .btn {
text-transform: uppercase;
font-size: 11px;
font-weight: 600;
padding: 6px 15px;
margin-right: 5px;
}
.profile-userbuttons .btn:last-child {
margin-right: 0px;
}

.profile-usermenu {
margin-top: 30px;
}
.profile-usermenu ul li {
border-bottom: 1px solid #f0f4f7;
}
.profile-usermenu ul li:last-child {
border-bottom: none;
}
.profile-usermenu ul li a {
color: #93a3b5;
font-size: 14px;
font-weight: 400;
}
.profile-usermenu ul li a i {
margin-right: 8px;
font-size: 14px;
}
.profile-usermenu ul li a:hover {
background-color: #fafcfd;
color: #5b9bd1;
}
.profile-usermenu ul li.active {
border-bottom: none;
}
.profile-usermenu ul li.active a {
color: #5b9bd1;
background-color: #f6f9fb;
border-left: 2px solid #5b9bd1;
margin-left: -2px;
}
/* Profile Content */
.profile-content {
padding: 20px;
background: #fff;
min-height: 460px;
}
.nav>li {
position: relative;
display: block;
}

任何帮助都将不胜感激,因为我已经尝试了多种方法,但都没有成功。

提前谢谢。

我看到您已经将类position-fixed添加到具有类profile-sidebar的元素中,因此无论发生什么,该元素都将保持固定。

您可以删除类position-fixed并处理CSS中的所有内容,使用媒体查询来设置其在更小和更大屏幕中的位置。

<div class="profile-sidebar position-fixed">

position-fixed不允许您的profile-sidebar离开。

否则会起作用https://jsfiddle.net/f9hot4yk/

您可以将profile-sidebar添加到CSS中的最小宽度位置,而不是添加position fixed类,在该位置您可以将固定属性添加到侧边栏。

像这样:

@media only screen and (min-width: 1200px) {
.profile-sidebar {
position: fixed;
}
}

最新更新