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.!!!
IoT mobile apps, the next big thing for current COVID-19 and future pandemics [Ultimate Guide]
In times where technology is a part of our everyday routine, the extension of its features to everyday devices is a peek into a futuristic world. For instance, when the pandemic struck, the need for remote monitoring was on the rise, more than ever. Gathering resources and medicines, consultation with doctors, monitoring of beds had […]
Healthcare mobile app development for organizations to address the disruption caused by the pandemic
In an increasingly convenient world where groceries, food, clothes are available at the click of a button, it was the healthcare sector that quite remained rooted to its traditional ways. However, since the onset of the pandemic, social distancing and other preventive measures, the usage of healthcare apps has seen a significant boost. Patients and […]
Mobile application Development Trends in 2021 in the Post-Pandemic Environment
The COVID-19 pandemic has exponentially triggered a big-time financial crisis, hurting practically all domains of life, including travel & tourism, real estate, leisure activities, small local businesses, and the quality of life of every being. However, the crisis has given birth to the vital need for digital solutions and developments that would help people face […]