实例演示课堂中学到的Grid的属性

实例演示课堂中学到的Grid的属性

程序实现

.banner { gridrow:1/1; gridcolumn:1/4; backgroundimage: url(head_banner.jpg); color: aliceblue; top:0;/* fixed不能固定上面设置的background-image *//* position: fixed; */ position: sticky; zindex:1;} header { display: grid; border:1px solid red; height:5em; margin:0auto; gridtemplatecolumns:10vw80vw10v源码网点我wcqh.cnw; gridtemplaterows:1.5em3.5em; backgroundcolor: teal;} header .banner { gridrow:1/1; gridcolumn:1/4; backgroundimage: url(head_banner.jpg); color: aliceblue; top:1em;/* 这里的粘性设置,只能在父元素内,父元素滚动到后台后,也不会粘住,后面的sticky滚动时会覆盖前面的*/ position: sticky;} header nav { gridrow:2/2; gridcolumn:2/3; textalign: center;/* line-he源码网点我wcqh.cnight和父元素等高,可用于文字定位于垂直中间位置 */ lineheight:3.5em;/* place-content 似乎对grid排版无效 *//* place-content: center; place-content: space-evenly; */} nav a {/* min-width: 15em; *//* 去掉a标签下划线 */ textdecoration: none; color: aliceblue; minwidth:10em;}.right { gridarea:2/3/ span 1/ span 1;/* text-align: right; */ textalign:cen源码网点我wcqh.cnter; lineheight:3.5em;/* padding用于限制内部元素排版 *//* padding: 0 20px; *//* 此处改变了font-size大小,所以文字高度和line-height不一样,所以不居中了 */ fontsize: larger; fontweight: bolder;}.right a { color: aliceblue; textdecoration: none;}.logo { gridarea:2/1/ span 1/ span 1;/* text-align: center 对图片设置无效 */ textalign: center;/* padding不加单位似乎源码网点我wcqh.cn对图片无效 */ padding:1px1px;}#tops_logo {/* width: 5vw; */ height:3.5em;}.container { width:auto; height:100vh; border:1px solid blue; display: grid; gridtemplatecolumns:10vw80vw10vw;}

实现效果

批改老师:PHPz 批改状态:合格 老师批语:
作者最新博文
2023-03-10 16:14:27

© 版权声明
THE END
喜欢就支持一下吧
点赞807 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容