Get a div to go across the whole page

后端 未结 6 2076
刺人心
刺人心 2021-01-06 03:30

Whenever i try to make a div with width 100%, it does not go across the whole page, it leaves small margins on either side(top bottom left and right), i would like the div

相关标签:
6条回答
  • 2021-01-06 03:58

    Set the padding to 0 for the body tag:

    body {
        padding: 0;
    }
    
    0 讨论(0)
  • 2021-01-06 04:04

    There is no need for padding as the padding is on the inside of the div and is measured as a distance from edge. Just set margin to 0px if you want a specific margin set then do it like @sho suggested and set them individually.

    0 讨论(0)
  • 2021-01-06 04:05

    You have to set margin and padding of body element to 0. Like this (in CSS):

    body
    {
      margin: 0;
      padding: 0;
    }
    

    And also remember about setting margin of div element to 0.

    0 讨论(0)
  • 2021-01-06 04:13

    This is a body margin from the browser reset margin and padding:

    body {
        margin: 0;
        padding: 0;
    }
    
    0 讨论(0)
  • 2021-01-06 04:18

    Try a CSS Reset:

    * { margin: 0; padding: 0; }
    

    That's a simple ones, there are thousands of more advanced ones across the web.

    0 讨论(0)
  • 2021-01-06 04:21

    Do you have the body margins set to 0px? In your stylesheet set body { margin:0px; }. If you want to keep the body margins, you need to adjust the width of the div. Something like div#idOfDiv { margin-left:-10px; margin-right: -10px }

    0 讨论(0)
提交回复
热议问题