加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

html体小于其内容

发布时间:2020-12-14 16:45:52 所属栏目:资源 来源:网络整理
导读:这是问题的基本 illustration: htmlheadstyle type="text/css" html {width: 100%; height: 100%; background: red;} body {width: 100%; height: 100%; background: green;} .leftbar,.rightbar {height: 100%; background: blue;} .leftbar{float: left;}
这是问题的基本 illustration:
<html><head><style type="text/css">
 html {width: 100%; height: 100%; background: red;}
 body {width: 100%; height: 100%; background: green;}
 
 .leftbar,.rightbar {height: 100%; background: blue;}

 .leftbar{float: left;}
 .rightbar {float: right;}

 table {width: 100px; height: 800px; background: black; color: white;
     margin: 0 auto 0 auto;}
</style></head>
<body>
 <ul class="leftbar"><li>one</li><li>two</li></ul>
 <ul class="rightbar"><li>alpha</li><li>beta</li></ul>
 <table><tbody><tr><td>blah blah</td></tr></tbody></table>
</body>
</html>?

我们可以立即看到浮动的ul元素与包含它们的物体一样高,问题是物体不像它所包含的物体那么高.

如何让身体足够大?在这个例子中,我希望左栏和右栏一直向下,只要滚动允许,所以你永远不会看到它们下面的任何空隙.

解决方法

从身体规则中删除高度:100% – 这使得身体与视口高度一样高(小于内容高度).

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读