当前位置: 首页 > news >正文

常见div+css网页布局(float,absolute)

 

网页布局-常见

 

 

1,           float布局

(1)常规方法

<div id="warp">
    <div id="column">
        <div id="column1">这里是第一列</div>
        <div id="column2">这里是第二列</div>
        <div class="clear"></div>
    </div>
    <div id="column3">这里是第三列</div>
    <div class="clear"></div>
</div>

CSS:
以下是引用片段:
#wrap{ width:100%; height:auto;}
#column{ float:left; width:60%;}
#column1{ float:left; width:30%;}
#column2{ float:right; width:30%;}
#column3{ float:right; width:40%;}
.clear{ clear:both;}

 

(2)margin等于-100%布局

有margin-left:-100%和margin-right:-100%两种情况,淘宝都有用。

使用margin-left的有:screen-hd .head 里面包括logo、搜索框和二维码。

使用margin-right的有:screen-hd .cont 里面包括导航菜单右侧的部分。

 

 

<div id="center" class="column">
    <h1>This is the main content.</h1>
</div>
<div id="left" class="column">
    <h2>This is the left sidebar.</h2>
</div>
<div id="right" class="column">
    <h2>This is the right sidebar.</h2>
</div>

CSS:
以下是引用片段:
body {margin: 0;padding-left: 200px;padding-right: 190px;min-width: 240px;}
.column {position: relative;float: left;}
#center {width: 100%;}
#left {width: 180px; right: 240px;margin-left: -100%;}
#right {width: 130px;margin-right: -100%;}

 

 

我自己实现的例子:

 

<div class="wrap">

       <div class="l">lllllll</div>

       <div class="c"><div class="c-wrap">cccccccccccccccccc</div></div>

       <div class="r">r</div>

</div>

 

.wrap{width: 600px; height: 300px; background: #eee;}

.l{display:inline;float:left; width:180px; background:red; margin-right:-100%;}

.c{display:inline; float:left; width:100%; overflow:hidden;}

.c .c-wrap{margin: 0 180px 0 180px; background:blue; }

.r{display:inline;float:left;width:180px; background:yellow; margin-left:-180px;}

 

 

 

 

2,           position布局

 

#left { position:absolute; top:0px; left:0px; width:120px; }
#middle {margin:20px 190px 20px 190px; }
#right {position:absolute; top:0px; right:0px; width:120px;}

 

 

转载于:https://www.cnblogs.com/zccst/p/3620655.html

相关文章:

  • 用PyTorch创建一个图像分类器?So easy!(Part 1)
  • 【Leetcode】Path Sum II
  • docker学习笔记
  • 3、开启debug调试模式
  • 为什么BAT公司使用微服务架构,资深架构师来告诉你原因!
  • mysql学习【第4篇】:数据库之数据类型
  • python字典操作总结
  • hadoop Hive(9)
  • 启动和测试oracle是否安装成功
  • Java初始化顺序
  • linux 生成随机密码
  • 线程创建
  • 测者的测试技术手册:智能化测试框架EvoSuite的一个坑以及填坑方法
  • cookie和session
  • Android EditText控件自动转换大小写,光标位置不跳位
  • SegmentFault for Android 3.0 发布
  • 【RocksDB】TransactionDB源码分析
  • 8年软件测试工程师感悟——写给还在迷茫中的朋友
  • CNN 在图像分割中的简史:从 R-CNN 到 Mask R-CNN
  • CSS进阶篇--用CSS开启硬件加速来提高网站性能
  • CSS相对定位
  • Git同步原始仓库到Fork仓库中
  • httpie使用详解
  • Java 11 发布计划来了,已确定 3个 新特性!!
  • jQuery(一)
  • Linux Process Manage
  • vue从创建到完整的饿了么(18)购物车详细信息的展示与删除
  • 大数据与云计算学习:数据分析(二)
  • 给github项目添加CI badge
  • 开年巨制!千人千面回放技术让你“看到”Flutter用户侧问题
  • 少走弯路,给Java 1~5 年程序员的建议
  • 实现简单的正则表达式引擎
  • 数组大概知多少
  • 微服务入门【系列视频课程】
  • 小程序、APP Store 需要的 SSL 证书是个什么东西?
  • 你对linux中grep命令知道多少?
  • "无招胜有招"nbsp;史上最全的互…
  • (¥1011)-(一千零一拾一元整)输出
  • (6)设计一个TimeMap
  • (day6) 319. 灯泡开关
  • (delphi11最新学习资料) Object Pascal 学习笔记---第8章第5节(封闭类和Final方法)
  • (floyd+补集) poj 3275
  • (LNMP) How To Install Linux, nginx, MySQL, PHP
  • (八十八)VFL语言初步 - 实现布局
  • (附源码)springboot学生选课系统 毕业设计 612555
  • (简单有案例)前端实现主题切换、动态换肤的两种简单方式
  • (十五)使用Nexus创建Maven私服
  • (转)C#调用WebService 基础
  • (转)EXC_BREAKPOINT僵尸错误
  • (转)Oracle存储过程编写经验和优化措施
  • (转载)Google Chrome调试JS
  • ./configure,make,make install的作用
  • .bat文件调用java类的main方法
  • .NET BackgroundWorker
  • .NET Core 版本不支持的问题