Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-07-2007, 09:13 AM   PM User | #1
Pyrofire
New Coder

 
Join Date: Jan 2007
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Pyrofire is an unknown quantity at this point
CSS class concat

how do i join 2 classes into a single one?

like say i've got..

.strRed { color:red; }
.bgBlack { background:#000; }

i want to do something like

.Combined strRed bgBlack { border:1px solid orange; }

it will join those 2 classes, and add a border. how do i do that?
Pyrofire is offline   Reply With Quote
Old 08-07-2007, 09:39 AM   PM User | #2
ahallicks
Senior Coder

 
ahallicks's Avatar
 
Join Date: May 2006
Location: Lancaster, UK
Posts: 1,134
Thanks: 1
Thanked 57 Times in 55 Posts
ahallicks is on a distinguished road
You can apply as many classes to one element as you wish:

<div class="strRed bgBlack">Your div</div>

So you could create a class for that border, or to simplify it why don't you just create a new one that has all of the style rules you need, rather than using bits and pieces from other styles to build an element that follows a different style set?
__________________
"write it for FireFox then hack it for IE."
Quote:
Originally Posted by Mhtml View Post
Domains are like women - all the good ones are taken unless you want one from some foreign country.
Reputation is your friend

Development & SEO Tools
ahallicks is offline   Reply With Quote
Old 08-07-2007, 09:53 AM   PM User | #3
Arbitrator
Senior Coder

 
Arbitrator's Avatar
 
Join Date: Mar 2006
Location: Splendora, Texas, United States of America
Posts: 2,931
Thanks: 6
Thanked 194 Times in 191 Posts
Arbitrator is on a distinguished road
Quote:
Originally Posted by Pyrofire View Post
how do i join 2 classes into a single one?
To match an element that must have two class names, you would use the code shown below.

Code:
.className1.className2 { /* declarations */ }
Do note that this CSS feature is not supported in Internet Explorer 6. My memory is hazy, but I believe that the above rule would match all elements with .className2, regardless of whether or not they are also in .className1, in that browser.

Quote:
Originally Posted by Pyrofire View Post
like say i've got..

.strRed { color:red; }
.bgBlack { background:#000; }
Presentational class names are bad. If you’re going to do that, you may as well just put the CSS inline with the HTML or not use CSS at all, since you’ll end up having to change both the CSS selector and HTML class attribute every time that you want to change the presentation. Use class names that describe content, not presentation.
__________________
Please for the love of god stop making IE. You current "browser"s cause me to cry every day. —Phil *
Arbitrator is offline   Reply With Quote
Old 08-07-2007, 10:10 AM   PM User | #4
Pyrofire
New Coder

 
Join Date: Jan 2007
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Pyrofire is an unknown quantity at this point
i very well know i can do it on the html object, but i want to do it in the CSS.
Pyrofire is offline   Reply With Quote
Old 08-07-2007, 11:46 AM   PM User | #5
Jutlander
Regular Coder

 
Jutlander's Avatar
 
Join Date: Jun 2007
Location: In my own sick little world :P
Posts: 425
Thanks: 1
Thanked 12 Times in 12 Posts
Jutlander is on a distinguished road
Join them? Like this or what?

Code:
.newclassname {
color: red;
background: #000;
}
__________________
.
.
Jutlander is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:17 PM.


Advertisement
Log in to turn off these ads.