CSS variables, more accurately known as CSS custom properties, are landing in Chrome 49. CSS is going to be like a CSS pre-processor itself such as SASS, LESS in the future. CSS variables are now officially part of the CSS specification – details here.
CSSWG was experimenting about CSS variables since 2012 – details here . There is another news that Google has now joined Mozilla by supporting this great feature.
Playing with CSS Variables.
- How it works.
- Override CSS variables.
- Override CSS variables in media query.
- Browser support.
1- How it works.
I already mentioned that CSS variables are known as CSS custom properties.
Create a root class in CSS file.
Create a Variable ( You can declare anything in variable such as color, width .. )
Call your variables anywhere you want in that css file (you can replace ‘element’ with ‘body’ in this below code)
2) Override CSS Variables.
We can override all css variables – see the demo.
3- Override CSS variables in media query.
We can include the variables with a different value in media query break points.
you can replace ‘element’ with ‘body’ in this below code
5- Browser support.
Firefox: Version 31+ (Enabled by default)
Chrome: Version 49+ (Enabled by default).
Safari/IOS Safari: Version 9.1/9.3 (Enabled by default).
IE Edge: In development.
We can check browsers supporting details- can i use
Mozilla has posted an article about this – link
CSS had already introduced calculation features calc it is an amazing feature, another one is flex-box, now they have introduced a variable feature.
Without doubt, we can say CSS Variables will be a supreme feature in future, at the moment it works only in the latest version of browsers. Web developers are really excited with that CSS as it is going to be awesome.!!!
If you are in Jordan looking for app development support you should read this
From downloading a mobile app to visiting a brick-and-mortar store, customers today value every interaction with a brand. A great customer experience leaves a lasting impression in their minds about the happy and satisfying experience. Winning the customer experience race Every interaction offers a make-or-break opportunity for a brand to either build a loyal customer […]
Enhanced Efficiency & Optimized Cost of Project Development with Sweden Hybrid Model.
Going beyond the cost factor and striving to deliver quality, innovation and flexibility to its customers across the globe, Toobler introduced a Hybrid (Onshore and Offshore) Software Development Model. Huge popularity of the hybrid model is fuelled by scores of organizations choosing to keep design and architecture phases at geographic proximity. Driven by a customer-centric […]
7 Pro Tips: Network Like a Boss at GITEX 2019
The biggest tech show in the Middle East, North Africa & South Asia- GITEX Technology week takes place in Dubai World Trade Centre from Oct 6 – Oct 10. The opportunity to network with prospects, key decision-makers and business heads of the tech industry makes GITEX an unmissable event. What makes the show exceptional is […]