Best way to center website?

Discussion in 'HTML & Website Design' started by tribalz, Dec 16, 2013.

  1. #1
    Pretty new to css and html
    drubiano.github.io

    here is my website, ive been playing around with it to get it how I want but how it is now, it doesnt seem like the best way to 'center' it. Ie, currently when you resize window it doesnt look very good. Any help appreciated and any resources to learn how to position blocks better would also help a lot.

    
    body {
        background-image: url("spacebg.jpg");
        }
    
    nav {  
      
        position: fixed;
        height: 100%;
        width: 200px;
        top: 0;
        left: 1210px;
        border-right: 10px solid black;
        background-color: #404853;
        list-style-type: none;
        }
    nav a {
      
        text-decoration: none;
        color: white; }
    nav li {
        text-align: center; }
    
    .info {
        background-color: #B8C5D1;
        height: 100%;
        position: fixed;
        top: 0;
        left: 500px;
        width: 700px;
        border-left: 10px solid black;
        color: black }
    .info h1 {
        text-align: center; }
      
    
    
    Code (markup):
     
    tribalz, Dec 16, 2013 IP
  2. Pixobox

    Pixobox Well-Known Member

    Messages:
    778
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    118
    #2
    put everything inside a div in html (ex:<div id="container">...your site..</div>), CSS - #container { width:700px; margin:auto;} hope it helps.
    Search for responsive layouts or media-queries for resizing issues.
     
    Pixobox, Dec 16, 2013 IP
  3. inserte

    inserte Well-Known Member

    Messages:
    85
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    110
    #3
    If you want it to look good when you resize window then you are looking for responsive technique. Here is one great video tutorial of how to create responsive design http://net.tutsplus.com/tutorials/html-css-techniques/responsive-web-design-a-visual-guide/ that will center no matter how big or small screen is.

    let me know if that helps
     
    inserte, Dec 16, 2013 IP
  4. tribalz

    tribalz Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #4
    thanks for replies, messed around with it some more
    body{
    margin-bottom: 120px;
    background-image: url("spacebg.jpg");
    }
    
    .content {
    float: right;
    height:100%;
    background-color: #B8C5D1;
    color: black;
    width: 600px;
    }
    
    .content h1 {
    text-align:center;
    }
    
    nav {
    height:100%;
    text-align: center;
    float: left;
    width: 200px;
    list-style-type:none;
    background-color: #404853;
    }
    
    nav li a {
    color: #fff;
    text-decoration: none;
    }
    nav li a:hover
    {
    background-color: #369;
    color: #fff;
    }
    
    .container {
    width:800px;
    margin:auto;
    }
    
    Code (markup):
    I cant make the height: 100% work so backgrounds fill in all the way down the page
     
    tribalz, Dec 16, 2013 IP
  5. RiptideSolutions

    RiptideSolutions Active Member

    Messages:
    142
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    65
    #5
    Take off the height:100% and just give it a fixed height if you're not looking for a Responsive view. Also, it's not good practice to add a margin-bottom to the body class.
     
    RiptideSolutions, Dec 16, 2013 IP