Connecting Tech Pros Worldwide Forums | Help | Site Map

How can I do this?

Rhino
Guest
 
Posts: n/a
#1: Apr 19 '06
I would like to know if something specific is possible with HTML and CSS
and, if it is possible, how best to do it.

I have a large JPEG showing an open book and would like to overlay the right
hand page in the JPEG with quotations, like "We learn from failure, not from
success! - Bram Stoker, Dracula". Now, I realize that I could use a drawing
program to add the text of the quotation to the graphic but I am wondering
if I can accomplish the same result vi HTML and/or CSS?

I can imagine placing the JPEG at an appropriate spot on a page and writing
the quote in the HTML and then using CSS to force the text to be within the
appropriate area of the right hand page of the JPEG. I'm not sure if this
can be done though or how to do it if it is possible.

Can anyone suggest the best technique?

I'd like to have the book JPEG on a few different pages of my site and be
able to change the actual quotes regularly by simply altering the quotes in
the HTML.

--
Rhino



jim
Guest
 
Posts: n/a
#2: Apr 19 '06

re: How can I do this?


Rhino,
Yes, this is very easily possible. There are a variety of ways, but
I'll try and point you in the easiest direction.

You will need two pairs of html page elements which are <div></div>
tags.
Between one set of div-tags is where you'll put your jpg image coding
eg:
<div>
<img src="book.jpg" />
</div>

Inside the other set of div-tags you can put your text:
eg:
<div>
<p> put your quotation or comment here</p>
</div>

Now comes the fun part with the css; this will be an inline style
versus putting the css rules within <style> tags in the <head> section
of your html document.

To use an inline style, you type style=" " inside the first 'opening'
element
eg:
<div style=" " >

Between the quotes is where you put your style rules which tell the web
browser the rules and ways you want that
tag or element to be shown to your web page visitors. inline style
rules need to follow this recipe:
style="rule:property; rule:property; rule:property"
note the colons and semi-colons which must appear for the style to be
used.

Now, let's set up the rules and properties for your div tags to make
them look how you want them!

Div-tags or boxes can be positioned anywhere on your html page.
"Absolute" positioning
means you plop them at a location and it will not move. "Relative"
positioning allows the box to move depending on other page elements.
You want to use absolute positioning for your two div boxes so that
they stay put.
eg:
<div style="position:absolute;">

Of course to go along with positioning is *where* to position things.
You give the div a left and top coordinate: how many pixels from the
left of the page and how many pixels down from the top of the page you
want the upper left corner of your div box to appear.
eg:
<div style="position:absolute; left:10px; top:10px;">

** IMPORTANT ** : You will have to play-with and alter your left and
top coordinates a bit to make sure your image and text line up where
you want them.

Last item about div positioning: you can put them in layers with one
behind the other. how? you give them a z-index. An index of '1' puts
that div-box in the background. The higher the z-index the more visible
in the fore-front that div-box will be.

For your purposes, you'll want the div holding your image to be in the
background, so it should have a z-index of '1'. You want your text to
be seen in the foreground, so it should have a higher z-index; you can
give it '2' or '10' or '100' as long as it is higher than the div
holding your image.

In this way, using div-box elements, absolute positioning, and
assigning a z-index value, you can literally "layer" or stack images
and text upon one another (note: this does not work using applets,
sound, movie, flash or any type of object/embed html tags).

Here's one example of how you might want to setup your code:
------------------------------------------------------
<div id="imageholder" style="position:absolute; left:50px; top:50px;
z-index:1">
<img src="book.jpg"/></div>

<div id="textholder" style="position:absolute; left:100px; top:100px;
z-index:10">
<p>We learn from failure, not from success! - Bram Stoker, "Dracula".
</p>
</div>
------------------------------------------------------
Keep in mind that you can change the left and top values in the div
styles above to 'move' them around on the web page; First determine
where you want your jpg image to appear on the page and get the left &
top coordinate values set for it. Then, change your quote-holding
div's left and top coordinates so that your quote sits right on top of
the image, in the area (ie: the right 'page' of the image) you want it.


Hope this info is helpful; there are other more complicated ways to do
this using formal css rules and styles and background images etc.
There can be a much more detailed and technically oriented explanation
of this process, but for your use and understanding right now, I tried
to scale it down a bit. Hopefully this is easier to understand and
will give you a non-frustrating easy transition into the fun world of
html style-sheets.

-Jim

frederick@southernskies.co.uk
Guest
 
Posts: n/a
#3: Apr 19 '06

re: How can I do this?


Rhino wrote:[color=blue]
> I have a large JPEG showing an open book and would like to overlay the right
> hand page in the JPEG with quotations, like "We learn from failure, not from
> success! - Bram Stoker, Dracula". Now, I realize that I could use a drawing
> program to add the text of the quotation to the graphic but I am wondering
> if I can accomplish the same result vi HTML and/or CSS?
>
> I can imagine placing the JPEG at an appropriate spot on a page and writing
> the quote in the HTML and then using CSS to force the text to be within the
> appropriate area of the right hand page of the JPEG. I'm not sure if this
> can be done though or how to do it if it is possible.[/color]

Put the JPEG in as the background image for a div element, and then
nest the content within that. For example:

..image {height: 100px; width: 140px; background-image: url(image.jpg);}
..text {position: relative; top: 10px; left: 30px;}

<div class="image">
<div class="text">
text goes here
</div>
</div>


--
AGw.

Spartanicus
Guest
 
Posts: n/a
#4: Apr 19 '06

re: How can I do this?


"Rhino" <no.offline.contact.please@nospam.com> wrote:
[color=blue]
>I have a large JPEG showing an open book and would like to overlay the right
>hand page in the JPEG with quotations, like "We learn from failure, not from
>success! - Bram Stoker, Dracula". Now, I realize that I could use a drawing
>program to add the text of the quotation to the graphic but I am wondering
>if I can accomplish the same result vi HTML and/or CSS?
>
>I can imagine placing the JPEG at an appropriate spot on a page and writing
>the quote in the HTML and then using CSS to force the text to be within the
>appropriate area of the right hand page of the JPEG. I'm not sure if this
>can be done though or how to do it if it is possible.[/color]

Mmmh, pretty inflexible.
http://homepage.ntlworld.ie/spartanicus/Book/index.htm

--
Spartanicus
Nije Nego
Guest
 
Posts: n/a
#5: Apr 20 '06

re: How can I do this?


On 19 Apr 2006 09:18:03 -0700, jim wrote:
[color=blue]
> Rhino,
> Yes, this is very easily possible. There are a variety of ways, but
> I'll try and point you in the easiest direction.[/color]
- cut[color=blue]
>
> -Jim[/color]

Very thorough and informative reply.
This is exactly why I love NG.

--
o'tom po'tom
Rhino
Guest
 
Posts: n/a
#6: Apr 22 '06

re: How can I do this?


A belated thanks to you all for your very helpful replies and suggestions!

I got the effect I wanted and it was surprisingly easy as a result of your
clear explanations.

--
Rhino


Closed Thread