gpt4 book ai didi

html - 我页面正文的宽度问题

转载 作者:太空宇宙 更新时间:2023-11-04 16:00:23 25 4
gpt4 key购买 nike

我的页面出现水平滚动,但我不明白为什么:/我尝试将边距和填充设为 0 进行修复,但没有任何效果。你知道问题可能是什么吗?我认为在添加视差效果之前我没有遇到这个问题(我只有叠加菜单 div 和按钮的 Bootstrap 行)但是删除所有视差代码并没有解决问题。

/*------------BODY------------*/

body {
position: relative;
padding: 0%;
margin: 0;
font-family: 'Lato', sans-serif;
background-color: black;
width: 100%;
}
body,
html {
height: 100%;
margin: 0;
padding: 0;
}
.parallax {
/* The image used */
background-image: url('img_parallax.jpg');
/* Full height */
height: 100%;
/* Create the parallax scrolling effect */
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
margin: 0;
padding: 0;
}
.parallax2 {
/* The image used */
background-image: url('img_parallax.jpg');
/* Full height */
height: 100%;
/* Create the parallax scrolling effect */
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
margin: 0;
padding: 0;
}
/* Turn off parallax scrolling for tablets and phones. Increase the pixels if needed */

@media only screen and (max-device-width: 1024px) {
.parallax {
background-attachment: scroll;
}
}
/*------------MENU------------*/

.overlay {
height: 0%;
width: 100%;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: rgb(0, 0, 0);
background-color: rgba(255, 255, 255, 0.9);
overflow-y: hidden;
transition: 0.5s;
}
.overlay-content {
position: relative;
top: 25%;
width: 100%;
text-align: center;
margin-top: 30px;
}
.overlay a {
padding: 8px;
text-decoration: none;
font-size: 36px;
color: #818181;
display: block;
transition: 0.3s;
}
.overlay a:hover,
.overlay a:focus {
color: #f1f1f1;
}
.overlay .closebtn {
position: absolute;
top: 20px;
right: 45px;
font-size: 60px;
}
@media screen and (max-height: 450px) {
.overlay {
overflow-y: auto;
}
.overlay a {
font-size: 20px
}
.overlay .closebtn {
font-size: 40px;
top: 15px;
right: 35px;
}
}
.menubutton {
cursor: pointer;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="parallax">

<div id="myNav" class="overlay">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">&times;</a>
<div class="overlay-content">
<a href="#">About</a>
<a href="#">Services</a>
<a href="#">Clients</a>
<a href="#">Contact</a>
</div>
</div>
<div id="menucontainer">
<div class="row">
<div class="col-sm-4"></div>
<div class="col-sm-4">
<center>
<div class="menubutton" onclick="openNav()">menubutton</div>
</center>
</div>
<div class="col-sm-4"></div>
</div>
</div>

</div>

<div class="parallax2">
PARALLAX2
</div>

<div class="parallax"></div>

最佳答案

Bootstrap .row 有负边距,将其包装到 .container.container-fluid 中。

<div class=container-fluid><div class="row"></div></div>

/*------------BODY------------*/

body {
position: relative;
padding: 0%;
margin: 0;
font-family: 'Lato', sans-serif;
background-color: black;
width: 100%;
}
body,
html {
height: 100%;
margin: 0;
padding: 0;
}
.parallax {
/* The image used */
background-image: url('img_parallax.jpg');
/* Full height */
height: 100%;
/* Create the parallax scrolling effect */
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
margin: 0;
padding: 0;
}
.parallax2 {
/* The image used */
background-image: url('img_parallax.jpg');
/* Full height */
height: 100%;
/* Create the parallax scrolling effect */
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
margin: 0;
padding: 0;
}
/* Turn off parallax scrolling for tablets and phones. Increase the pixels if needed */

@media only screen and (max-device-width: 1024px) {
.parallax {
background-attachment: scroll;
}
}
/*------------MENU------------*/

.overlay {
height: 0%;
width: 100%;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: rgb(0, 0, 0);
background-color: rgba(255, 255, 255, 0.9);
overflow-y: hidden;
transition: 0.5s;
}
.overlay-content {
position: relative;
top: 25%;
width: 100%;
text-align: center;
margin-top: 30px;
}
.overlay a {
padding: 8px;
text-decoration: none;
font-size: 36px;
color: #818181;
display: block;
transition: 0.3s;
}
.overlay a:hover,
.overlay a:focus {
color: #f1f1f1;
}
.overlay .closebtn {
position: absolute;
top: 20px;
right: 45px;
font-size: 60px;
}
@media screen and (max-height: 450px) {
.overlay {
overflow-y: auto;
}
.overlay a {
font-size: 20px
}
.overlay .closebtn {
font-size: 40px;
top: 15px;
right: 35px;
}
}
.menubutton {
cursor: pointer;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="parallax">

<div id="myNav" class="overlay">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">&times;</a>
<div class="overlay-content">
<a href="#">About</a>
<a href="#">Services</a>
<a href="#">Clients</a>
<a href="#">Contact</a>
</div>
</div>
<div id="menucontainer">
<div class=container-fluid>
<div class="row">
<div class="col-sm-4"></div>
<div class="col-sm-4">
<center>
<div class="menubutton" onclick="openNav()">menubutton</center>
</div>
<div class="col-sm-4"></div>
</div>
</div>
</div>

</div>

<div class="parallax2">
PARALLAX2
</div>

<div class="parallax"></div>

Rows must be placed within a .container (fixed-width) or .container-fluid (full-width) for proper alignment and padding. -(Bootstrap Introduction)

More Info

关于html - 我页面正文的宽度问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42129225/

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