1. 程式人生 > 其它 >Layui佈局總結:容器和柵格系統

Layui佈局總結:容器和柵格系統

技術標籤:3.Web前端

總覽

在這裡插入圖片描述

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Layui</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"
>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <link rel="stylesheet" href="css/layui.css" media="all"> </head> <body> <div class="layui-container">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;"> <legend>始終等比例水平排列</legend> </fieldset> <div class="layui-row"> <div class="layui-col-xs6"> <div class="grid-demo grid-demo-bg1"
>
6/12</div> </div> <div class="layui-col-xs6"> <div class="grid-demo">6/12</div> </div> </div> <div class="layui-row"> <div class="layui-col-xs3"> <div class="grid-demo grid-demo-bg1">3/12</div> </div> <div class="layui-col-xs3"> <div class="grid-demo">3/12</div> </div> <div class="layui-col-xs3"> <div class="grid-demo grid-demo-bg1">3/12</div> </div> <div class="layui-col-xs3"> <div class="grid-demo">3/12</div> </div> </div> <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;"> <legend>移動裝置、桌面端的組合響應式展現</legend> </fieldset> <div class="layui-row"> <div class="layui-col-xs12 layui-col-md8"> <div class="grid-demo grid-demo-bg1">移動:12/12、桌面:8/12</div> </div> <div class="layui-col-xs6 layui-col-md4"> <div class="grid-demo">移動:6/12、桌面:4/12</div> </div> <div class="layui-col-xs6 layui-col-md12"> <div class="grid-demo grid-demo-bg2">移動:6/12、桌面:12/12</div> </div> </div> <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;"> <legend>移動裝置、平板、桌面端的複雜組合響應式展現</legend> </fieldset> <div class="layui-row"> <div class="layui-col-xs6 layui-col-sm6 layui-col-md4"> <div class="grid-demo grid-demo-bg1">移動:6/12 | 平板:6/12 | 桌面:4/12</div> </div> <div class="layui-col-xs6 layui-col-sm6 layui-col-md4"> <div class="grid-demo layui-bg-red">移動:6/12 | 平板:6/12 | 桌面:4/12</div> </div> <div class="layui-col-xs4 layui-col-sm12 layui-col-md4"> <div class="grid-demo layui-bg-blue">移動:4/12 | 平板:12/12 | 桌面:4/12</div> </div> <div class="layui-col-xs4 layui-col-sm7 layui-col-md8"> <div class="grid-demo layui-bg-green">移動:4/12 | 平板:7/12 | 桌面:8/12</div> </div> <div class="layui-col-xs4 layui-col-sm5 layui-col-md4"> <div class="grid-demo layui-bg-black">移動:4/12 | 平板:5/12 | 桌面:4/12</div> </div> </div> <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;"> <legend>常規佈局:從小螢幕堆疊到桌面水平排列</legend> </fieldset> <div class="layui-row"> <div class="layui-col-md1"> <div class="grid-demo grid-demo-bg1">1/12</div> </div> <div class="layui-col-md1"> <div class="grid-demo">1/12</div> </div> <div class="layui-col-md1"> <div class="grid-demo grid-demo-bg1">1/12</div> </div> <div class="layui-col-md1"> <div class="grid-demo">1/12</div> </div> <div class="layui-col-md1"> <div class="grid-demo grid-demo-bg1">1/12</div> </div> <div class="layui-col-md1"> <div class="grid-demo">1/12</div> </div> <div class="layui-col-md1"> <div class="grid-demo grid-demo-bg1">1/12</div> </div> <div class="layui-col-md1"> <div class="grid-demo">1/12</div> </div> <div class="layui-col-md1"> <div class="grid-demo grid-demo-bg1">1/12</div> </div> <div class="layui-col-md1"> <div class="grid-demo">1/12</div> </div> <div class="layui-col-md1"> <div class="grid-demo grid-demo-bg1">1/12</div> </div> <div class="layui-col-md1"> <div class="grid-demo">1/12</div> </div> </div> <div class="layui-row"> <div class="layui-col-md9"> <div class="grid-demo grid-demo-bg1">75%</div> </div> <div class="layui-col-md3"> <div class="grid-demo">25%</div> </div> </div> <div class="layui-row"> <div class="layui-col-md4"> <div class="grid-demo grid-demo-bg1">33.33%</div> </div> <div class="layui-col-md4"> <div class="grid-demo">33.33%</div> </div> <div class="layui-col-md4"> <div class="grid-demo grid-demo-bg1">33.33%</div> </div> </div> <div class="layui-row"> <div class="layui-col-md6"> <div class="grid-demo grid-demo-bg1">50%</div> </div> <div class="layui-col-md6"> <div class="grid-demo">50%</div> </div> </div> <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;"> <legend>列間隔</legend> </fieldset> <div class="layui-row layui-col-space1"> <div class="layui-col-md3"> <div class="grid-demo grid-demo-bg1">1/4</div> </div> <div class="layui-col-md3"> <div class="grid-demo">1/4</div> </div> <div class="layui-col-md3"> <div class="grid-demo grid-demo-bg1">1/4</div> </div> <div class="layui-col-md3"> <div class="grid-demo">1/4</div> </div> </div> <div class="layui-row layui-col-space5"> <div class="layui-col-md4"> <div class="grid-demo grid-demo-bg1">1/3</div> </div> <div class="layui-col-md4"> <div class="grid-demo">1/3</div> </div> <div class="layui-col-md4"> <div class="grid-demo grid-demo-bg1">1/3</div> </div> </div> <div class="layui-row layui-col-space10"> <div class="layui-col-md9"> <div class="grid-demo grid-demo-bg1">9/12</div> </div> <div class="layui-col-md3"> <div class="grid-demo">3/12</div> </div> </div> <div class="layui-row layui-col-space15"> <div class="layui-col-md7"> <div class="grid-demo grid-demo-bg1">7/12</div> </div> <div class="layui-col-md5"> <div class="grid-demo">5/12</div> </div> </div> <div class="layui-row layui-col-space30"> <div class="layui-col-md7"> <div class="grid-demo grid-demo-bg1">7/12</div> </div> <div class="layui-col-md5"> <div class="grid-demo">5/12</div> </div> </div> <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;"> <legend>列偏移</legend> </fieldset> <div class="layui-row"> <div class="layui-col-md4"> <div class="grid-demo grid-demo-bg1">4/12</div> </div> <div class="layui-col-md4 layui-col-md-offset4"> <div class="grid-demo">偏移4列</div> </div> <div class="layui-col-md1 layui-col-md-offset5"> <div class="grid-demo grid-demo-bg1">偏移5列</div> </div> <div class="layui-col-md1"> <div class="grid-demo">不偏移</div> </div> </div> <div class="layui-row"> <div class="layui-col-md3 layui-col-md-offset3"> <div class="grid-demo grid-demo-bg1">偏移3列</div> </div> <div class="layui-col-md3 layui-col-md-offset1"> <div class="grid-demo">偏移1列</div> </div> </div> <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;"> <legend>柵格巢狀</legend> </fieldset> <div class="layui-row"> <div class="layui-col-md5"> <div class="layui-row grid-demo"> <div class="layui-col-md3"> <div class="grid-demo grid-demo-bg1">內部列</div> </div> <div class="layui-col-md9"> <div class="grid-demo grid-demo-bg2">內部列</div> </div> <div class="layui-col-md12"> <div class="grid-demo grid-demo-bg3">內部列</div> </div> </div> </div> <div class="layui-col-md7"> <div class="layui-row grid-demo grid-demo-bg1"> <div class="layui-col-md12"> <div class="grid-demo">內部列</div> </div> <div class="layui-col-md9"> <div class="grid-demo grid-demo-bg2">內部列</div> </div> <div class="layui-col-md3"> <div class="grid-demo grid-demo-bg3">內部列</div> </div> </div> </div> </div> </div> <div class="layui-fluid"> <fieldset class="layui-elem-field layui-field-title"> <legend>流體容器(寬度自適應,不固定)</legend> </fieldset> <div class="layui-row"> <div class="layui-col-sm3"> <div class="grid-demo grid-demo-bg1">25%</div> </div> <div class="layui-col-sm3"> <div class="grid-demo">25%</div> </div> <div class="layui-col-sm3"> <div class="grid-demo grid-demo-bg1">25%</div> </div> <div class="layui-col-sm3"> <div class="grid-demo">25%</div> </div> </div> </div> <script src="layui.js" charset="utf-8"></script> <script> </script> </body> </html>