CSS3 Tutorial

Learning CSS3 Step by Step

Creating Ribbons in CSS3

5

Ribbons are often used in a website’s design. Now we can create these ribbons using different css3 techniques and without images. CSS3 Ribbons create a special 3D perception which is often used in modern designs.

Creating Ribbons with only CSS3

3D Ribbons creating in CSS3 using different techniques; box-shadow, text-shadow, css3 triangles

In order to create these CSS3 ribbons we start with the technique to give shadow to an object: box-shadow. We give the ribbon and the shadow a color using RGBA technique where we can add opacity to the object as well. With RGBA we first give the Red,Green and Blue values for our color and then the opacity value. We can create following basic layout, adding some rounded corners to the background and aligning the banner over the background with some margins left and right.

Basic CSS3 layout using box-shadox and text-shadow

this is the layout before we add the triangles to create 3D ribbons in CSS3

<div class="bubble">
<div class="banner"><h2>CSS3 Ribbon</h2></div>
<div>
<h2>Basic CSS3 layout using box-shadox and text-shadow</h2>
<p>
this is the layout before we add the triangles to create 3D ribbons in CSS3
</p>
</div>
</div>
.bubble{
	border-radius: 10px;
	-moz-border-radius: 10px;
	-webkit-border-radius: 10px;
	
	box-shadow: 0 0 8px rgba(0,0,0,.6);
	-webkit-box-shadow: 0 0 8px rgba(0,0,0,.6);
	-moz-box-shadow: 0 0 8px rgba(0,0,0,.6);
	
	position: relative;
	background: #fff;
	z-index: 90; /* stack order: background */
}

.banner{
	background: #E7B550;
	padding: 0px 15px;
	left: -15px; top: 15px; 
	float: left;
	height: 30px;
	width: 100%;
	-moz-box-shadow: 0px 0px 4px rgba(0,0,0,0.55);
  	-webkit-box-shadow: 0px 0px 4px rgba(0,0,0,0.55);
	z-index: 100; /* stack order: foreground */
}

Now we have our banner but still no 3D ribbon effect. Herefor we need to create triangles with css3 and position them correctly towards the banner. We add two empty divs that will represent the left and right triangle, the left triangle will have a negative margin to the left while the right triangle will have the full width of the content as margin. The background for the triangles is slightly darker then the one for the banner to create the depth effect.

Creating Ribbons with only CSS3 using Triangles

Most people don’t know the triangle technique.

<div class="bubble">
<div class="banner"><h2>CSS3 Ribbon</h2></div>
<div class="left_triangle"></div>
<div class="right_triangle"></div>
<div>
<h2>Creating Ribbons with only CSS3</h2>
<p>
3D Ribbons creating in CSS3 using different techniques; box-shadow, text-shadow, css3 triangles
</p>
</div>
</div>
.triangle{
	height: 0px;
	width: 0px;
	border-style: solid;
	position: relative;
	border-width: 15px;
	z-index: 80; /* stack order: behind background */
}

.triangle_left{
	border-color: transparent #E1A223 transparent transparent;
	margin-left: -30px;
	top: 30px;
}

.triangle_right{
	border-color: transparent transparent transparent #E1A223;
	margin-left: 100%;
}

at last we add some basic padding to our content to make the total picture look nice.

Posted on in Tutorial

Comments

5

  1. Hayden says

    Great tutorial!
    It’s the little things that count, isn’t it?
    Thanks.

  2. Deryck says

    I’m using Druapl and this would make my nav bar pretty dope.

    Thanks.

  3. James Vidler says

    Great tutorial, but your example source code doesn’t work if you follow your exact instructions. I ended up lifting your code from source and that worked better. But worked great regardless, thanks dude.

  4. webexstudios says

    I love to work with css3. Thanks

  5. Hasan says

    This is good tutorial .. :-)

Leave a Reply

winrar download free

winrar download free

download winrar free

download winrar free

winzip activation code

winzip activation code

free winrar download

free winrar download

windows 7 ultimate product key

windows 7 ultimate product key

winzip registration code

winzip registration code

windows 7 key generator

windows 7 key generator

winzip free download full version

winzip free download full version

windows 7 product key

windows 7 product key

free winzip

free winzip

windows 7 activation crack

windows7 activation crack

winrar free

winrar free

winrar free download

winrar free download

winzip free download

winzip free download

winzip freeware

winzip freeware

free winrar

free winrar

windows 7 crack

windows 7 crack

windows xp product key

windows xp product key