RSS Amplifier

Bruce Taylor · Jul 19, 2024

Get The Screen Width & Height Without JavaScript

0
Sign in to vote or save

This site does not allow itself to be embedded. You can still read it on the original site — the toolbar below keeps your place in the directory.

Original source can be viewed at: css-tip.com Very neat and clever. @property --_w { syntax : '<length>' ; inherits : true ; initial-value : 100vw ; } @property --_h { syntax : '<length>' ; inherits : true ; initial-value : 100vh ; } :root { --w : tan ( atan2 ( var ( --_w ) , 1px ) ) ; /* screen width */ --h : tan ( atan2 ( var ( --_h ) , 1px ) ) ; /* screen height*/ /* The result is an integer…

Original source can be viewed at: css-tip.com

Very neat and clever.

@property --_w {
  syntax: '<length>';
  inherits: true;
  initial-value: 100vw;
}
@property --_h {
  syntax: '<length>';
  inherits: true;
  initial-value: 100vh;
}
:root {
  --w: tan(atan2(var(--_w),1px)); /* screen width */
  --h: tan(atan2(var(--_h),1px)); /* screen height*/
  /* The result is an integer without unit  */
}

Reply via email

Read on brootaylor.com

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.