The CSS language is full of small gaps which are frustrating to navigate. Between CSS properties to hide a container and its contents, there is still room for improvement. visibility: hidden keeps height and width integrity while display: none on a container hides everything. You can use .container > * to hide all contents of a […]
The post CSS content-visibility appeared first on David Walsh Blog.
The CSS language is full of small gaps which are frustrating to navigate. Between CSS properties to hide a container and its contents, there is still room for improvement. visibility: hidden
keeps height and width integrity while display: none
on a container hides everything. You can use .container > *
to hide all contents of a container, but what if there was a better way?
There is a better way to hide the contents of an element while respecting the container’s border and dimensions. That better way is using the content-visibility
property:
.my-container.contents-loading { content-visibility: hidden; }
A demo of such functionality:
See the Pen
Untitled by David Walsh (@darkwing)
on CodePen.
Avoiding a .container > *
selector by using content-visibility: hidden
is so much nicer from a maintenance perspective!
The post CSS content-visibility appeared first on David Walsh Blog.
Related Posts
Recommended Story For You :
![](https://clickaibank.co.in/cb-resources/img/homepage-foreground.jpg)
GET YOUR VINCHECKUP REPORT
![](https://clickaibank.co.in/cb-resources/img/645d006bb149e9165e0d11a6_MarketingBlocks-hero3-p-800.png)
The Future Of Marketing Is Here
![](https://clickaibank.co.in/cb-resources/img/charactersample.png)
Images Aren’t Good Enough For Your Audience Today!
![](https://clickaibank.co.in/cb-resources/img/wsfr_3.0_header_box.png)
Last copies left! Hurry up!
![](https://clickaibank.co.in/cb-resources/img/home_banner_image.png)
GET THIS WORLD CLASS FOREX SYSTEM WITH AMAZING 40+ RECOVERY FACTOR
![](https://clickaibank.co.in/cb-resources/img/home-feature-calendar.png)
Browse FREE CALENDARS AND PLANNERS
![](https://clickaibank.co.in/cb-resources/img/easyStep1.png)
Creates Beautiful & Amazing Graphics In MINUTES
![](https://clickaibank.co.in/cb-resources/img/bottom_bg.png)
Uninstall any Unwanted Program out of the Box
![](https://clickaibank.co.in/cb-resources/img/header_2222.jpg)