This is a discussion on Use of CSS Properties with Variables within the Web Design forums, part of the Web Designing & Development category; Advanced CSS with Variables: CSS Level 2 Recommendation effects the Web authors' community that has been requesting a way of ...
Advanced CSS with Variables:
CSS Level 2 Recommendation effects the Web authors' community that has been requesting a way of defining variables in CSS.
Variables allow to define stylesheet-wide values identified by a token and usable in all CSS declarations.
If a value is often used in a stylesheet - a common example is the value of the color or background-color properties - it's then easy to update the whole stylesheet statically or dynamically modifying just one variable instead of modifying all style rules applying the property/value pair.
Example:
The Same thing we can define in PHP also. For that thing firstly, you need to create php page for the content. Following example shows how:Code:[COLOR=#000000] # @variables { # CorporateLogoBGColor: #fe8d12; # } # # div.logoContainer { # background-color: var(CorporateLogoBGColor); # } [/COLOR]
Example:
[/COLOR]Code:[COLOR=#000000] <?php header("Content-type: text/css"); $color = "green"; // <--- define the variable echo <<<CSS /* --- start of css --- */ h2 { color: $color; /* <--- use the variable */ font-weight: bold; font-size: 1.2em; text-align: left; } /* --- end of css --- */ CSS; ?>
Bookmarks