常用布局总结
2015-06-06 14:01
211 查看
1,清除由于子元素浮动带来的高度塌陷
2,图片和文字垂直居中对齐,图片和文字垂直居中对齐的方法
(1)父元素设置font-size=0,为了消除子元素使用display-inline-block带来的间隙
(2)子元素如果是文字就要单独设置font-size,子元素这只vertical-align=top,使子元素浮动到和父元素上方对齐,在设置line-height居中显示,line-height和图片高度相同。
.clear:before, .clear:after{ content:""; display:table; } .clear:after{ clear:both; overflow:hidden; } .clear{ zoom:1; }
2,图片和文字垂直居中对齐,图片和文字垂直居中对齐的方法
(1)父元素设置font-size=0,为了消除子元素使用display-inline-block带来的间隙
(2)子元素如果是文字就要单独设置font-size,子元素这只vertical-align=top,使子元素浮动到和父元素上方对齐,在设置line-height居中显示,line-height和图片高度相同。
<style type="text/css"> *{ margin:0px; padding:0px; } .head{ width:90%; background-color:red; font-size:0px; padding:5px 0px; } .name{ width:50%; background-color:green; font-size:25px; vertical-align:top; line-height:25px; } .operation{ width:50%; background-color:orange; text-align:right; font-size:15px; line-height:25px; } .operation img{ width:25px; height:25px; } .dispinline{ display:inline-block; } </style> <div class="head"> <div class="name dispinline">最新猜测</div> <div class="operation dispinline">ddd</div> </div>
相关文章推荐
- Caused by: java.net.UnknownHostException
- 《数据结构学习与实验指导》3-5求链式线性表的倒数第K项/3-6表达式转换
- OnEraseBkGnd与OnPaint
- pushd popd切换目录
- sendfile优化文件拷贝
- linux的root登录密码问题
- Web安全之SQL注入攻击
- LeetCode1 Two Sum
- hihocoder 1135 : Magic Box
- C 文件操作库函数总结
- cmake学习(二)常用变量和常用环境变量
- Android Stdio常见问题解决
- 清除keil编译中间文件的脚本
- CMake 手册详解(二十二)
- 【Java】利用ant插件压缩文件夹及其所有子文件与子文件夹
- 移动端页面侧边导航滑入效果
- SAE上部署
- 如何快速开发网站?
- 设计模式C++实现(16)——状态模式
- 探索:移动互联网如何颠覆医疗