星空网 > 软件开发 > 网页设计

两列布局的设置方法总结

今天看到了这样一道题

用两种不同的方法来实现一个两列布局,其中左侧部分宽度固定、右侧部分宽度随浏览器宽度的变化而自适应变化 

自己感觉有好几种方法,再此总结下:

 一、使用position:absolute方法,因为把元素设置为absolute,那元素就脱离了文档流,后面的元素就会占据他原来的位置:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html ="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title></head><style type="text/css">    .side{width:190px;height:80px;background-color:#F00;position:absolute;}  .exta{height:80px;background-color:#0f0;margin-left:190px; }    </style><body>  <div class="pd">      <div class="side">side</div>    <div class="exta">exta</div>  </div></body></html>

 两列布局的设置方法总结

二、使用float方法

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html ="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title></head><style type="text/css">    .side{width:190px;height:80px;background-color:#F00;     float:left;  }  .exta{height:80px;background-color:#0f0; }//不能添加float:left;否则其宽度就会随内容变窄,不是随浏览器变化了    </style><body>  <div class="pd">        <div class="side">side</div>    <div class="exta">exta</div>  </div></body></html>


 




原标题:两列布局的设置方法总结

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

到越南有哪些物流:https://www.goluckyvip.com/tag/104826.html
陆运到越南专线:https://www.goluckyvip.com/tag/104828.html
越南运输费用:https://www.goluckyvip.com/tag/104829.html
IPO:https://www.goluckyvip.com/tag/10483.html
越南整柜专线:https://www.goluckyvip.com/tag/104831.html
有什么物流可以发越南:https://www.goluckyvip.com/tag/104832.html
三百元以内千兆路由器怎么选择?:https://www.vstour.cn/a/363184.html
千岛湖绿城度假酒店的简介:https://www.vstour.cn/a/363185.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流