Solved

Variable in CSS

Posted on 2015-02-19
3
78 Views
Last Modified: 2015-02-19
Hi Experts,

Is it possible to use variables in CSS? For example, if I want to set the width to couple of elements to the same value, can I do this in one place?

Thank you
0
Comment
Question by:APD_Toronto
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 250 total points
ID: 40619461
Nope.  CSS does not support variables.  Some people get around this using their server side language like PHP to process their CSS files.  Or they set things using javascript.
0
 
LVL 43

Assisted Solution

by:Chris Stanyon
Chris Stanyon earned 250 total points
ID: 40619477
You could use one of the CSS extension frameworks such as SASS or LESS. Otherwise, as Dave says, build your CSS dynamically using PHP - fairly straight forward to do.
0
 

Author Closing Comment

by:APD_Toronto
ID: 40619490
Thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
BG appearing and then disappaear after a second 8 56
Change color in a check box 8 34
Word Press Fixes to Google Speed Test Issues 2 48
Display Flex does not Wrap Items 2 43
This article discusses how to create an extensible mechanism for linked drop downs.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question