How I Did It: How to Create a sticker-ribbon in 3 steps

The stickers (or ribbon) are those images that are placed in the upper right or upper left, and commonly have a form angular range. There are various types, from simple static images to the most spectacular Flash movies. Sometimes they are constructed so as to stay in position even when scroll the browser window.
If you do not want to rely on services such as QuickRibbon.com , but you want to build a ribbon around you, here are 3 simple steps to follow.

1. We create the image

First of all we create the image that we want to place in one of the right or left. The image below, of 163 × 163 pixels, ecostruita to the upper left corner.

Ribbon Sticker

To make the effect complete overlap must choose, when you save, a format that supports transparency, like GIF or PNG.

2. HTML code

contenitore, che useremo puoi per posizionare l'immagine nell'angolo: Saved our image we can put it in our pages, tags by wrapping the img in a div container, which you'll use to position the image to the:

1
"ribbon" >< img src = "ribbon.gif" title = "Ribbon Test" width = "163" height = "163" border = "0" >< / div > < div class = "ribbon"> < img src = "ribbon.gif" title = "Test Ribbon" width = "163" height = "163" border = "0"> </ div >

If our stickers must have a link, we can make use of tags map to define a sensitive area that is not rectangular. The stickers shown in this sample, in fact, have an oblique form and transparency highlights the contours perfectly. It would therefore be inappropriate can click an empty area by simply adding a tag a flow around the image. Then we use this syntax:

1
2
"ribbon" >< img src = "ribbon.gif" title = "Ribbon Test" width = "163" height = "163" border = "0" usemap = "#ribbonlink" >< / div > < div class = "ribbon"> < img src = "ribbon.gif" title = "Test Ribbon" width = "163" height = "163" border = "0" usemap = "# ribbonlink"> </ div >

definisce le coordinate del nostro ribbon. The attribute coords of the tag area defines the coordinates of our ribbons.

3. CSS

Let's add the definitions of the styles that will allow our stickers positioned on the page properly:

1
2
3
4
5
6
7
8
9
10
11
{div.ribbon
absolute ; position: absolute;
0px ; left : 0px ; top: 0px; left: 0px;
163px ; width : 163px ; height: 163px; width: 163px;
0 ; padding : 0 ; margin: 0; padding: 0;
visible ; overflow: visible;
none ; float: none;
10000 } z-index: 10000}
{div.ribbonimg
0 ; padding : 0 ; margin : 0 ; border: 0; padding: 0; margin: 0;
none } background-image: none}

in fixed : If we want the ribbon to remain "stuck" to the video, even if we scroll down the window, just change the absolute style position in fixed :

1
2
3
4
5
6
7
8
{div.ribbon
fixed ; position: fixed;
0px ; left : 0px ; top: 0px; left: 0px;
163px ; width : 163px ; height: 163px; width: 163px;
0 ; padding : 0 ; margin: 0; padding: 0;
visible ; overflow: visible;
none ; float: none;
10000 } z-index: 10000}

, fino a poco tempo fa non era supportato da tutti i browser. Note: the type fixed , in the style position , until recently, was not supported by all browsers. To make the effect, in fact, was forced to use a Javascript function that, at regular intervals, controlled the flow of the contents of any window and replace the ribbon so that it gave the impression to remain substantially motionless. Fortunately, today, apart from some outdated version of Internet Explorer, all browsers support the type fixed .

2 comments to "How I Did It: How to Create a sticker-ribbon in 3 steps"

  1. January 22, 2009 Create a sticker-ribbon | Simone D'Amico :

    [...] How I Did It: How to Create a sticker-ribbon in 3 steps posted under Graphics Related Post: Creating the interface of an operating system with jQuery [...]

  2. May 27, 2009 Graphicgirls.it:: Utilities, resources and software:: Create a ribbon for your site :

    [...] You'd like to make a ribbon with the custom graphics you can do this using divs and css. In this excellent post on Undolog will be explained step by step how to do it. If you use an image format. Png [...]

Leave a comment

XHTML TAG PERMIT: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> INSERTION CODE:
 <pre></pre> // blocco generico <code></code> // blocco generico [cc_actionscript][/cc_actionscript] // Actionscript [cc_actionscript3][/cc_actionscript3] // Actionscript 3 [cc_css][/cc_css] // CSS Style Sheet [cc_html][/cc_html] // HTML [cc_js][/cc_js] // Javascript [cc_objc][/cc_objc] // Objective-C [cc_php][/cc_objc] // PHP [cc_sql][/cc_sql] // SQL