Css Image Replacment - using CSS to change the image path

free web hosting
Open Discussion > CONTRIBUTE > Computers > Programming Languages > CSS (Cascading Style Sheets)

Css Image Replacment - using CSS to change the image path

moldboy
I was wondering if it is possable to change the path to an image using CSS, so that I could provide a sort of template system rather then having to change a bunch of thing I could have astandard page and then by changing the external CSS I could change not only styles but the whole image, I soo how I could change the background-color { url(image.gif)} but whatabout an actual image say change the src of an img tag?

Reply

mizako
I do not think that what you want to do it is possible. CSS is a style sheet for elements. An img tag it is itself an element and the src attributte has to be in the image tag inside of your XHTML code. Maybe you can use a div element and position your image as a background image for this element. This way by changing the style sheet you can change the image src.

Reply

Tyssen
I've been thinking about doing something similar recently. My thoughts were that if you wanted to change the background image of an element dynamically (say randomizing a background image) that you'd javascript or PHP or ASP to generate a different internal line of CSS code inside your HTML document, e.g. create an array with a set of URLs and then use your script to print out
CODE
<style type="text/css">
element { background: url(images/randomimage.jpg); }
</style>

Well, something like that anyway.

Reply

SystemWisdom
You should really check out Brain Jar..

Click the Home menu, then go down the menu to Customize and select one of the themes.. You'll notice that the theme changes completely including background images...

This is all done with seperate CSS style sheets for each theme, and simply changed to point to a different style sheet for each theme..

The site even has alot of tutorials including how to change your sites theme using CSS (pure client-side themes)..

Anyway, I hope that helps!

Reply

moldboy
QUOTE
You should really check out Brain Jar..

You know that's exactly what I want except without the menu, but for the user to change the themes.

Now I was also looking at his code and sort of came to the conclusion that is isn't all CSS though, because as was mentioned in the above postings that css can't change the img tag src, so I got to wondering how did he change the floating brain image according to the style chosen, I would assume it has something to do with the style variable defigned in the setscheme.asp file, now there is another story I wouldn't have aclue how to set the scheme using an external file, nor how to do it with asp, but I assume it could be done with php, so let's say I have a file that contians a bunch of information recarding what css to use and what image where:
CODE

//Default theme
$css = "default/default.css";
$bannerimage = "default/banner.gif";
//and so on a so forth

then in my site I would have a code that depending on the ?style= command it would include the above file at the top so:
CODE

if style="default"{
include default_theme.php;
}
//then you would have a bunch of other if's and what to do if there was no style defination
echo "<html><head><title>here it is!</title><link href="" . $css . "" rel="stylesheet" type="text/css" />";

and so on a so forth with the rest of the site, so when the style is style=defaule the default_theme.php is called which provides the file with the variables like $css

Do you think that might work, also how would I keep that style even through the rest of my pages?

 

 

 


Reply

someguy
You could only do this by changing a bg image, usually the bg image of the whole page, a table or a cell. You could do this by saving one css file as 'imagestyle.css and have this in it:

CODE
.style1 { background: url(images/yourimage.gif)}


and then you could insert this into the <HEAD> of your HTML file:

CODE
<LINK rel="stylesheet" type="text/css" href="imagestyle.css">


and put this in the table cell of which you want the image. NOTE you should change the width and height values to the width and height values of your image
CODE

<TD width="100" height="100" class="style1">&nbsp</TD>



and this should work or you could;

Use an external javascript to display an image,

Use a random image script and only add the image you want to be shown

Or simpily change the picture but keep the same filename. But if you choose this method the new image would have to be the same size in pixels other wise it will have to be streched.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Recent Queries:-
  1. css image linked chenge - 0.07 hr back. (1)
  2. css change img title - 0.16 hr back. (1)
  3. css image path - 0.67 hr back. (1)

  4. change image - 1.34 hr back. (1)
  5. css set source of image - 2.43 hr back. (1)
  6. css change image source - 5.68 hr back. (1)
  7. css change image src - 7.26 hr back. (1)
  8. css change source for img - 13.82 hr back. (1)
  9. change image in a table with css - 16.36 hr back. (1)
  10. "img" "change image" "css" - 17.51 hr back. (1)
  11. css image source - 1.25 hr back. (6)
  12. change src img css - 20.03 hr back. (1)
  13. image source in css - 20.10 hr back. (1)
  14. specify img src in css file - 22.45 hr back. (1)
Similar Topics

Keywords : css, image, replacment, css, change, image, path

  1. Problem Aligning In Firefox
    Problem aligning an image in Firefox. (9)
  2. Link Image Css Bug In Firefox
    Can anyone help me? (7)
    I have a problem in a site I am creating. I have styled my post content links in the following
    way. CODE #post-content a {     background-color: #bf6f3c;     color: #fff;
        padding: 2px 2px 1px 2px;     border-bottom: 1px solid #7f4926; } #post-content
    a:hover {     color: #f5fac7; } And when I insert an link image like so: There
    seems to be an extra border inherited from my #post-content a style. I have attached the screenshot
    to show the problem. This was how my link image should look like: CODE #post-content a img { ....
  3. Centering A Div Containing Image.
    I have a logo I need centered in a aujustable width page (9)
    http://sonesay.trap17.com/sonesayi/ Just a new layout I'm working on, Any ideas how I can get
    the logo to be centered? At the moment I can only float it left or right. I think is possible to get
    it done in tables but I would prefer to stay away from them in layouts. Any insight appreciated. by
    the way source code and css is at http://sonesay.trap17.com/sonesayi/index.html
    http://sonesay.trap17.com/sonesayi/main.css thanks ....
  4. Centering Background Image In Css
    (8)
    Well, the title says what I need. Basically, I want a background image that can be used in the body
    or inside a div (or table), which is centered.....
  5. Css Image Position Problem
    align image left or right (1)
    I am having problems figuring out why my image will not align how I want it. Here , you can see
    that the image is aligned to the left. This is the code for that block: CODE <a
    href="http://img355.imageshack.us/img355/844/r25870774779uu.jpg"><img
    src="http://img355.imageshack.us/img355/844/r25870774779uu.th.jpg" alt="bush
    bathroom break note" align="left" style="margin-right:
    5px;"></a>[text goes here] But if you go here , you can see that the
    text does not stay to the right of....

    1. Looking for css, image, replacment, css, change, image, path

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for css, image, replacment, css, change, image, path

*MORE FROM TRAP17.COM*
advertisement



Css Image Replacment - using CSS to change the image path



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE