Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within HTML Pages with CSS and JavaScript
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
HTML Pages with CSS and JavaScript
CSS question
colin shuker
Ranch Hand
Posts: 750
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi, I have several images that use an ID:
<style type="text/css"> #mover0 {position: absolute; left: 0px; top: 0px;} #mover1 {position: absolute; left: 0px; top: 80px;} #mover2 {position: absolute; left: 0px; top: 160px;} </style>
These are displayed with
document.write("<DIV id='mover0'>"); document.write("<IMG etc etc etc"); document.write("</DIV>");
<br /> <br /> But what I want to do is have N different images under the ID's mover0,mover1,...mover(N-1) <br /> <br /> I don't know if I can do this inbetween the style tags, can anyone help? Thanks>
Eric Pascarello
author
Posts: 15385
6
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
set the position with just JavaScript and skip the css.
Eric
colin shuker
Ranch Hand
Posts: 750
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks, I thought about that, but then stopped thinking about it.
I just tried
// ON AND OFF IMAGES tabOn = new Image(200, 80); tabOn.src = "tabOn.png"; tabOff = new Image(200, 80); tabOff.src = "tabOff.png"; var t0 = new Image; var t1 = new Image; var t2 = new Image; t0.src = tabOn.src; t1.src = tabOff.src; t2.src = tabOff.src; t0.style.left = 0; t0.style.top = 0;
Then I put name="t0" in the IMG tag for t0 image.
It doesn't seem to work though, I'm not sure what I'm doing wrong, I need absolute positioning also.
Any ideas?
colin shuker
Ranch Hand
Posts: 750
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I think I've done it now
IMG STYLE="position:absolute; TOP:0px; LEFT:0px; WIDTH:200px; HEIGHT:80px" SRC="circle.gif"
And I can change position on mouse click with
document.images[chosen].style.left = 10;
So I should be ok now. Thanks
Eric Pascarello
author
Posts: 15385
6
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
var myElement = document.getElementById("ElementId"); myElement.style.top = "100px"; myElement.style.left = "200px";
Eric
I am displeased. You are no longer allowed to read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Can't get CSS Positioning right
Please wait massage with database connection
jQuery and layering Divs
Clickable Div Background image
Converting table to divs
More...