Log in

View Full Version : applying code from stylesheet in style attribute



ahs10
02-22-2008, 08:30 PM
ok i have a div with css styling using the class attribute works fine. it references a class within a separate css stylesheet linked to the file, and all is well.

now i want to change some of that information with ajax, so i need to take the code from the stylesheet and put in in the page itself. so i copy the code, and use the style attribute instead of class. makes sense to me, however i'm obviously the only one that makes sense to... it's all jacked up, not even close.

how do i fix this? why is it different using the exact some code?

here's my code using the class attribute...

css -
.leftEdge {background:#000000 url(whatever.gif) repeat-y left top}

html-
<div class="leftEdge">

...that works fine, why doesn't this....

no css stylesheet

html-
<div style="background:#000000 url(whatever.gif) repeat-y left top">

i even tried to label everything, using background-repeat and background-position... still a no go. please help

boogyman
02-22-2008, 09:52 PM
that appears to be correct, but if you have your website live, could you give us the url so we can check it out? thanks

also remember when posting computer code to wrap it in
tags

Medyman
02-26-2008, 01:50 PM
is whatever.gif in the same directory as the page you're trying to use it on?

I know that seems simple but if you had it working in the external CSS, it makes me think that the relative path to whatever.gif isn't the same from your external CSS to the page you're adding it on.

marynorn
02-26-2008, 02:09 PM
<div style="background:#000000 url(whatever.gif) repeat-y left top">
Try
<div style="background-color:#000000; background-image:url(whatever.gif); background-repeat:repeat-y; background-position:left top;">