Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pure CSS Rounded Ribbon

Tags:

html

css

I am trying to achieve the below using pure CSS, is it possible? If I can figure out a way to hide the bottom part to the top of the bottom rounded corner that would work. But I am lost at what would work...

Designers Design what I have thus far

.ribbon, .ribbon * {
box-sizing: border-box;
-moz-box-sizing: border-box;
}
.ribbon {
    width: 600px;
    margin: 40px auto 10px;
    padding: 0 10px 4px;
    position: relative;
    color: black;
    background: #eee;
}
.ribbon h3 {
    display: block;
    height: 40px;
    width: 620px;
    margin: 0;
    padding: 5px 10px 5px 30px;
    position: relative;
    left: -30px;
    color: white;
    background: rgb(193,0,0);
    box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.ribbon h3::before {
    content: '';
    display: block;
    width: 0;
    height: 0;
    position: absolute;
    bottom: -11px;
    z-index: 10;
    left: 0;
}
.ribbon.round h3 {
    border-radius: 10px 0px 0px 0px;
}
.ribbon.round h3::before {
    width: 20px;
    height: 30px;
    bottom: -20px;
    border: none;
    background: rgb(61,0,0);
    border-radius: 10px 0px 0px 10px;
}

Fiddle to what I have currently http://jsfiddle.net/yoderman94/Gdgwq/

like image 791
Chad J Treadway Avatar asked Jan 21 '26 00:01

Chad J Treadway


1 Answers

Simply make your z-index value negative:

.ribbon h3::before {
  z-index: -1;
}

That will place it under the heading.

To keep the rounded top, add another block with lower z-index, and fill it with the same background as the heading:

Example: http://jsfiddle.net/K7e96/

like image 143
nice ass Avatar answered Jan 22 '26 15:01

nice ass



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!