0

基于以下答案的大规模编辑

原帖在这里http://webmasters.stackexchange.com在miration之前。

我终于在所有浏览器(所有主要浏览器;Chrome、Opera、Safari、Firefox)上进行了页面布局,除了 IE 9 和可能的旧版本。目前,链接在第二个链接(具有下拉菜单)之后停止显示在“导航”栏中。链接对于下拉菜单都是水平安全的,直到第三个链接出现,它们都显示在“导航”栏下方并作为垂直列表显示。我确信这个问题需要一个单独的 IE 样式表,但问题是主样式表还是菜单样式表,目的是什么?

这是布局的图片:

这里 HTML5-核心布局-

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>College Of Martial Arts</title>
<link href="menu.css" rel="stylesheet" type="text/css">
<link href="master.css" rel="stylesheet" type="text/css"><!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>

<body>

<div class="wrap">
  <div id="logo" class="logo"><img src="images/comalogo.png" width="100" height="150"></div>
<header>
    <p> College Of Martial Arts</p>
  </header>

<!-- This is the HTML for the navigation bar at the top of the website -->   
    <nav>
 <ul id="menu"><b>
        <li><a href="#">News</a></li>
            <li>·</li>
        <li><a href="#">About Us</a>
        <ul>
                    <li><a href="#">The Instructors</a></li>
                    <li><a href="#">Our Arts</a></li>

        </ul>
         </li>
            <li>·</li>
        <li><a href="#">Location</a></li>
            <li>·</li>
        <li><a href="#">Gallery</a></li>
            <li>·</li>
        <li><a href="#">MMA.tv</a></li>
            <li>·</li>
        <li><a href="#">Schedule</a></li>
            <li>·</li>
        <li><a href="#">Fight Gear</a></li></b>
        </ul>
</nav>

<!-- end nav -->  

  <div class="midwrap">
    <div class="sidebar1">
    <aside>

      <p>This is an area for module/blocks for various uses such as; upcoming events, shout box, mini calendar and many more possibilities.</p>
    </aside>
  <!-- end .sidebar1 --></div>
  <article class="content">
    <h1>Main Content Area</h1>
    <section>
     <h2>A place to post content</h2>
      <p>"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?"

<a href="http://www.lipsum.com/">http://www.lipsum.com/</a>.</p>
    </section>
    <div class="clearfooter"></div>
    <!-- end .content --></article></div>
  <footer>
    <p>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.</p>
    <address>
      Address Content
    </address>
  </footer>
  <!-- end .wrap --></div>
</body>
</html>

CSS3 - 菜单样式表

@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 -主样式表-

@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;
}
4

5 回答 5

2

在你的 CSS 而不是你的 body 中试试这个。

"*" { 边距:0; 填充:0;}

明星周围没有引号。

于 2012-06-02T08:02:48.890 回答
2

</li>之后</ul>被交换了<li>Our Arts</li>,这让 CSS 关闭了。为了更好地衡量,在 CSS 中display: inline-block;使用#menu ul {}and #menu li {}

于 2012-06-07T05:23:09.030 回答
1

首先,我建议将modernizr放在头脑中。

http://modernizr.com/

我会改变:

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

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

}

于 2012-05-31T20:27:39.967 回答
1

布局问题通常与 HTML 或 CSS 的版本无关,除非浏览器不理解 HTML 或 CSS 或其特定版本。例如,由于 IE8- 不了解 HTML5,开发人员通常使用使用 JavaScript 块的解决方法来使其理解 HTML5 元素。

无论如何,由于您提供的代码非常长(并且您可能会发送它的小提琴版本),我建议您检查此列表:

  1. 确保您的浏览器同时支持 HTML5 和 CSS3,至少与您使用的一样多。
  2. 一行一行,去掉CSS规则,看看能不能找出问题出在哪里。
  3. 更改您的DOCTYPE声明并使用全小写html而不是HTML.
于 2012-05-31T20:45:29.873 回答
1

在您的问题边缘,请记住 CSS3 是 HTML5 的一部分...

您应该更好地使用 HTML5 的功能:

  • <header>代替<div id="header" class="header">
  • <nav>代替<div id="nav" class="nav">
  • <footer>代替<div id="footer" class="footer">
  • <aside>为您的右侧栏
  • ETC...
于 2012-06-02T17:51:11.770 回答