Removing space at the top left and right of div

后端 未结 9 1843
迷失自我
迷失自我 2020-12-01 13:02

I am starting to work with css and have basic issue.

I have a div element:

相关标签:
9条回答
  • 2020-12-01 13:24

    I had the same problem . just try this :

    html, body {
        margin-top:-13px;
    }
    
    0 讨论(0)
  • 2020-12-01 13:24

    the issue i had lately also, but even though i used padding:0px even added the !important on body didn't solved it... the actual problem was its position ... which you can do by using background-position:50% 50%; or by automatically let it choose the center position of the screen .. which is margin:0 auto; or margin:auto; that solved it for me ... hope for you all also. i realized the margin is what was needed after i tried @HAS's response thanks man ur awesome ... sorry for zombify the post

    0 讨论(0)
  • 2020-12-01 13:26

    margin: 0px; would remove all spaces around the element.

    padding: 0px; clears the area around the content

    you can try:

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

    with margin:auto; the browser calculates a margin.

    You can also use

    * {margin: 0px; padding: 0px;}
    

    this will remove all default margins and spaces. But be careful while using:

    position: absolute; 
    

    The 'position' property can take 4 values, static, relative, fixed and absolute. Then you can use top, bottom, left, right properties to position your element. This depends on your layout. This link might be useful https://www.w3schools.com/css/css_margin.asp

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