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>全票& ...
随机推荐
- 某个 页面覆盖了 UITabBar 的tabItem的解决办法
将这个页面的背景色设置为无色: [self.view setBackgroundColor:[UIColor clearColor]]; 或者 self.view.frame = CGRectMake ...
- WordPress基础:常用分类列表wp_list_categories
函数:wp_list_categories($args) 作用:列出某个分类下的分类项目 用法: <ul> <?php $args= array( 'depth'=>1, 'o ...
- Linux学习4-阿里云服务器(CentOS)下使用 Tomcat安装 Jenkins
前言 通常做自动化测试,需要用到jenkins来做持续集成,那么linux系统里面如何使用tomcat安装Jenkins环境呢? 前面一篇已经搭建好java和tomcat环境,接着直接下载jenkin ...
- linux内核netfilter模块分析之:HOOKs点的注册及调用
转自;http://blog.csdn.net/suiyuan19840208/article/details/19684883 -1: 为什么要写这个东西?最近在找工作,之前netfilter 这一 ...
- 真爱如血第七季/全集True Blood迅雷下载
第七季 True Blood Season 7(2014)看点:由于日本科学家合成了一种人造血,一夜之间,吸血鬼不再是人们心中那富有传奇色彩的怪物,而是能与人类和平相处的朋友.已经播出五年的HBO吸血 ...
- 使用Camera进行拍照 & 后台静默拍照的思路
Android中的Camera可以用来进行自定义相机.取景框实时预览.拍照等操作.在5.0中,这个类不推荐使用了,新出了一个Camera2,那个东西没怎么研究过,反正一时半会用不到.本篇讲解的是如果用 ...
- Easyui 页面设置加载完成之后,满屏
js文件: if(top.location!=self.location){ top.location.href=self.location; }
- 配置SSD-caffe测试时出现“Check failed: error == cudaSuccess (10 vs. 0) invalid device ordinal”解决方案
这是由于GPU数量不匹配造成的,如果训练自己的数据,那么我们只需要将solver.prototxt文件中的device_id项改为自己的GPU块数,一块就是0,两块就是1,以此类推. 但是SSD配置时 ...
- cannot import name 'main' 解决方案
error description: pip3 install numpy Traceback (most recent call last): File "/usr/bin/pip3&qu ...
- @ZooKeeper注册中心安装(单节点)
1.下载zookeeper 下载地址:https://archive.apache.org/dist/zookeeper/,这里我们使用3.4.6版本. [winner-0715@localhost ...