Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a header bar fold over the webpage css

Tags:

html

css

effect

Can someone please tell me the CSS code or point me to a tutorial on how to achieve this effect see all the time. Here is a image of what I'm talking about:

enter image description here

Note: I know how to position with absolute I just need to know how they pull the effect off.

like image 941
John Floyd Avatar asked Dec 19 '12 19:12

John Floyd


1 Answers

If the ribbon is the issue, then use borders on an empty (0-size) element (which you can add with :after pseudo-element)..

Html

<div id="content">
    <div id="ribbon"></div>
</div>

CSS

#content{
    background-color:#77c;
    width:300px;
    height:200px;
    position:relative;
}
#ribbon{
    position:absolute;
    width:80px;
    height:30px;
    right:-20px;
    top:50px;
    background-color:#999;
}
#ribbon:after{
    content:'';
    width:0;
    height:0;

    border-color: transparent transparent #666 #666;
    border-style:solid;
    border-width:5px 10px;

    position:absolute;
    right:0;
    top:-10px;
}

Demo at http://jsfiddle.net/gaby/zJPhy/

like image 162
Gabriele Petrioli Avatar answered Nov 01 '22 13:11

Gabriele Petrioli