开发者

Use device-width in CSS? JS possibilities?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜