如何让页面自动适应窗口? [英] How do I get a page to auto fit to a window?

查看:173
本文介绍了如何让页面自动适应窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚为一位朋友开始了我的第一个正确的HTML网站,我想知道如何才能让网站自动创建页面?



这是一个不需要滚动的景观设计。 应该将 body html 设置为 position:fixed; ,然后设置 right: left: top: bottom: 0; 。这样,即使内容溢出,它也不会超出视口范围。



例如:

 < HTML> 
< body>
< div id =wrapper>< / div>
< / body>
< / html>

CSS:

  html,body,{
position:fixed;
top:0;
bottom:0;
剩下:0;
right:0;
}

> JS Fiddle示例



警告:使用此方法,如果用户缩小窗口大小,内容将被剪切关闭。

I've just started my first proper HTML website for a friend, and I was wondering how I would be able to get the website to autofit the page?

It's a landscape design which needs no scrolling.

解决方案

You should set body and html to position:fixed;, and then set right:, left:, top:, and bottom: to 0;. That way, even if content overflows it will not extend past the limits of the viewport.

For example:

<html>
<body>
    <div id="wrapper"></div>
</body>
</html>

CSS:

html, body, {
    position:fixed;
    top:0;
    bottom:0;
    left:0;
    right:0;
}

JS Fiddle Example

Caveat: Using this method, if the user makes their window smaller, content will be cut off.

这篇关于如何让页面自动适应窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆