Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2009-05-14 05:00:26
- darock
- Member
- Registered: 2007-11-23
- Posts: 54
how to show different background for a div when visiting a new section
I want a different background image to show for a div on my website whenever a user visits a new section of the site. For example, if they visit section A, then I would want a certain background-image pulled from the css to appear. And then section B would have another background image for that div, etc… How do I do this?
Offline
Re: how to show different background for a div when visiting a new section
You could use this:
<div class="section_<txp:section title="0" link="0"/>"></div>
And add this to CSS:
div.section_SECTIONname {background: url(lalala.jpg);}
Or, instead of applying custom class to div you can dirrectly set background image:
<div style="background: url(section_<txp:section title="0" link="0"/>.jpg);"></div>
And don’t forget to upload img section_SECTIONname.jpg
to your server.
Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?
Offline
Re: how to show different background for a div when visiting a new section
I usually create an id or class at the body level:
<body id="section_<txp:section title="0" link="0"/>">
So you can apply different css styles without the need to apply this technique in different subelements. Example css:
#section_one h1 {color: red}
#section_one .thediv {background-color: red}
#section_two h1 {color: blue}
#section_two .thediv {background-color: blue}
Offline
Re: how to show different background for a div when visiting a new section
Might be worth pointing out that by default, the section tag title
and link
attributes are set to “0”…
Offline
Re: how to show different background for a div when visiting a new section
jstubbs wrote:
Might be worth pointing out that by default, the section tag
title
andlink
attributes are set to “0”…
Textbook says this attrs will be set to "1"
from Crockery (4.1), though it’s better to be ready
Last edited by the_ghost (2009-05-14 12:45:59)
Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?
Offline