View Full Version : CSS If Condtion?
TheInsaneManiac
10-04-2009, 08:20 PM
Is it possible to use if conditionals in CSS? Like template conditions, profile field conditionals, ect?
I don't think so, but you can try to make two ids, #first_user, #second_user and then use if in template.
<if condition="something == 0">
<sometag id="first_user"/>
<else />
<sometag id="second_user"/>
</if>
TheInsaneManiac
10-05-2009, 10:13 AM
I don't think so, but you can try to make two ids, #first_user, #second_user and then use if in template.
<if condition="something == 0">
<sometag id="first_user"/>
<else />
<sometag id="second_user"/>
</if>
Well I wanted to make it so that a profile field containing a background image link could be used in the CSS. This way the USER can decide the background.
Lynne
10-05-2009, 04:44 PM
Have you tried it? I would think that if you add the css inline - style="background: xxxxx"
TheInsaneManiac
10-05-2009, 06:45 PM
Have you tried it? I would think that if you add the css inline - style="background: xxxxx"
Yea I sent to the CSS manager and added $userinfo[field15] to the background url($userinfo[field15]), but it didn't work. It just made the url to http://www.website.com/$userinfo[field15]
Lynne
10-05-2009, 08:26 PM
Add it *inline*.
<div style="background: url($userinfo[field15])"> etc....
TheInsaneManiac
10-06-2009, 01:13 AM
Add it *inline*.
<div style="background: url($userinfo[field15])"> etc....
This is the overall background though. Like the forum body background.
EX:
body
{
background: #080B1C url(banner.jpg) no-repeat top center fixed;
color: #007DDA;
font: 11px verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;
margin: 0px;
padding: 0px;
height: 100%;
Lynne
10-06-2009, 04:34 AM
OK, so try it inline in the body tag. Just try it inline as opposed to putting it in the css area.
TheInsaneManiac
10-06-2009, 05:11 AM
OK, so try it inline in the body tag. Just try it inline as opposed to putting it in the css area.
What do you mean? Wouldn't this mean I would have to edit the body tag on EVERY template?
Lynne
10-06-2009, 02:14 PM
I was trying to figure out if it would work that way. If it does, then you can figure out how to go about it.
I think I'm not understanding what you are doing. You have a User Profile Field, and the user enters a color for the background? adn then you want that to effect the background on all your pages? What is the name of your background class that you need to change or is your background actually part of the body tag as you said above? If so, have you tried just seeing if it works inline for the body tag, or tried adding the class/css in the headerinclude template?
TheInsaneManiac
10-06-2009, 04:46 PM
I was trying to figure out if it would work that way. If it does, then you can figure out how to go about it.
I think I'm not understanding what you are doing. You have a User Profile Field, and the user enters a color for the background? adn then you want that to effect the background on all your pages? What is the name of your background class that you need to change or is your background actually part of the body tag as you said above? If so, have you tried just seeing if it works inline for the body tag, or tried adding the class/css in the headerinclude template?
Every single page I have has a background for it. Hence:
background: #080B1C url(banner.jpg) no-repeat top center fixed;
I want the members to be able to enter their background url into the profile field and them be able to see their background.
Lynne
10-06-2009, 04:51 PM
OK, so have you tried adding something to the headerinclude template like I suggested?
<style type="text/css">
body {
background: #080B1C url($bbuserinfo['fieldx']) no-repeat top center fixed;
}
</style>
Put it at the end, of course, to overwrite the css in the css file.
TheInsaneManiac
10-06-2009, 05:47 PM
syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /public_html/forum/includes/adminfunctions_template.php(3950) : eval()'d code on line 3
Got that after trying:
<style type="text/css">
body {
background: #080B1C url($bbuserinfo['field85']) no-repeat top center fixed;
}
</style>
Wayne Luke
10-06-2009, 05:50 PM
Can't use quotes between [] for variables in templates. Parsing issue.
Lynne
10-06-2009, 07:22 PM
Whoops, I knew that. Thanks, Wayne.
TheInsaneManiac
10-07-2009, 02:24 AM
Thanks guys! It works now.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.