Hi, I've the following problem. It should work but it doesn't. On my webpage is the following PHP code: <div class="{$adsense_class}"> <p>Some adsense code here</a> </div> Code (markup): My CSS code is like this: .adsense { float: right; padding: 1em; background-color: gray; margin: 0 0 1em 3em; } .160by600 { width: 160px; height: 600px; } Code (markup): My page managed to print out the following HTML. But somehow only .adsense is working. .160by600 isn't. Any idea why? <div class="adsense 160by600"> <p>Some adsense code here</a> </div> Code (markup):
Well for start, you can't have two classes on one div (which looks like you're trying to do?) Secondly, shouldn't the php code look more like this: <div class="<?php echo $adsense_class; ?>"> <p>Some adsense code here</a> </div> Code (markup): And then the class specified like so: <?php $adsense_class = adsense; ?> Code (markup): I don't see where it is you're trying to place the width of the ad, and I'm not sure why you're doing it this way. Please elaborate so we can help you more.
Well, actually there can be multiple classes to a tag. It's a cool tip. In my case, all my ads are floated right. Depending on how much space my content takes up, php will generate the appropriate class for ad size, together with the float property.
Wrong. He'd already have the adsense variable set, and is being called by a template engine like thing called "Smarty". I dislike it - too slow, but it'd be what he is using. Did that fix the problem, though? Cheers
Thanks. It solved it. Anyway, I'm not using Smarty. Will be just having the adsense code in their individual php files and including them when needed. I'm only using very simple logic codes.
It's also a handy thing to know if you are using a javascript to manipulate your content. Instead of going through and changing the display state, you can use a fixed class for general style info, and a second class that you swap to change it's state. That's how my accordion Javascript works. I have a set of classes that start with s_. s_radio# makes it part of a radio set, I swap s_expanding, s_expanded, s_shrinking and s_shrunk to change the state, while s_content tells me the box it's on is to be styled as a shrinking box. http://battletech.hopto.org/html_tutorials/accordion
to only have one class that did the same thing as two classes combined, would require more lines of code in your css...there'd be overlapping attributes. Note: I realize that statement in itself made no sense...so here's trying to clarify... Take tabular data rows for example (I may want to distinguish odd/even rows and regular or bolded text & numbers separately) Instead of creating .oddtext, .oddnum, .eventext, .evennum classes... I'd create .odd, .even, .text, .num and they wouldn't have overlapping attributes like the first 4 would. I usually do this when I'm applying styles dynamically, shooting through a loop