IE和FF中高度自适应

在CSS的布局中,经常碰到高度自适应的问题,这里给出一种解决方案。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
 <title>Box Float</title>
 <style type="text/css">
  
  body
  {
   margin:15px;
   font-family:Arial;
   font-size:12px;
  }
  .father
  {
   background-color:#ffff99;
   border:1px solid #ff0099;
   padding:5px;
  }
  .father div
  {
   padding:10px;
   margin:15px;
   border:1px dashed #eef7dd;
   background-color:#90daff;
  }
  .father p
  {
   border:1px dashed #332158;
   background-color:#ff90ba;
   clear:both;
  }
  .son1
  {
   float:left;
  }
  .son2
  {
   float:left;
  }
  .son3
  {
   float:right;
   /*在这里设置的clear属性没有什么用,要将属性设置在含有文字的DIV中*/
   /*clear:both;*/
  }
  /*解决自适应高度问题*/
  .father .clear
  {
   margin:0px;
   padding:0px;
   border:0px;
   clear:both;
  }
  
 
 </style>
</head>

<body>

<div class="father">

 <div class="son1">
  Box-1<br/>
  根据内容来调整宽度

 </div>
 <div class="son2">
  Box-2
 </div>
 <div class="son3">
  Box-3
 </div>
 <p>在IE和FF中可以自适应的CSS布局方式</p>
 <div class="clear">
 </div>
</div>

</body>
</html>
效果:

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值