Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Style sheets, include one style within another (not inheritance)

Reply
Thread Tools

Style sheets, include one style within another (not inheritance)

 
 
foldface@yahoo.co.uk
Guest
Posts: n/a
 
      11-24-2003
Hi

Given something like this:

<style type="text/css">
DIV.allowLeft {clear: left;}
DIV.left {float: left;}
DIV.leftBig {float: left; width: 300}
DIV.rightBig {float: right; width: 300}
</style>

Is there anyway of placing the 'width:300' bit into another declaration
(pardon my terminology) so that I only have to change it in one place,
e.g. something like this:

<style type="text/css">
bigWidth = 300;
DIV.allowLeft {clear: left;}
DIV.left {float: left;}
DIV.leftBig {float: left; bigWidth}
DIV.rightBig {float: right; bigWidth}
</style>

The width is only going to apply to some divs

Thanks
F
 
Reply With Quote
 
 
 
 
Bertilo Wennergren
Guest
Posts: n/a
 
      11-24-2003
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> <style type="text/css">
> DIV.allowLeft {clear: left;}
> DIV.left {float: left;}
> DIV.leftBig {float: left; width: 300}
> DIV.rightBig {float: right; width: 300}
> </style>


> Is there anyway of placing the 'width:300' bit into another declaration
> (pardon my terminology) so that I only have to change it in one place,


"width:300" is an error (it has no meaning). You probably meant
"width:300px" (and some browsers will guess that - which they
shouldn't). You should howevere consider setting the width in "em"s
instead, particularily if the content is text.

> e.g. something like this:


> <style type="text/css">
> bigWidth = 300;
> DIV.allowLeft {clear: left;}
> DIV.left {float: left;}
> DIV.leftBig {float: left; bigWidth}
> DIV.rightBig {float: right; bigWidth}
> </style>


No variables in CSS. But you can do this:

<style type="text/css">
DIV.allowLeft {clear: left;}
DIV.left {float: left;}
DIV.leftBig, DIV.rightBig {width: 300px;}
DIV.leftBig {float: left;}
DIV.rightBig {float: right;}
</style>

You can also use multiple classes. Like this:

HTML:

<div class="leftBig whatever">...</div>
<div class="rightBig whatever">...</div>

CSS:

<style type="text/css">
DIV.allowLeft {clear: left;}
DIV.left {float: left;}
DIV.whatever {width: 300px;}
DIV.leftBig {float: left;}
DIV.rightBig {float: right;}
</style>

--
Bertilo Wennergren <(E-Mail Removed)> <http://www.bertilow.com>

 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I include an XML file within another XML file? Poirot XML 0 05-11-2011 12:57 PM
/* #include <someyhing.h> */ => include it or do not include it?That is the question .... Andreas Bogenberger C Programming 3 02-22-2008 10:53 AM
How do I include a server tag within a javascript parameter which is itself within a HTML element event? mark4asp ASP .Net 2 11-07-2006 06:23 AM
Include JSF page within another JSF page BlackIce Java 1 07-05-2006 11:24 PM
Passing value from one script on one page to another script on another page. Robert Cohen ASP General 3 07-15-2003 01:46 PM



Advertisments