Reputation: 119
I'm new to html/css and to practice I'm trying to build a portfolio webpage. I have two containers as seen in the image, and I'd like to get rid of the space on the side when changing the background color. I tried messing around with padding and margin to no avail.
Any ideas on how to fix this problem?
html,
body {
font-family: ;
margin: 0 auto;
text-transform: lowercase;
}
.container {
max-width: 940px;
margin: 0 auto;
padding: 0 !important;
}
.nav {
float: right;
display: inline;
margin: 0 auto;
list-style: none;
}
.nav li {
list-style: none;
display: inline;
padding-top: 0;
padding-left: 10px;
}
.nav>li>a {
padding: 0px !important;
color: black;
}
a:hover {
background-color: yellow;
}
.header {
width: 100%;
display: inline-block;
padding: 10px 0 0 0;
margin: 0 auto;
}
.header h1 {
font-size: 20px;
margin: 0 auto;
display: inline-block;
}
.header .nav {
padding-left: 10px;
}
.supporting h1 {
border-left: 1px solid black;
padding: 10px;
margin: 0 auto;
display: inline-block;
position: absolute;
top: 25%;
}
.supporting .container {
background-color: white;
height: 500px;
width: 100%;
}
.work .container {
height: 500px;
margin: 0 auto;
background: rgba(225, 225, 225, .8)
}
<html>
<head>
<link href="style.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="js/main.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
<div class="container">
<div class="header">
<h1 class="logo">header</h1>
<ul class="nav nav-pills">
<li>
<a href="#">Projects</a>
</li>
<li>
<a href="#">Photography</a>
</li>
<li>
<a href="#">blog</a>
</li>
</ul>
</div>
<div class="supporting">
<div class="container">
<h1>hi.</h1>
</div>
</div>
<div class="work">
<div class="container">
<h1>work</h1>
</div>
</div>
Upvotes: 2
Views: 2157
Reputation: 4433
When using .container
bootstrap gives it a specific width
.
You have two choices there,
first you can use .container-fluid
instead of .container
and that will make full width container (you just need to remove some padding).
Secondly you can choose to wrap .container
inside a .container-fluid
<div class = "container-fluid">
<div class ="container">
content goes here
</div>
</div>
and then in your css
you give background color to .container-fluid
not to .container
div.container-fluid{
padding-left:0px;
padding-right:0px;
background-color:red;
}
Upvotes: 1
Reputation: 522
I think you should check bootstrap documentation about container-fluid this is the bootstrap way to manage full width containers.
Upvotes: 1