简单实现栅格布局的两种方式
2015-03-10 10:01
1846 查看
一、使用float:
二、使用display:flex(这个css3属性仅谷歌和火狐支持)
实现效果如图所示:
当然使用table和负边距也是可以实现的,有时间补上:-D
以上就是本文所述的全部内容了,希望大家能够喜欢。
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <style> section { border: solid 1px; } section section { float: left; margin-left: 10px; margin-top: 10px; text-align: center; width: 200px; border-radius: 20px; height: 200px; } .parent { height: 440px; width: 660px; } .parent section:first-child { height: 410px; } </style> </head> <body> <section class="parent"> <section>A</section> <section>B</section> <section>C</section> <section>D</section> <section>E</section> </section> </body> </html>
二、使用display:flex(这个css3属性仅谷歌和火狐支持)
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <style> section { border: solid 1px; } section section { margin-left: 10px; margin-top: 10px; text-align: center; width: 200px; border-radius: 20px; height: 200px; } .parent { display: flex; flex-direction: column; flex-wrap: wrap; height: 440px; width: 660px; } .parent section:first-child { height: 410px; } </style> </head> <body> <section class="parent"> <section>A</section> <section>B</section> <section>C</section> <section>D</section> <section>E</section> </section> </body> </html>
实现效果如图所示:
当然使用table和负边距也是可以实现的,有时间补上:-D
以上就是本文所述的全部内容了,希望大家能够喜欢。
相关文章推荐
- 简单实现栅格布局的两种方式
- js实现文件下载的两种简单方式
- 两种简单的方式快速实现hashCode 和 equals方法
- C和C#两种方式实现简单的邮件发送
- 用最简单最实用的方式实现ViewPager无限循环两种方式
- 实现顶部轮播,下部listview经典布局的两种方式
- css页面中常见左中右分栏布局的两种实现方式
- 实现顶部轮播,下部listview经典布局的两种方式
- 实现顶部轮播,下部listview经典布局的两种方式
- 实现顶部轮播,下部listview经典布局的两种方式
- 智能指针的简单实现及两种误用方式
- 用最简单最实用的方式实现ViewPager无限循环两种方式
- C和C#两种方式实现邮件的简单接收
- Auto Layout简单应用——以编码的方式实现Auto Layout自动布局(二)
- 实现顶部轮播,下部listview经典布局的两种方式
- Javascript 瀑布流实现的两种方式:固定列数的浮动布局与绝对定位自适应宽度
- 瀑布流布局的两种实现方式:传统多列浮动和绝对定位布局
- 用最简单最实用的方式实现ViewPager无限循环两种方式
- C和C#两种方式实现邮件的简单发送
- UIScrollView的自动布局最简单实现方式,不用一句代码即可滚动