实现栅格布局的方法有哪些-创新互联

本篇内容主要讲解“实现栅格布局的方法有哪些”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“实现栅格布局的方法有哪些”吧!

创新互联长期为1000多家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为南昌县企业提供专业的网站建设、成都做网站南昌县网站改版等技术服务。拥有十多年丰富建站经验和众多成功案例,为您定制开发。

一、使用float:

代码如下:

<!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>


 实现效果如图所示:

实现栅格布局的方法有哪些

到此,相信大家对“实现栅格布局的方法有哪些”有了更深的了解,不妨来实际操作一番吧!这里是创新互联建站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

名称栏目:实现栅格布局的方法有哪些-创新互联
分享路径:https://www.cdcxhl.com/article46/cedeeg.html

成都网站建设公司_创新互联,为您提供网站导航营销型网站建设小程序开发微信公众号企业网站制作ChatGPT

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都网站建设公司