Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 2 of 2
  1. #1
    Member
    Join Date
    Aug 2005
    Posts
    87
    Member #
    10945

    Question Looking for a better way to create a responsive header & nav

    I am trying to create a website header in HTML5 that has the navigation nested inside.

    Then I recently learned about responsive design and I am trying to see if I can create one that will shrink to fit the size of phones and tablets.

    How is my HTML and CSS? What can I improve? At its smallest size the logo will be placed on top with the navigation below it.

    I also noticed that when I shrink the browser window, the background of the header gets sliced in half.

    Here is the code:

    Code:
    <!DOCTYPE html>
    
    <html><head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
        <meta charset="utf-8">
        <title>navigation test</title>
    
        <style type="text/css">
    
    html, body, div, span, applet, object, iframe,
    h1, h2, h3, h4, h5, h6, p, blockquote, pre,
    a, abbr, acronym, address, big, cite, code,
    del, dfn, em, font, img, ins, kbd, q, s, samp,
    small, strike, strong, sub, sup, tt, var,
    dl, dt, dd, ol, ul, li,
    fieldset, form, label, legend,
    table, caption, tbody, tfoot, thead, tr, th, td, header, footer, section,
    aside, nav, article, figure, time, legend {
        margin: 0;
        padding: 0;
        border: 0;
        outline: 0;
        font-family:  arial, verdana, tahoma, helvetica;
        font-size:100%;
        vertical-align: baseline;
    }     
    
    body {
        font-size: 0.750em;
        line-height: 1;
        color:#f8f7f7;
        background:#332f30 url(../images/backgrounds/mainbg.jpg) repeat bottom left;
    
    }
    
    ol, ul {
        list-style: none;
    }    
    
    img, header, footer, section, aside, nav, article, figure, time, legend {
        display:block;
    }
    
        /* --------------------- LINKS --------------------- */
    
    a {
        color:#f8f7f7;
        cursor:pointer;
        text-decoration:none;
    }
    
    a:focus, a:hover {
        color:#f8f7f7;
        text-decoration:none;
    }
    
    aside a, article a{
        color:#0985bf;
        cursor:pointer;
        text-decoration:underline;
    }
    
    
    /* --------------------- WRAPS --------------------- */
    
    
    header div {
        width:946px;
        margin-left:auto;
        margin-right:auto;
            background-color: #444444;    
    }
    
    header div:after {
         display: block;
        height: 0;
        clear: both;
    }
    
    
    /* --------------------- HEAD --------------------- */
    
    
    header {
        background-color: #444444;
        height:102px;    
    }
    
    header img.logos {
        float: left;
       margin-top: 30px;
    }
    
    header ul {
        float: right;
        display: inline;
        margin-top:40px;
        height: 22px;
    }
    
    header li {
        display: inline;
    }
    
    header li a {
        height: 22px;
        margin-left: 32px;
        font-size: 20px;
        font-family: 'Century Gothic', Helvetica, sans-serif;
        font-weight: bold;
    }
    
    </style>
    
    </head>
    
    <body>
    
    
    <header>
    <div>
    <img src="http://www.webdesignforums.net/Desktop/Responsive Version/images/logo.png" width="203" height="41" class="logos">
    
    
                <ul>
    
                    <li><a href="#" class="portfoliobtn" title="link to portfolio">HOME</a></li>
    
                    <li><a href="#" class="aboutbtn" title="link to about">ABOUT</a></li>
    
                    <li class="active"><a href="#" class="blogbtn" title="link to about">PORTFOLIO</a></li>
    
                    <li><a href="#" class="contactbtn" title="link to contact">CONTACT</a></li>
    
                </ul>
    
    
    </div>
    </header>
    </body>
    </html>
    Attached Images Attached Images
    Last edited by deffvaltez; Apr 10th, 2014 at 12:39 PM.

  2.  

  3. #2
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,483
    Member #
    425
    Liked
    2783 times
    First off, if your background's a solid color, you don't really need a background image. That's a waste of resource.

    The reason your header is getting cut off is probably because you have it sized to 946px. If you want, use a relative width such as 100% to deal with that issue. At least if I'm interpreting what you said correctly, that should solve it.

    The biggest thing you can improve on your CSS is not to use that flaming car wreck known as the Eric Meyer CSS reset. I don't know why he ever came up with that thing, but people need to stop using it because it's flawed right out of the chute. If you're not sure what I mean, put nothing other than an ordered list on your page and you should see it.

    Once you get those things done, then all you need to do is to add some media queries in and you should be set.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Tags for this Thread

All times are GMT -6. The time now is 12:16 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com