Question

I am trying to create css ribbons for a block-style main navigation, but the right-hand side triangles of the ribbon don't work when I include "display:table;" or "display:block;" in Clearfix. Naturally, when I remove Clearfix, the ribbon works properly, but the wrap disappears. It would be great to have the ribbon work -and- use Clearfix to keep the wrap from collapsing. Any tips would be greatly appreciated!

The original code, and an image I based my work on can be found here: http://jsfiddle.net/necolas/xCfeH/

Here is the HTML I've written:

<!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>

Here is the 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;
}
Was it helpful?

Solution 2

The problem was solved as follows: "Changed #ribbon to "position: absolute;" and added "position: relative;" to #main-navigation for the fix.
I found the solution here: stackoverflow.com/questions/8327424/

OTHER TIPS

To clear the floats, try adding overflow: hidden to the container.

Either:

#ribbon { overflow: hidden; }

or:

#main-navigation { overflow:hidden; }

(and simply omit the clearfix class)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top