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

Tuesday, December 2, 2008

The sticker (or ribbon) are those images that are positioned in the upper right or upper left, and they commonly form an angled fascia. There are various types, from simple static images to the most spectacular Flash movies. Sometimes they are constructed so as to remain in their position even when you scroll the contents of the browser window.
If you do not want to rely on services like QuickRibbon.com, but want to build a ribbon around you, here's 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 picture below, of 163x163 pixels, ecostruita the upper left corner.

Ribbon Sticker

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

2. HTML

Saved our image we can insert in our pages, wrapping the tag img in a div container, which you'll use to position the image in the corner:

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

If our sticker must have a link, we can use the tag map to define a hot spot that is not rectangular. The sticker in this example, in fact, have a slanted shape and transparency highlights perfectly the contours. It would therefore be improper to allow you to click on a blank area by simply adding a tag a central axis of the image. Then we use this syntax:

HTML:
  1. "ribbon" ><img src = "ribbon.gif" title = "Ribbon Test" width = "163" height = "163" border = "0" usemap = "#ribbonlink" >< / div> <div "ribbon" class => <img src = "ribbon.gif" title = "Ribbon Test" width = "163" height = "163" border = "0" usemap = "#ribbonlink"> </ div>
  2. "ribbonlink" ><area shape = "poly" coords = "163,0,0,163,0,129,129,0" href = "http://undolog.com" >< / map> <map "ribbonlink" name => shape = <area "poly" coords = "163,0,0,163,0,129,129,0" href = "http://undolog.com"> </ map>

The attribute coords of the tag area defines the coordinates of our ribbon.

3. the CSS

Now add the definitions of the styles that will enable our stickers positioned on the page correctly:

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

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

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

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 any window's contents and replace the ribbon in a way that gave the impression of being essentially immobile. Fortunately, today, with some outdated version of Explorer, all browsers support the type fixed

Related Post

Was this article helpful?: Per nientePocoAbbastanzaMoltoMoltissimo
Loading ... Loading ...

2 comments to "How I Did It: How to create a sticker-ribbon in 3 Steps"

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

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

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

    [...] Would like to make a ribbon with the custom graphics you can do so using div 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 with [...]

Leave a comment

TAG XHTML PERMISSIONS: <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 [as][/as]           // Actionscript [css][/css]         // CSS Style Sheet [html][/html]       // HTML [js][/js]           // Javascript [objc][/objc]       // Objective-C [php][/php]         // PHP [sql][/sql]         // SQL