开发者

Use device-width in CSS? JS possibilities?

开发者 https://www.devze.com 2023-04-06 00:07 出处:网络
Is there any way to reference device-height and device-width in your CSS in order to center a div containing dynamic content of varying sizes (images)? Is it possible to use JS to get the effective vi

Is there any way to reference device-height and device-width in your CSS in order to center a div containing dynamic content of varying sizes (images)? Is it possible to use JS to get the effective viewport dimensions and 开发者_运维百科then reference them with SASS/LESS, or am I dreaming?


Here's a simple example of how to get the viewport with JavaScript: http://andylangton.co.uk/articles/javascript/get-viewport-size-javascript/

But I would suggest looking into CSS Media Queries: Detect screen width with CSS Media Queries

0

精彩评论

暂无评论...
验证码 换一张
取 消