<div class="ul-group-title">基本</div>
<div class="ul-nav-grid colord">
<div class="item red">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
</div>
<div class="ul-group-title">图标颜色</div>
<div class="ul-nav-grid colord">
<div class="item red">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item orange">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item yellow">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item green">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item bluegreen">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item blue">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item purple">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item red">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item orange">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item yellow">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item green">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item bluegreen">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
</div>
<div class="ul-group-title">图标背景</div>
<div class="ul-nav-grid colord-bg">
<div class="item red">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item orange">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item yellow">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item green">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item bluegreen">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item blue">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item purple">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item red">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item orange">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item yellow">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item green">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item bluegreen">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
</div>
<div class="ul-group-title">宫格边框+背景色</div>
<div class="ul-nav-grid colord-bg box">
<div class="item red">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item orange">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item yellow">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item green">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item bluegreen">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item blue">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item purple">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item red">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item orange">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item yellow">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item green">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
<div class="item bluegreen">
<div class="icon">
<div class="main"><i class="layui-icon layui-icon-home"></i></div>
</div>
<div class="title">首页</div>
</div>
</div>
<div class="ul-group-title">宫格边框+图片</div>
<div class="ul-nav-grid box">
<div class="item red">
<div class="icon">
<div class="main">
<img style="width: 26px;height: 26px;" src="/static/images/view.jpg">
</div>
</div>
<div class="title">首页</div>
</div>
<div class="item orange">
<div class="icon">
<div class="main">
<img style="width: 26px;height: 26px;" src="/static/images/view.jpg">
</div>
</div>
<div class="title">首页</div>
</div>
<div class="item yellow">
<div class="icon">
<div class="main">
<img style="width: 26px;height: 26px;" src="/static/images/view.jpg">
</div>
</div>
<div class="title">首页</div>
</div>
<div class="item green">
<div class="icon">
<div class="main">
<img style="width: 26px;height: 26px;" src="/static/images/view.jpg">
</div>
</div>
<div class="title">首页</div>
</div>
</div>
<div class="ul-group-title">宫格边框+图片+背景</div>
<div class="ul-nav-grid colord-bg">
<div class="item red">
<div class="icon">
<div class="main">
<img style="width: 26px;height: 26px;" src="/static/images/view.jpg">
</div>
</div>
<div class="title">首页</div>
</div>
<div class="item orange">
<div class="icon">
<div class="main">
<img style="width: 26px;height: 26px;" src="/static/images/view.jpg">
</div>
</div>
<div class="title">首页</div>
</div>
<div class="item yellow">
<div class="icon">
<div class="main">
<img style="width: 26px;height: 26px;" src="/static/images/view.jpg">
</div>
</div>
<div class="title">首页</div>
</div>
<div class="item green">
<div class="icon">
<div class="main">
<img style="width: 26px;height: 26px;" src="/static/images/view.jpg">
</div>
</div>
<div class="title">首页</div>
</div>
</div>
.ul-nav-grid {
display: flex;
flex-wrap: wrap;
align-items: flex-start;
justify-content: flex-start;
$gridCount: 3;
.item {
flex: 0 0 calc(100% / $gridCount);
text-align: center;
margin-bottom: 12px;
.icon {
text-align: center;
}
.main {
padding: 6px;
display: flex;
align-items: center;
justify-content: center;
width: fit-content;
margin: 0 auto;
}
}
// 将背景颜色值定义成变量
$colors:('red': #FF6961,
'orange': #FFA07A,
'yellow': #FF69B4,
'green': #2ECC71,
'bluegreen': #1ABC9C,
'blue': #3498DB,
'purple': #AF7AC5,
);
&.colord {
@each $colorKey,
$color in $colors {
.item.#{$colorKey} {
.icon {
color: $color;
}
}
}
}
&.colord-bg {
@each $colorKey,
$color in $colors {
.item.#{$colorKey} {
.icon {
color: #fff;
.main {
background-color: $color;
border-radius: 50%;
}
}
}
}
}
&.box {
background-color: #eee;
padding: 0.5px;
.item {
flex: 0 0 calc(100% / $gridCount - 1px - 24px);
margin: 0.5px;
background-color: #fff;
padding: 12px;
}
}
}
.ul-nav-grid {
display: flex;
flex-wrap: wrap;
align-items: flex-start;
justify-content: flex-start;
}
.ul-nav-grid .item {
flex: 0 0 calc(100% / $gridCount);
text-align: center;
margin-bottom: 12px;
}
.ul-nav-grid .item .icon {
text-align: center;
}
.ul-nav-grid .item .main {
padding: 6px;
display: flex;
align-items: center;
justify-content: center;
width: fit-content;
margin: 0 auto;
}
.ul-nav-grid.colord .item.red .icon {
color: #FF6961;
}
.ul-nav-grid.colord .item.orange .icon {
color: #FFA07A;
}
.ul-nav-grid.colord .item.yellow .icon {
color: #FF69B4;
}
.ul-nav-grid.colord .item.green .icon {
color: #2ECC71;
}
.ul-nav-grid.colord .item.bluegreen .icon {
color: #1ABC9C;
}
.ul-nav-grid.colord .item.blue .icon {
color: #3498DB;
}
.ul-nav-grid.colord .item.purple .icon {
color: #AF7AC5;
}
.ul-nav-grid.colord-bg .item.red .icon {
color: #fff;
}
.ul-nav-grid.colord-bg .item.red .icon .main {
background-color: #FF6961;
border-radius: 50%;
}
.ul-nav-grid.colord-bg .item.orange .icon {
color: #fff;
}
.ul-nav-grid.colord-bg .item.orange .icon .main {
background-color: #FFA07A;
border-radius: 50%;
}
.ul-nav-grid.colord-bg .item.yellow .icon {
color: #fff;
}
.ul-nav-grid.colord-bg .item.yellow .icon .main {
background-color: #FF69B4;
border-radius: 50%;
}
.ul-nav-grid.colord-bg .item.green .icon {
color: #fff;
}
.ul-nav-grid.colord-bg .item.green .icon .main {
background-color: #2ECC71;
border-radius: 50%;
}
.ul-nav-grid.colord-bg .item.bluegreen .icon {
color: #fff;
}
.ul-nav-grid.colord-bg .item.bluegreen .icon .main {
background-color: #1ABC9C;
border-radius: 50%;
}
.ul-nav-grid.colord-bg .item.blue .icon {
color: #fff;
}
.ul-nav-grid.colord-bg .item.blue .icon .main {
background-color: #3498DB;
border-radius: 50%;
}
.ul-nav-grid.colord-bg .item.purple .icon {
color: #fff;
}
.ul-nav-grid.colord-bg .item.purple .icon .main {
background-color: #AF7AC5;
border-radius: 50%;
}
.ul-nav-grid.box {
background-color: #eee;
padding: 0.5px;
}
.ul-nav-grid.box .item {
flex: 0 0 calc(100% / $gridCount - 1px - 24px);
margin: 0.5px;
background-color: #fff;
padding: 12px;
}
<view class="ul-group-title">基本</view>
<view class="ul-nav-grid colord">
<view class="item red">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
</view>
<view class="ul-group-title">图标颜色</view>
<view class="ul-nav-grid colord">
<view class="item red">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item orange">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item yellow">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item green">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item bluegreen">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item blue">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item purple">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item red">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item orange">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item yellow">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item green">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item bluegreen">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
</view>
<view class="ul-group-title">图标背景</view>
<view class="ul-nav-grid colord-bg">
<view class="item red">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item orange">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item yellow">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item green">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item bluegreen">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item blue">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item purple">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item red">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item orange">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item yellow">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item green">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item bluegreen">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
</view>
<view class="ul-group-title">宫格边框+背景色</view>
<view class="ul-nav-grid colord-bg box">
<view class="item red">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item orange">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item yellow">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item green">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item bluegreen">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item blue">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item purple">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item red">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item orange">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item yellow">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item green">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
<view class="item bluegreen">
<view class="icon">
<view class="main"><i class="layui-icon layui-icon-home"></i></view>
</view>
<view class="title">首页</view>
</view>
</view>
<view class="ul-group-title">宫格边框+图片</view>
<view class="ul-nav-grid box">
<view class="item red">
<view class="icon">
<view class="main">
<img style="width: 26px;height: 26px;" src="/static/images/view.jpg">
</view>
</view>
<view class="title">首页</view>
</view>
<view class="item orange">
<view class="icon">
<view class="main">
<img style="width: 26px;height: 26px;" src="/static/images/view.jpg">
</view>
</view>
<view class="title">首页</view>
</view>
<view class="item yellow">
<view class="icon">
<view class="main">
<img style="width: 26px;height: 26px;" src="/static/images/view.jpg">
</view>
</view>
<view class="title">首页</view>
</view>
<view class="item green">
<view class="icon">
<view class="main">
<img style="width: 26px;height: 26px;" src="/static/images/view.jpg">
</view>
</view>
<view class="title">首页</view>
</view>
</view>
<view class="ul-group-title">宫格边框+图片+背景</view>
<view class="ul-nav-grid colord-bg">
<view class="item red">
<view class="icon">
<view class="main">
<img style="width: 26px;height: 26px;" src="/static/images/view.jpg">
</view>
</view>
<view class="title">首页</view>
</view>
<view class="item orange">
<view class="icon">
<view class="main">
<img style="width: 26px;height: 26px;" src="/static/images/view.jpg">
</view>
</view>
<view class="title">首页</view>
</view>
<view class="item yellow">
<view class="icon">
<view class="main">
<img style="width: 26px;height: 26px;" src="/static/images/view.jpg">
</view>
</view>
<view class="title">首页</view>
</view>
<view class="item green">
<view class="icon">
<view class="main">
<img style="width: 26px;height: 26px;" src="/static/images/view.jpg">
</view>
</view>
<view class="title">首页</view>
</view>
</view>