-2

我正在尝试为块式主导航创建 css 功能区,但是当我包含“display:table;”时,功能区的右侧三角形不起作用 或“显示:块;” 在 Clearfix 中。自然,当我删除 Clearfix 时,色带可以正常工作,但包裹消失了。让功能区工作并使用 Clearfix 来防止包装折叠会很棒。任何提示将非常感谢!

可以在这里找到原始代码和我的工作所基于的图像:http: //jsfiddle.net/necolas/xCfeH/

这是我编写的 HTML:

<!DOCTYPE html>

  <html>

    <head>

      <meta charset='UTF-8' />

      <link rel='stylesheet' href='css/style.css' />

    </head>

    <body>

      <div id="page-wrap" class="group">

        <nav id="main-navigation">

           <ul id="ribbon">

               <li><a href="#">ABOUT</a></li>

               <li><a href="#">CLIENTS</a></li>

               <li><a href="#">SERVICES</a></li>

               <li><a href="#">CONTACT</a></li>

           </ul>

        </nav>

      </div> <!-- END page-wrap -->

   </body>

这是CSS:

/*
Description: Ribbon Block Nav Ribbon
*/


/* Clearfix to prevent collapse of bottom body area when divided into two.
------------------------------------------------------------ */
.group:after { content:""; display: table; clear:both;
}

/**
* Based on Eric Meyer's Reset CSS v2.0 (http://meyerweb.com/eric/tools/css/reset/)
* http://cssreset.com
*/

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, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
vertical-align: baseline;
}


/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}

ol, ul {
list-style: none;
}



/* "Page wrap" is the white page upon which all elements reside.
------------------------------------------------------------ */
#page-wrap { 
    width: 900px; 
    margin: 70px auto 10px; 
    display: block;
    background: white;
}

/* Background black 
------------------------------------------------------------ */
body {
background: #000000;
}

/* Main List Item Link Styling
------------------------------------------------------------ */
#main-navigation li a {
display: block;
padding: 10px 30px 15px 30px; 
color: white;
font: 24px Arial, sans-serif;
font-weight: bold;
text-decoration: none;
margin: 0 -30px 15px 0;
position: relative;
left:-15px;
background: #d6d135;
-webkit-box-shadow: 180px 0px 0px 0px #d3d3d3;
box-shadow: 1px 2px 2px 1px #d3d3d3;

/* css3 extras */
text-shadow:0 1px 1px rgba(0,0,0,0.2);
-webkit-box-shadow:0 1px 1px rgba(0,0,0,0.2);
   -moz-box-shadow:0 1px 1px rgba(0,0,0,0.2);
        box-shadow:0 1px 1px rgba(0,0,0,0.2);
zoom:1;
}



/* Main Nav Container
------------------------------------------------------------ */
#main-navigation {
float: left;
display: block;
width: 180px;
z-index:1;
padding: 25px 0 30px 0;
margin: 0 15px 10px 0;
}


#ribbon li a:before,
#ribbon li a:after {
   content:"";
   position:absolute;
   z-index:-1;
   top:100%;
   left:0;
   border-width:0 14px 14px 0;
   border-style:solid;
   border-color:transparent #647D01;
}

#ribbon li a:after {
    left:auto;
    right:0;
    border-width:0 0 14px 14px;
}
4

2 回答 2

0

要清除浮动,请尝试添加overflow: hidden到容器中。

任何一个:

#ribbon { overflow: hidden; }

或者:

#main-navigation { overflow:hidden; }

(并简单地省略clearfix类)

于 2013-05-25T21:47:21.690 回答
0

问题解决如下:“将#ribbon更改为”position:absolute;”并将“position:relative;”添加到#main-navigation以进行修复。
我在这里找到了解决方案:stackoverflow.com/questions/8327424/

于 2013-05-27T13:28:07.957 回答