百度ife任务三,要求中间宽度自适应,高度取三列最高者。

开始用position的relative和absolute,但是relative不能自适应宽,absolute不能加float浮动,撑不起来外框。

折腾了三天,最后在一个网站看到,左left浮动,右right浮动,中间啥都不用,既不用position也不用float,只要把center写在right后面就可以了!

index.html

 <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="common.css">
</head>
<body>
<div class="out">
<div class="left">
<img src="../images/photo.png" class="photo" alt="">
<span>梵天莲华</span>
</div>
<div class="right">
<img src="../images/photo.png" alt="">
<img src="../images/photo.png" alt="">
<img src="../images/photo.png" alt="">
</div>
<!-- center要放到下面,不用浮动,就可以自适应高度和宽度 -->
<div class="center">
<p>php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!</p>
<p>php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!</p>
<p>php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!</p>
<p>php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!</p>
<p>php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!php is very much!</p>
</div>
</div>
<div>111111111111111122222222222222222222</div>
</body>
</html>

style.css

 body{
margin: 0;
}
.clear{
clear: both;
}
.out{
/*width设置为100%,右边会顶到边,出现横滚动条*/
/*width: 100%;*/
border: 1px solid #00f;
margin: 10px;
padding: 20px;
/*overflow可清除浮动*/
overflow: hidden;
}
.left{
background-color: #555;
float: left;
border: 1px solid #f00;
width: 200px;
/*设置display属性为内联表格,顶部对齐,但是不能靠右侧布局*/
/*display: inline-table;
vertical-align: top;*/
}
.center{
background-color: #aaa;
border: 1px solid #0f0;
margin-left: 240px;
margin-right: 160px;
min-width: 500px;
}
.right{
background-color: #eee;
float: right;
border: 1px solid #f00;
width: 120px;
} .photo{
width: 80px;
height: 80px;
margin: 20px;
}
.left span{
float: right;
margin-top: 20px;
margin-right: 10px;
} .right img{
width: 80px;
height: 80px;
/*将图片设置为block块级元素,不然默认边距*/
display: block;
margin: 20px 20px 20px 20px;
}

CSS学习笔记(6)--浮动,三列布局,高度宽度自适应的更多相关文章

  1. CSS学习笔记08 浮动

    从CSS学习笔记05 display属性一文中,我们知道div是块元素,会独占一行,即使div的宽度很小,像下面这样 应用display属性的inline属性可以让div与div共享一行,除了这种方法 ...

  2. html+css学习笔记 3[浮动]

    inline-block/float(浮动) 回顾:inline-block 特性:      1.块在一排显示 2.内联支持宽高 3.默认内容撑开宽度 4.标签之间的换行间隙被解析(问题) 5.ie ...

  3. CSS学习笔记:浮动属性

    目录 一.浮动流是什么 二.通过代码实例了解浮动特点 1. 搭建测试框架 2. 添加浮动 3. 浮动元素的排布 4. 给行内元素添加浮动效果 5. 子元素浮动后对父元素的影响 5.1 在父元素中添加o ...

  4. CSS学习笔记(12)--Flex 布局教程:实例篇

    原文--阮一峰博客 作者: 阮一峰 日期: 2015年7月14日 上一篇文章介绍了Flex布局的语法,今天介绍常见布局的Flex写法. 你会看到,不管是什么布局,Flex往往都可以几行命令搞定. 我只 ...

  5. CSS学习笔记(11)--Flex 布局教程:语法篇

    原文--阮一峰博客 作者: 阮一峰 日期: 2015年7月10日 网页布局(layout)是CSS的一个重点应用. 布局的传统解决方案,基于盒状模型,依赖 display属性 + position属性 ...

  6. HTML/CSS学习之 三列布局,其中左侧和右侧的部分宽度固定,中间部分宽度随浏览器宽度的变化而自适应变化

    第一种方法:绝对定位 <!DOCTYPE html> <html> <head> <title>三列布局</title> <link ...

  7. CSS学习笔记10 相对定位,绝对定位与固定定位

    文档流中的元素的位置由元素在 (X)HTML 中的位置决定,这就是最原始的普通流,前面讲到的浮动CSS学习笔记08 浮动可以改变元素在文档流中的位置,除了这个我们还可以通过使用CSS的position ...

  8. 慕课笔记利用css进行布局【三列布局】

    三个div中间自适应,两侧固定大小 <html> <head> <title>三列布局</title> <style type="tex ...

  9. 三列布局,读《css那些事儿》

    1.两列定宽,中间自适应 要点:浮动.负边距效果.mainbox增加内容div并设置margin.:after清除浮动 原理:mainbox的浮动并将其宽度设置为100%,次要内容及侧边栏设置固定宽度 ...

  10. css常见的各种布局下----三列布局

    css 三列布局,左右固定宽度右边自适应 1不使用定位,只使用浮动可以实现左右固定,中间宽度自适应布局 1.1.1 自适应部分一定要放第一个位子,使用浮动,并且设置宽度为100%,不设置浮动元素内容不 ...

随机推荐

  1. Linux0.11内核剖析--内核代码(kernel)--sched.c

    1.概述 linux/kernel/目录下共包括 10 个 C 语言文件和 2 个汇编语言文件以及一个 kernel 下编译文件的管理配置文件 Makefile.其中三个子目录中代码注释的将放在后面的 ...

  2. 关于DrawIndexedPrimitive函数的调用

    函数的原型例如以下所看到的: HRESULT DrawIndexedPrimitive( [in] D3DPRIMITIVETYPE Type, [in] INT BaseVertexIndex, [ ...

  3. Python Socket 编程——聊天室演示样例程序

    上一篇 我们学习了简单的 Python TCP Socket 编程,通过分别写服务端和client的代码了解主要的 Python Socket 编程模型.本文再通过一个样例来加强一下对 Socket ...

  4. (剑指Offer)面试题57:删除链表中的重复结点

    题目: 在一个排序的链表中,存在重复的结点,请删除该链表中重复的结点,重复的结点不保留,返回链表头指针. 例如,链表1->2->3->3->4->4->5 处理后为 ...

  5. 真人测试网站用户体验的超棒在线服务 - Peek by UserTesting

    闲逛的过程中找到的这个工具网站,它可以帮助你测试你的网站用户体验,而且会发送给你一个5分钟的视频来展示一个实际的用户(不是机器,是人哦)如何操作你的网站的,这个服务目前免费,大家如果有兴趣了解你的网站 ...

  6. XML❤你并不孤单

    XML不是已不成立的,它是慢慢发展起来的.由最初的GML发展到SGML再到HTML,最后有了是1998年发展起来的可扩展标记语言. 然而XML并非替换HTML的技术,两者的存在都十分重要. XML是一 ...

  7. C#基础视频教程7.2 如何编写简单游戏

    前面一小节我们实现了简单的碰撞检测,但是实际上游戏的对象并不是一个标准的矩形(小鸟是一个不规则的物体,其实碰撞的管道也是不规则物体),所以如果真的要做的比较完美,我们自己要写一个方法,能够导入一个图像 ...

  8. Linux 监测内存常用的工具sar free vmstat

    Linux 检测内存常用的工具sar free vmstat free 内存统计信息解释 total 内存总量used 内存使用的大小free 内存剩余大小shared 共享内存大小buffers 块 ...

  9. Java同步机制总结--synchronized

    不久前用到了同步,现在回过头来对JAVA中的同步做个总结,以对前段时间工作的总结和自我技术的条理话.JAVA中synchronized关键字能够 作为函数的修饰符,也可作为函数内的语句,也就是平时说的 ...

  10. linux(Centos)下编译安装gcc4.8.2

    欢迎转载.转载请注明原文地址:http://blog.csdn.net/majianfei1023/article/details/46811159 近期要用到c++ 11,所以没办法仅仅得把那台ce ...