HTML5 CSS3 layout not working

MASSIVE EDIT BASED ON THE ANSWERS BELOW

original post here http://webmasters.stackexchange.com before miration.

I have finally gotten the page to layout as it should across all browsers (all major browsers; Chrome, Opera, Safari, Firefox) except IE 9 and likely its legacy versions. Currently the links stop showing in the ‘nav’ bar after the second link (which has drop downs). The links are all horizontal safe for the drop down, until it comes to the link third and on they all show below the ‘nav’ bar and as a vertical list. I am sure the problem requires a separate style sheet for IE but the question is a master style sheet or the menu style sheet, and to what end?

here is a pic of the layout:

HTML5 -core layout-



College Of Martial Arts








College Of Martial Arts

Main Content Area

A place to post content

"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?" http://www.lipsum.com/.

This footer contains the declaration position:relative; to give Internet Explorer 6 hasLayout for the footer and cause it to clear correctly. If you're not required to support IE6, you may remove it.

Address Content

CSS3-menu style sheet

@charset "utf-8";
/* CSS Document */

/* Main */
#menu
{
        width: 100%;
        margin: 0;
        padding: 10px 0 0 0;
        list-style: none;
        background: url(images/menubg.png) repeat-x;
        background: -moz-linear-gradient(#000, #333);
        background: -webkit-gradient(linear,left bottom,left top,color-stop(0, #444),color-stop(1, #000));
        background: -webkit-linear-gradient(#000, #333);
        background: -o-linear-gradient(#000, #333);
        background: -ms-linear-gradient(#000, #333);
        background: linear-gradient(#000, #333);
        -moz-border-radius: 5px;
        border-radius: 5px;
        -moz-box-shadow: 0 2px 1px #9c9c9c;
        -webkit-box-shadow: 0 2px 1px #9c9c9c;
        box-shadow: 0 8px 8px #9c9c9c;
        /* outline:#000 solid thin; */



}

#menu li
{
        left:150px;
        float: left;
        padding: 0 0 10px 0;
        position:relative;
        color: #FC0;
        font-size:15px;
        font-family:'freshman' cursive;
        line-height:15px;
        display: inline-block;
}


#menu a
{
        float: left;
        height: 15px;
        line-height:15px;
        padding: 0 10px;
        color: #FC0;
        font-size:15px;
        text-decoration: none;
        text-shadow: 1 1px 0 #000;
        text-align:center;
}


#menu li:hover > a
{
        color: #fafafa;
}


*html #menu li a:hover /* IE6 */
{
        color: #fafafa;
}


#menu li:hover > ul
{
        display: block;
}


/* Sub-menu */
#menu ul
{
    list-style: none;
    margin: 0;
    padding: 0;
    display: none;
    position: absolute;
    top: 25px;
    left: 0;
    z-index: 99999;
    background: url(images/menubg.png) repeat-x;
    background: -moz-linear-gradient(#000, #333);
    background: -webkit-gradient(linear,left bottom,left top,color-stop(0, #111),color-stop(1, #444));
    background: -webkit-linear-gradient(#000, #333);
    background: -o-linear-gradient(#000, #333);
    background: -ms-linear-gradient(#000, #333);
    background: linear-gradient(#000, #333);
    -moz-border-radius: 5px;
    border-radius: 5px;
    /* outline:#000 solid thin; */
}


#menu ul li
{
    left:0;
    -moz-box-shadow: none;
    -webkit-box-shadow: none;
    box-shadow: none;
}


#menu ul a
{
    padding: 10px;
    height: auto;
    line-height: 1;
    display: block;
    white-space: nowrap;
    float: none;
    text-transform: none;
}


*html #menu ul a /* IE6 */
{
        height: 10px;
        width: 200px;
}


*:first-child+html #menu ul a /* IE7 */
{
        height: 10px;
        width: 200px;
}


/* Clear floated elements */
#menu:after
{
        visibility: hidden;
        display: block;
        font-size: 0;
        content: " ";
        clear: both;
        height: 0;
}


* html #menu             { zoom: 1; } /* IE6 */
*:first-child+html #menu { zoom: 1; } /* IE7 */

CSS3-master style sheet-

@charset "utf-8";

*{
    margin: 0;
    padding: 0;
}

html{
    height:100%;
}

body {
    font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif;
    background: #000;
    margin: 0;
    padding: 0;
    color: #000;
}

/* ~~ Element/tag selectors ~~ */
ul, ol, dl { /* Due to variations between browsers, it's best practices to zero padding and margin on lists. For consistency, you can either specify the amounts you want here, or on the list items (LI, DT, DD) they contain. Remember that what you do here will cascade to the .nav list unless you write a more specific selector. */
    padding: 0;
    margin: 0;
}
h1, h2, h3, h4, h5, h6, p {
    margin-top: 0;   /* removing the top margin gets around an issue where margins can escape from their containing block. The remaining bottom margin will hold it away from any elements that follow. */
    padding-right: 15px;
    padding-left: 15px; /* adding the padding to the sides of the elements within the blocks, instead of the block elements themselves, gets rid of any box model math. A nested block with side padding can also be used as an alternate method. */
}
a img { /* this selector removes the default blue border displayed in some browsers around an image when it is surrounded by a link */
    border: none;
}
/* ~~ Styling for your site's links must remain in this order - including the group of selectors that create the hover effect. ~~ */
a:link {
    color: #FC0;
    text-decoration: underline; /* unless you style your links to look extremely unique, it's best to provide underlines for quick visual identification */
}
a:visited {
    color: #FC0;
    text-decoration: underline;
}
a:hover, a:active, a:focus { /* this group of selectors will give a keyboard navigator the same hover experience as the person using a mouse. */
    text-decoration: none;
}
/* ~~ This fixed width container surrounds all other blocks ~~ */
.wrap {
    position: relative;
    width: 1250px;
    min-height: 100%;
    margin: 0 auto; /* the auto value on the sides, coupled with the width, centers the layout */
    color: #fff;
}

div.logo{
    position: absolute;
    top: 25px;
    left: 20px;
}


header {
    background-color: #999;
    color: #FC0;
    margin-left: 5px;
    height: 80px;
    width: 1240px;
    line-height: 70px;
    font-family: 'freshman' cursive;
    font-size: 50px;
    text-shadow: 8px 8px #9c9c9c;
    text-outline: 1px 1px #000;
    text-align: center;     
}

/* ~~ These are the columns for the layout. ~~ 

1) Padding is only placed on the top and/or bottom of the block elements. The elements within these blocks have padding on their sides. This saves you from any "box model math". Keep in mind, if you add any side padding or border to the block itself, it will be added to the width you define to create the *total* width. You may also choose to remove the padding on the element in the block element and place a second block element within it with no width and the padding necessary for your design.

2) No margin has been given to the columns since they are all floated. If you must add margin, avoid placing it on the side you're floating toward (for example: a right margin on a block set to float right). Many times, padding can be used instead. For blocks where this rule must be broken, you should add a "display:inline" declaration to the block element's rule to tame a bug where some versions of Internet Explorer double the margin.

3) Since classes can be used multiple times in a document (and an element can also have multiple classes applied), the columns have been assigned class names instead of IDs. For example, two sidebar blocks could be stacked if necessary. These can very easily be changed to IDs if that's your preference, as long as you'll only be using them once per document.

4) If you prefer your nav on the left instead of the right, simply float these columns the opposite direction (all left instead of all right) and they'll render in reverse order. There's no need to move the blocks around in the HTML source.

*/
.midwrap{
    float: left;
    background-color: #999;
    margin-left: 5px;
    width: 1240px;
    color: #FFF;

}

.sidebar1 {
    float: right;
    width: 250px;
    background: #999;
    padding: 10px 0px 0px 10px;
    }

.content {
    padding: 10px 0;
    width: 850px;
    float: right;
    background:#999;
}

/* ~~ This grouped selector gives the lists in the .content area space ~~ */
.content ul, .content ol {
    padding: 0 15px 15px 40px; /* this padding mirrors the right padding in the headings and paragraph rule above. Padding was placed on the bottom for space between other elements on the lists and on the left to create the indention. These may be adjusted as you wish. */
}

.clearfooter {
height: 330px;
}

/* ~~ The footer ~~ */
footer {
    margin-left:5px;
    height: 330px;
    width:1240px;
    padding: 10px 0;
    background: #69F;   
    bottom: 0;
    position: relitive;/* this gives IE6 hasLayout to properly clear */
    clear: both; /* this clear property forces the .container to understand where the columns end and contain them */
}

/*HTML 5 support - Sets new HTML 5 tags to display:block so browsers know how to render the tags properly. */
header, section, footer, aside, nav, article, figure {
    display: block;
}

Problem courtesy of: john.weland

Solution

The

and

were swapped after

  • Our Arts
  • and that threw the CSS off. For good measure, in the CSS use display: inline-block; for the #menu ul {} and #menu li {} .

    Solution courtesy of: GomezJr

    Discussion

    Layout problems generally has nothing to do with the version of HTML or CSS, unless browser doesn’t understand HTML or CSS or the specific version of it. For example since IE8- don’t know about HTML5, developers usually use a workaround using a JavaScript nugget to make it understand HTML5 elements.

    Anyway, since the code you provided is really long (and you might send a fiddle version of it), I recommend that you check this list:

    1. Ensure that your browser supports both HTML5 and CSS3 , at least as much as you’ve used them.
    2. Line by line, remove CSS rules, to see if you can find out where the problem is originated.
    3. Change your DOCTYPE declaration and use all-lowercased html instead of HTML .

    Discussion courtesy of: Saeed Neamati

    Firstly, I would advise sticking modernizr in the head.

    http://modernizr.com/

    The I would change:

    div.wrap {
        left: 50%;
        margin-left: -625px;
        min-height: 100%;
        position: absolute;
        width: 1250px;
    }

    to

    div.wrap {
    margin: 0 auto;
    min-height: 100%;
    position: relative;
    width: 1250px;

    }

    Discussion courtesy of: Timbadu

    In margin of your problem, remember CSS3 is part of HTML5…

    You should better use HTML5’s features :


    • instead of



    • instead of


    • etc…

    Discussion courtesy of: zessx

    Try this in your CSS instead of your body.

    “*” { margin: 0; padding: 0; }

    Without quotes around star.

    Discussion courtesy of: Brian

    This recipe can be found in it’s original form on Stack Over Flow .

    稿源:CSS3 Recipes (源链) | 关于 | 阅读提示

    本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
    酷辣虫 » 综合编程 » HTML5 CSS3 layout not working

    喜欢 (0)or分享给?

    专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

    使用声明 | 英豪名录