Grid随记

该博客文章通过四个示例(demo01至demo04)详细介绍了CSS Grid布局的使用方法,包括设置列宽、行高、自动填充、响应式设计等特性。通过这些示例,读者可以学习如何创建灵活且响应式的网格布局,以适应不同屏幕尺寸的需求。

http://www.ruanyifeng.com/blog/2019/03/grid-layout-tutorial.html 

 

 

 demo01

<div class="wrapper">
  <div class="one item">One</div>
  <div class="two item">Two</div>
  <div class="three item">Three</div>
  <div class="four item">Four</div>
  <div class="five item">Five</div>
  <div class="six item">Six</div>
</div>

.wrapper {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-gap: 20px;
  grid-auto-rows: minmax(100px, auto);
}
.one {
  grid-column: 1 / 2;
  grid-row: 1;
  background: #19CAAD;
}
.two { 
  grid-column: 2 / 4;
  grid-row: 1 / 3;
  background: #8CC7B5;
}
.three {
  grid-row: 2 / 5;
  grid-column: 1;
  background: #D1BA74;
}
.four {
  grid-column: 3;
  grid-row: 3;
  background: #BEE7E9;
}
.five {
  grid-column: 2;
  grid-row: 3/5;
  background: #E6CEAC;
}
.six {
  grid-column: 3;
  grid-row: 4;
  background: #ECAD9E;
}
.item {
  text-align: center;
  font-size: 200%;
  color: #fff;
}

demo02

<div class="wrapper">
  <div class="one item">One</div>
  <div class="two item">Two</div>
  <div class="three item">Three</div>
  <div class="four item">Four</div>
  <div class="five item">Five</div>
  <div class="six item">Six</div>
</div>

.wrapper {
  margin: 60px;
  /* 声明一个容器 */
  display: grid;
  /*  声明列的宽度  */
  grid-template-columns: repeat(3, 200px);
  /*  声明行间距和列间距  */
  grid-gap: 20px;
  /*  声明行的高度  */
  grid-template-rows: 100px 200px;
}
.one {
  background: #19CAAD;
}
.two { 
  background: #8CC7B5;
}
.three {
  background: #D1BA74;
}
.four {
  background: #BEE7E9;
}
.five {
  background: #E6CEAC;
}
.six {
  background: #ECAD9E;
}
.item {
  text-align: center;
  font-size: 200%;
  color: #fff;
}
 

 demo03

<div class="wrapper">
  <div class="one item">One</div>
  <div class="two item">Two</div>
  <div class="three item">Three</div>
  <div class="four item">Four</div>
  <div class="five item">Five</div>
  <div class="six item">Six</div>
</div>
.wrapper {
  margin: 50px;
}
.wrapper {
  display: grid;
  grid-template-columns: repeat(auto-fill, 200px);
  grid-gap: 5px;
  grid-auto-rows: 50px;
}
.one {
  background: #19CAAD;
}
.two { 
  background: #8CC7B5;
}
.three {
  background: #D1BA74;
}
.four {
  background: #BEE7E9;
}
.five {
  background: #E6CEAC;
}
.six {
  background: #ECAD9E;
}
.item {
  text-align: center;
  font-size: 200%;
  color: #fff;
}


image

 demo04(重复demo03)

.wrapper {
  display: grid;
  grid-template-columns: 200px 1fr 2fr;
  grid-gap: 5px;
  grid-auto-rows: 50px;
}

image

 demo05(重复demo03) 

 
.wrapper {
    /* 限制宽度   */
  display: grid;
  grid-template-columns: 1fr 1fr minmax(300px, 2fr);
  grid-gap: 5px;
  grid-auto-rows: 50px;
}

image

demo06

<div class="wrapper">
  <div class="one item">One</div>
  <div class="two item">Two</div>
  <div class="three item">Three</div>
  <div class="four item">Four</div>
  <div class="five item">Five</div>
  <div class="six item">Six</div>
</div>
.wrapper {
  margin: 50px;
}
.wrapper {
  display: grid;
  grid-template-columns: 1fr 1fr minmax(300px, 2fr);
  grid-template-rows: 100px 100px;
  grid-gap: 5px;
  grid-auto-rows: 50px;
 
}
.one {
  background: #19CAAD;
}
.two { 
  background: #8CC7B5;
}
.three {
  background: #D1BA74;
}
.four {
  background: #BEE7E9;
}
.five {
  background: #E6CEAC;
}
.six {
  background: #ECAD9E;
}
.item {
  text-align: center;
  font-size: 200%;
  color: #fff;
  display:grid;
  justify-items: center;
  align-items: center;
}

 

开发相关随记包含多个方面: - **软件开发**:在增加和设计较为庞大的程序时,要考虑程序结构设计,如解耦、层与层接口、模块之间关系、参数、ram、flash、运行速度等。还可学习了解aoutosar的分层结构。新的项目需在较短时间完成从零编码到交付[^1]。 - **IsaacLab开发**:遇到在spring - damping模型下,调大限制和刚度、damping参数后出现异常情况,几十个episode插入后不在孔周围晃,此现象与预期不符,需进一步理顺[^2]。 - **Chrome扩展程序开发**:Map是新的数据类型,可在JavaScript中用于存储键值对实现快速查找,还给出了本地缓存工具的代码实现,同时列举了一些相关学习参考资料,如ReqBin在线API测试工具、Chrome插件开发攻略等[^3]。 ```javascript let data = new Map([ ['Alice', 25], ['Bob', 30], ['Charlie', 35], ['David', 40] ]); console.log(data.get('Alice')); // 25 var myLocalStorageTool = { set: function(key, value) { localStorage.setItem(key, value); }, get: function(key) { return localStorage.getItem(key); }, remove: function(key) { localStorage.removeItem(key); }, removeAll: function() { localStorage.clear(); }, toJsonString: function(jsData) { return JSON.stringify(jsData); }, toJsData: function(jsonString) { return JSON.parse(jsonString); } }; ``` - **X86平台开发**:对于intel的X86平台,intel提供完整数据手册和丰富资源,不同卷册有不同内容,如vol 1是整体介绍,vol 2是CPU部分寄存器说明等,还有PDG、硬件设计指南、散热文档、产线可制造性文档等可供参考[^4]。 - **通用开发问题**:client的定时器是通用功能,但依赖cocos2d的Scheduler类,导致移植到server端困难,使用C++标准库实现可避免该问题[^5]。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值