0

Is there a passive method (i.e. not JS) to make a div disappear, when its width is less than a certain value?

Something like...

.my-div[width < 120px] {
    display: none;
}

Edit #1

I'm already using media queries for responsive design, but the point at which I want to hide this div is in between two break points. I'll make another media query if I must, but I was hoping for some niche secret CSS trick.

Birrel
  • 4,754
  • 6
  • 38
  • 74
  • 2
    No, there isn't, not for an element. Media query's for the viewport is the closest. – Asons Apr 12 '19 at 18:28
  • Yeah I figured not. More media queries. – Birrel Apr 12 '19 at 18:32
  • Is there somewhere that people can submit suggestions for functionality to add to future CSS releases? Size-based selectors would be pretty handy to have. – Birrel Apr 12 '19 at 18:34
  • Also see: [Can media queries resize based on a div element instead of the screen?](https://stackoverflow.com/questions/12251750/can-media-queries-resize-based-on-a-div-element-instead-of-the-screen) – showdev Apr 12 '19 at 18:37
  • 1
    @showdev Great links ... linked both as a dupe/answer of/to this question. – Asons Apr 12 '19 at 18:38
  • 2
    For raising CSS suggestions, you might like to check out the [w3.org mailing list](https://www.w3.org/Style/CSS/current-work#contribute) and [Github working draft](https://github.com/w3c/csswg-drafts). You might be able to find existing discussions about similar issues. – showdev Apr 12 '19 at 18:40

0 Answers0