Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to insert more than one watermark

Status
Not open for further replies.

leifoet

Technical User
Jan 31, 2016
203
BE
This css-code prints a watermark at the top of my document:

<style>
div {
width: 880px;
height: 100%;
display: block;
position: relative;
repeat: no-repeat;
}

div::after {
content: "";
background: url(myimage.gif) no-repeat;
opacity: 0.3;
top: 3%;
left: 20%;
bottom: 0;
right: 0;
position: absolute;
z-index: 1;
}
</style>

How can i change these settings/code to become the following
=> change the size (height - width) of the printed watermark-image
=> how can I get the watermark also at the bottom (bottom) - or even also in the middle of the document (possibly with different images ?)
My attempts are not successful - possibly also the code is not optimal ?

Thanks for help - Leifoet

 
Hi

Is this for use only on your own machine ? Otherwise I see no reason for it as by default FireFox and Chrome not print background images.

With this kind of CSS trick you can add at most 2 "watermarks". The current one being set on [tt]::after[/tt] pseudo-element, you can set another one on [tt]::before[/tt].


Feherke.
feherke.ga
 
I use the watermark-code in a website - tested before in desktop Windows Edge, desktop Chrome and Android Chrome: successful.

Now also inserted new 'before' code (as proposed by feherke) to become also the same watermark-image on the bottom of the document :

div::before {
content: "";
background: url(myimage.gif) no-repeat;
opacity: 0.3;
top: 90%;
left: 20%;
bottom: 0;
right: 0;
position: absolute;
z-index: 1;
}

Not successful => watermark only at the top (as before)
Code not OK ?

Other possibilities or tips ?
Thanks - Leifoet



 
Hi

When in doubt, set borders to see what you got :
As you can see, the [tt]::before[/tt] and [tt]::after[/tt] pseudo-elements are like dynamically generated element which your CSS places over the base element. The [tt]background[/tt] you set can appear somewhere inside those pseudo-elements. As you specified no positioning for the background, will default to the top left corner.


Feherke.
feherke.ga
 
I note that my code is identical to the code in therefore this should succeed also... but in my document I only see the top watermark - not the bottom one.

The document/list (in which the bottom-watermark should appear) is generated by an SQL select query (from an Access database);
in your exemple in however, the 'document' is static (?).

Could this be a (the) problem to determine 'the bottom' ?
If so, how to solve ?
Thanks - Leifoet
 
I see the watermark at the top, not only in your expample but also in my document;
the image of the 2nd url overlaps perfect the first => I see only one (=at the top)
I tested it also with my own image in the second url => both images only at the top.

Other options ?
Thanks for help - Leifoet
 
Hi

Sorry, at this point I left without ideas. Will need to see the entire HTML and CSS as the browser gets them. ( So as they are visible in the browser's View Source command. )


Feherke.
feherke.ga
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top