CSS外框高度自动适应
当有浮动float时,最外框会不跟随内容的高度而高;
解决办法一:
清除浮动 clear:both
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">
*{margin:0px;padding:0px;}
.wrap{background:red;width:1000px;margin:auto;}
.left,.right{float:left;height:50px;}
.left{width:960px;background:red;}
.right{width:40px;background:green;}
.clear{clear:both;}
</style>
</head>
<body>
<div class="wrap">
<div class="left"></div>
<div class="right"></div>
<div class="clear"></div>
</div>
</body>
</html>
解决办法二:
给最外框加 overflow:hidden; zoom:1;
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">
*{margin:0px;padding:0px;}
.wrap{background:red;width:1000px;margin:auto;overflow:hidden; zoom:1;}
.left,.right{float:left;height:50px;}
.left{width:960px;background:red;}
.right{width:40px;background:green;}
</style>
</head>
<body>
<div class="wrap">
<div class="left"></div>
<div class="right"></div>
</div>
</body>
</html>
解决办法三:
给外框加属性 content: "";display: table;line-height: 0;clear: both;
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">
*{margin:0px;padding:0px;}
.wrap:before, .wrap:after {content: "";display: table;line-height: 0;clear: both;}
.wrap:after {clear: both;}
.wrap {margin: 0 auto;width: 1000px;}
.left,.right{float:left;height:50px;}
.left{width:960px;background:red;}
.right{width:40px;background:green;}
</style>
</head>
<body>
<div class="wrap">
<div class="left"></div>
<div class="right"></div>
</div>
</body>
</html>
CSS最小高度与自适应高度并存
div{_height:200px; min-height:200px
/* 注释:两个放置不分前后顺序,兼容所有浏览器 */}

CSS外框高度自动适应的更多相关文章
- 纯CSS实现侧边栏/分栏高度自动相等
by zhangxinxu from http://www.zhangxinxu.com本文地址:http://www.zhangxinxu.com/wordpress/?p=694 一.为何要分栏高 ...
- 纯CSS兑现侧边栏/分栏高度自动相等(转)
这里直接介绍我认为的最佳的侧边栏/分栏高度自动相等方法.核心的CSS代码如下(数值不固定): margin-bottom:-3000px; padding-bottom:3000px; 再配合父标签的 ...
- 右边根据左边的高度自动居中只需要两行CSS就可以完成
右边根据左边的高度自动居中只需要两行CSS就可以完成 <style type="text/css" > div{ display: inline-block; vert ...
- textarea宽度、高度自动适应处理方法
textarea自动高度 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http: ...
- textarea 实现高度自动增长
有时候希望textarea 能够自动调整高度来适应输入的内容 网上看到了很多解决方案,比如动态创建一个隐藏的div,当用户输入的时候将textarea的内容绑定到div,由于div的高度会自动撑开,因 ...
- css修改input自动提示的黄色背景
css修改input自动提示的黄色背景 input:-webkit-autofill { background-color: #FAFFBD; background-image: none; -web ...
- css文字超出自动显示省略号
只针对单行文本有效: 01.针对块状元素 ul li{ width: 180px; text-overflow: ellipsis; white-space: nowrap;/*禁止自动换行*/ ov ...
- css+js实现自动伸缩导航栏
用css+js实现自动伸缩导航栏 需要达到的效果: 默认首页选中样式 设置鼠标滑过效果:颜色变化(#f60),宽度变化,字体变化 所涉及的知识点: 布局:float css: 元素状态切换(displ ...
- css 分栏高度自动相等
方法2: <div class="ticket_table"> <div class="ticket_l"> <h3>全票& ...
随机推荐
- Android:intent的基础
只有一个活动的应用也太简单了吧?没错,你的追求应该更高一点.不管你想创建多少 个活动,方法都和上一节中介绍的是一样的.唯一的问题在于,你在启动器中点击应用的图 标只会进入到该应用的主活动,那么怎样才能 ...
- sublime关闭自动打开上次的文件
菜单:Preferences->settings-User 在配置中加入: "hot_exit": false, "remember_open_files" ...
- fastjson的日期格式化
//SerializerFeature.WriteDateUseDateFormat 使用日期字段格式序列化(2017-01-01),而不是用时间戳表示日期 JSON.toJSONString(dat ...
- Reflector_8.3.0.93_安装文件及破解工具
Reflector_8.3.0.93_安装文件及破解工具 下载地址:http://pan.baidu.com/s/1jGwsYYM 约 8.9MB
- SharePoint 内容编辑器部件介绍
前言 在SharePoint的使用过程中,我们经常会往页面中插入一些东西,这时候很可能就需要内容编辑器部件了.比如:插HTML.插样式.插脚本.插图片,统统都拿来,用内容编辑器部件. 正文 使用内容编 ...
- ExtJS 教程目录
今天我创建了一个小组,取名ExtJS互助团,欢迎朋友们加入!遇到问题需要帮助的时候别忘了ExtJS互助团!希望更多的园友加入进来,帮别人,也是帮自己!组内讨论不限于ExtJS,还包括FineUI.Ex ...
- 不知道哪里alert undefined 用下面的语句是js报错.F12能提示报错的地方window.alert=function(aa){ if (typeof (aa)"undefined"){ throw "就是这";}};
不知道哪里alert undefined 用下面的语句是js报错.F12能提示报错的地方 var oldalert=window.alert; window.alert=function(aa){ i ...
- 第三十一章 elk(2)- 第二种架构(最常用架构)
参考:http://linuxg.blog.51cto.com/4410110/1761757 最常用架构: 一.安装redis 1.下载:http://redis.io/download 2.解压后 ...
- 附1 踩过的jedis的一些坑
1.java.lang.Long to java.lang.B]类型转换异常 解决方案:归还资源部分,使用jedis.close() 2.jedis数组越界异常 解决方案:版本太低,升到2.8.0
- 如何使用chrome自带的Javascript调试工具 【转】
http://zhangyongbluesky.blog.163.com/blog/static/1831941620113155739840/ 将写好的Javascript代码用chrome打开. ...