1

I'd like to detect whether the web page is flowing over the Y axis, aka it is higher than the display and if so, affect styles.

I am looking for a purely CSS solution, or as close to that as possible.

How would I do this?

Lucien
  • 776
  • 3
  • 12
  • 40
  • Possible duplicate of [Determine if an HTML element's content overflows](http://stackoverflow.com/questions/143815/determine-if-an-html-elements-content-overflows) – fnune Jan 28 '16 at 17:25
  • @FaustoNA, I was looking for a purely CSS solution, such as a media query though. As far as I know, this hasn't been asked before. – Lucien Jan 28 '16 at 17:32

2 Answers2

4

I am looking for a purely CSS solution [...] such as a @media query

In standards-based (real-world) web development, @element queries (as opposed to @media queries) are still hypothetical.

If they weren't, your CSS-only solution could be something like:

@element body and (min-height: 101vh) {

[... STYLES HERE...]

}

In the meantime, read:

Element Queries for CSS by Tommy Hodgins (September 30, 2015)

and have a look at

eqCSS on Github


Further Reading:

Rounin
  • 27,134
  • 9
  • 83
  • 108
0

Years have passed since this was asked and answered. We now have CSS container queries, which would be the equivalent of the 'element queries' mentioned in the original answer.

https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Container_Queries

There are some great YouTube videos on this!

Lee Cichanowicz
  • 101
  • 1
  • 6