treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Page width - cant get normally paddings

  • Hello and sorry. Question is really easy, but after reading your web site and book, i did not get answer for it. So.. I want to make web site which have in psd file width - 1024 and left&right paddings - 38.. But after a lot of trying i cant to make relative design, where in size of window (1024px) will be same paddings..

    My CSS:

    page {

        width: 92,578125%;  (948/1024)
        margin: 20px auto; - is it just editing top margin?)
        background: #ff00ff;
    

    }

    What i have- http://cl.ly/image/0p1u1H2Q250k

    Padding looks like- http://cl.ly/image/1U2Y47051M3z

    Sorry for my english and hope you understood what i meant ;)

  • Firstly, you should probably be using a reset or normalise css.

    For a width as specified for the 'page' you should have

    page {
    width:1024px
    padding:0 38px;
    }
    

    However, you should be aware that normally padding is ADDED to a specified width so the ACTUAL width will be 1100px.

    To get round this you have to use change the way this is done with

    * { 
      -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
      -moz-box-sizing: border-box;    /* Firefox, other Gecko */
      box-sizing: border-box;         /* Opera/IE 8+ */
    }
    
  • I didn't understand your issue correctly, but I believe, adding the float property may solve your issue. It will force layout to take padding or margin whatever you want to add.

  • You wouldn't float a whole page!

    And in any case...I don't think that's his issue.

    Here's an example of the difference: http://codepen.io/anon/pen/iFgmx