Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS how to control the margins

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #45584
    zeeshan
    Participant

    hi

    this is zeeshan. how can i take the margin of the div from top. when the div having the css margin:0 auto;
    div{
    width:500px;
    height:540px;
    text-align:center;
    display:block;
    border:3px solid #d4d4d4;
    margin:0 auto;
    }

    #138978
    CodeGraphics
    Participant

    div{
    margin: 50px auto 0 auto;
    }

    Margin goes clock-wise. The first value is for top, the second value is for right, the third value is for bottom and the fourth value is for left. So if you add the code above, then you are telling the div to shift down by 50px from top.

    #138979
    pixelgrid
    Participant

    Im not sure if this is what you are asking

    In margin: 0 auto

    0 – represents top and bottom
    auto – means center it horizontally

    If you want to add more top margin make it a full declaration margin: top right bottom left.

    If you are having extra margin and dont know where its coming from you should post a link to your site

    #138980
    daffy58
    Participant

    add one more div and you can control the margin. See the[ codepen](http://codepen.io/anon/pen/pDBrF “”)

    Or you can just set as
    margin: 20px auto 0

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘CSS’ is closed to new topics and replies.