Antegeia
Antegeia

Reputation: 269

Align div to left

I am trying to set a div to left 0 but i can't. This is my code

.bottom
{
width: 100%;
position: relative;
height: 100px;
background: #21241c;
float: left;
margin: 0;
}

I do not want to position my div absolute!

This is the html

 <div class='top'></div>
 <div class='middle'></div>
 <div class='bottom'></div>

I want the bottom div to be always under middle div with 100% width. I tried float left and margin 0 but no. My bottom div seams to be at the center of the screen leaving white space right and left of it. Can you help?

Thanks!

Upvotes: 2

Views: 90

Answers (5)

user3091530
user3091530

Reputation: 630

You just use this below code:

.bottom
 {
  width: 100%;
  height: 100px;
  background: #21241c;
  float: left;
  margin: 0;
  }

Upvotes: 1

Antegeia
Antegeia

Reputation: 269

Thanks for your time, i find a solution. Just add the bellow code in my css.

html, body
{
  margin: 0;
  padding: 0;
}

Upvotes: 0

Eoin2211
Eoin2211

Reputation: 911

You need to correct your Html. As we don't have the code I would presume your div is just in the body? Try: html, body { width:100%; height:100%; margin: 0; }

Upvotes: 0

Sander van Leeuwen
Sander van Leeuwen

Reputation: 51

It's not your .bottom div which is the problem, but one of the parent elements, presumably the body element. Remove any padding and / or margin from the body:

body {
    margin: 0;
    padding: 0;
}

Upvotes: 0

G.L.P
G.L.P

Reputation: 7207

Try to use like this

float:left; 
margin:0;

no need to set position as absolute. If you are using margin:0 auto; it will fix your div in center, so use margin as zero.

Upvotes: 0

Related Questions