Reputation: 97
I have a horizontal scrolling on my page and I don't understand why :/ I tried fixing it with margin and padding at 0 but nothing works. Do you have an idea what the problem might be. I think I didn't have this problem before adding the parallax effect (I had only the overlay menu div and the button's bootstrap row) but deleting all the parallax's code didn't solve the issue.
/*------------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()">×</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>
Upvotes: 2
Views: 95
Reputation: 13558
Bootstrap .row
has negative margins, wrap it into .container
or .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()">×</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)
Upvotes: 2
Reputation: 2188
Give "container" or "container-fluid" class to your div id="menucontainer". "row" class has negative margin.
Upvotes: 0