微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

弄乱了我的CSS

简而言之,我想要一个正确的div浮动垂直延伸100%
但它只适用于我不包含< doctype>在我的 HTML

在今天的标准中,我真的必须添加< doctype&gt ;? 这是Internet Explorer中的结果: 这只是简单的HTML

<html>
<head>
<style type="text/css">
html,body {
padding:0;
margin:0;
height:100%;
}
#wrap {
background:red;
height:100%;
overflow:hidden;
}
#left {
background:yellow;
float:left;
width:70%;
min-height:100%;
}
#right {
background:pink;
float:right;
width:30%;
min-height:100%;
}
</style>

<body>
<div id="wrap">
<div id="left"> Content </div>
<div id="right"> Side Content </div>
</div>
</body>
</html>

解决方法

in today’s standard,do i really have to add <doctype>?

您不必做任何事情,但缺少DOCTYPE基本上断言您(在最宽松的意义上)符合未知/不一致的“怪癖”标准.

我想解决方案就像将父容器的高度设置为100%或特定像素高度一样简单.

>确保在HTML和BODY元素上设置高度.
>确保在任何父容器上设置高度.

工作示例:http://jsfiddle.net/7xxFj/

<div id="one">
    First column
</div>
<div id="two">
    second column
</div>​

HTML,BODY { height: 100%; }
#one { height: 100%; width: 30%; float: left; background-color: red; }
#two { height: 100%; width: 70%; float: left; background-color: blue; }

正如@BoltClock在评论中指出的那样,您可能希望布局可以超出100%.这需要更多的努力(但仍然在标准内工作良好).

This article示出了用于实现具有相等列高度的布局的若干方法.更多methods here.

原文地址:https://www.jb51.cc/css/214026.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。