<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Rails Forum - Ruby on Rails Help and Discussion Forum - Dynamically change css value]]></title>
		<link>http://railsforum.com/viewtopic.php?id=31376</link>
		<description><![CDATA[The most recent posts in Dynamically change css value.]]></description>
		<lastBuildDate>Wed, 16 May 2012 13:27:04 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Dynamically change css value]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=152536#p152536</link>
			<description><![CDATA[<p>&lt;style&gt;<br />&nbsp; &nbsp;#header {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; background-image: url(/images/&lt;%=h current_user.background_image %&gt;);<br />&nbsp; &nbsp; &nbsp;}<br />&lt;/style&gt;</p><br /><p>This works perfectly for me. Thanks for the reply.</p>]]></description>
			<author><![CDATA[dummy@example.com (trupti@joshsoftware.com)]]></author>
			<pubDate>Wed, 16 May 2012 13:27:04 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=152536#p152536</guid>
		</item>
		<item>
			<title><![CDATA[Re: Dynamically change css value]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=101786#p101786</link>
			<description><![CDATA[<div class="quotebox"><cite>Neil wrote:</cite><blockquote><p>Being an inline-style, this could be considered hackish - but it could work;</p><p><pre name="code" class="css:nogutter">&lt;div id=&quot;header&quot; style=&quot;background-image:url(/images/&lt;%=h current_user.background_image %&gt;);&quot;&gt;<br />&nbsp; # Your header contents<br />&lt;/div&gt;</pre><br />There might be another way with javascript or SASS, but I only use straight CSS at the moment - perhaps someone else could advise on that. And if you&#039;re doing anything more advanced than this with regards to customising the view via user preferences, you might want to start investigating templating systems such as Liquid.</p></blockquote></div><p>I rather go with putting all style (that need to be somewhat dynamic) in &lt;style&gt;-tags in the page header (under the css-links) and not in the code. <br /><pre name="code" class="ruby:nogutter">&lt;style&gt;<br />&nbsp; &nbsp;#header {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; background-image: url(/images/&lt;%=h current_user.background_image %&gt;);<br />&nbsp; &nbsp; &nbsp;}<br />&lt;/style&gt;</pre></p>]]></description>
			<author><![CDATA[dummy@example.com (AndreasE)]]></author>
			<pubDate>Wed, 24 Jun 2009 20:40:06 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=101786#p101786</guid>
		</item>
		<item>
			<title><![CDATA[Re: Dynamically change css value]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=99844#p99844</link>
			<description><![CDATA[<p>Oo..this is something that I&#039;m looking for. Thanks much Neil.</p>]]></description>
			<author><![CDATA[dummy@example.com (rambo)]]></author>
			<pubDate>Fri, 05 Jun 2009 00:21:18 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=99844#p99844</guid>
		</item>
		<item>
			<title><![CDATA[Re: Dynamically change css value]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=99771#p99771</link>
			<description><![CDATA[<p>Being an inline-style, this could be considered hackish - but it could work;</p><p><pre name="code" class="css:nogutter">&lt;div id=&quot;header&quot; style=&quot;background-image:url(/images/&lt;%=h current_user.background_image %&gt;);&quot;&gt;<br />&nbsp; # Your header contents<br />&lt;/div&gt;</pre><br />There might be another way with javascript or SASS, but I only use straight CSS at the moment - perhaps someone else could advise on that. And if you&#039;re doing anything more advanced than this with regards to customising the view via user preferences, you might want to start investigating templating systems such as Liquid.</p>]]></description>
			<author><![CDATA[dummy@example.com (Neil)]]></author>
			<pubDate>Thu, 04 Jun 2009 10:32:59 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=99771#p99771</guid>
		</item>
		<item>
			<title><![CDATA[Re: Dynamically change css value]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=99730#p99730</link>
			<description><![CDATA[<p>Thanks johnson, I was thinking of using javascript but Im next to zero when it comes to javascript. Neil, your solution looks great. But what about if user upload their own header ? it is like user can change the header. Looking forward to hear from you. Thanks in advance.</p>]]></description>
			<author><![CDATA[dummy@example.com (rambo)]]></author>
			<pubDate>Thu, 04 Jun 2009 00:02:13 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=99730#p99730</guid>
		</item>
		<item>
			<title><![CDATA[Re: Dynamically change css value]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=99699#p99699</link>
			<description><![CDATA[<div class="quotebox"><cite>rambo wrote:</cite><blockquote><p>Ok, I have a website where there is a need to change the header background dynamically. I dont know how exactly am i going to do this. What im trying to do now is, in my css, for example;</p><p>#header{<br /> background-image: url(/images/&#039;#{some-header-picture}&#039;)<br /> }</p><p>I know above code is not working. Just curious is there any way to do achieve this ?</p></blockquote></div><p>Are you trying to show a different background image in your header depending on which part of the site the user is viewing? If so, you could do something like;</p><p><pre name="code" class="ruby:nogutter">&nbsp; &nbsp; &lt;div id=&quot;header&quot; class=&quot;&lt;%= params[:controller] %&gt;&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; # Your header contents<br />&nbsp; &nbsp; &lt;/div&gt;</pre><br />...and your CSS would look like;</p><p><pre name="code" class="css:nogutter">#header.users { background-image: url(/images/header_users.png) }<br />#header.songs { background-image: url(/images/header_songs.png) }<br />#header.artists { background-image: url(/images/header_artists.png) }</pre></p>]]></description>
			<author><![CDATA[dummy@example.com (Neil)]]></author>
			<pubDate>Wed, 03 Jun 2009 15:59:00 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=99699#p99699</guid>
		</item>
		<item>
			<title><![CDATA[Re: Dynamically change css value]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=99669#p99669</link>
			<description><![CDATA[<p>javascript</p>]]></description>
			<author><![CDATA[dummy@example.com (Johnson)]]></author>
			<pubDate>Wed, 03 Jun 2009 11:51:11 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=99669#p99669</guid>
		</item>
		<item>
			<title><![CDATA[Dynamically change css value]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=99640#p99640</link>
			<description><![CDATA[<p>Ok, I have a website where there is a need to change the header background dynamically. I dont know how exactly am i going to do this. What im trying to do now is, in my css, for example;</p><p>#header{<br /> background-image: url(/images/&#039;#{some-header-picture}&#039;)<br /> }</p><p>I know above code is not working. Just curious is there any way to do achieve this ?</p>]]></description>
			<author><![CDATA[dummy@example.com (rambo)]]></author>
			<pubDate>Wed, 03 Jun 2009 09:41:25 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=99640#p99640</guid>
		</item>
	</channel>
</rss>
