views:

46

answers:

4

I would like to add a "preview" stripe to a site.
I like what blogger does when you click to preview editing a post (Anteprima means preview in italian)

alt text

Do you know how to make it as a layer in order to plug it without modifying the main html code of my site?

+3  A: 

You will either have to add an additional DIV or add an additional SCRIPT in document head. It's simpler with a DIV, because it will be there immediately without executing any script.

Example HTML (Version 1):

<body>
    <div class="preview"></div>
    ...
</div>

Example HTML (Version 2):

<body>
    <img class="preview" />
    ...
</div>

Example CSS:

.preview
{
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    z-index: 100;
    /* omit all these if you use an IMG */
    width: 100px; /* adjust */
    height: 100px; /* adjust */
    background-image: url(...);  /* adjust */
    background-repeat: no-repeat;
}
Robert Koritnik
+1 for actual code but why a div? Why not just an <img>?
Noufal Ibrahim
Naufal: You're right. Could be an image as well.
Robert Koritnik
A: 

You could just insert a semi-transparent PNG with the content and position it at the top left corner couldn't you?

Noufal Ibrahim
+2  A: 

Here's another option to play with. Just fiddle around with the values. I used webkit rotation in this sample. For more rotation compatibility, see here

CSS:

.preview {
    position:absolute;
    top:50px;
    left:-125px;
    width:400px;
    font-size:32px;
    text-align:center;
    background-color:#888; 
    color:#fff;
    border:1px solid black;
    -webkit-transform:rotate(-45deg);
    -webkit-transform-origin-x:50%;
    -webkit-transform-origin-y:0px;
}

and the HTML:

<div class="preview">Preview</div>
rchern
This is nice, but it's not a browser wide solution.
Robert Koritnik
@Robert See my note about rotation compatibility. I simply didn't list the other options out. It also seems to be what Blogger uses.
rchern
@rchern that's a beauty
systempuntoout
+1  A: 

Hi systempuntoout

Very simple solution

Markup

<img src="preview-image.png" class="preview">

Css

.preview {
    position: fixed;
    top: 0;
    left: 0;
    display: block;
}
Kenneth B