flex加 grid 布局笔记

2 篇文章 0 订阅

<style>
    .flex-container {
        display: flex;
        height: 100%; /* 设置容器的高度 */
    }
    .wide {
        display: flex;
        padding: 10px;
        border: 1px solid lightgray;
        text-align: center;
        justify-content: center; /* 在水平方向上居中 */
        align-items: center; /* 在垂直方向上居中 */
        width: 50%;
    }
    .grid-container {
        display: grid;
        grid-template-columns: repeat(2, 1fr); /* 创建两列 */
        grid-template-rows: repeat(2, 1fr); /* 创建两行 */
        gap: 50px; /* 设置列和行之间的间距 */
    }

    .grid-item {
        width: 140px;
        height: 140px;
        background-color: white;
        padding: 20px;
        text-align: center;
        display: grid;
        border: 1px solid #4974A4;
        place-items: center;
       
    }
        .active {
            background-color: #4974A4;
            color: #fff;
        }
    .grid-item {
        transition: background-color 0.3s ease;
    }
        .grid-item:hover:hover {
            background-color: #4974A4;
            color: #fff;
        }
       
        /*.grid-item img {
            width: 140px;
            height: 100px;
        }*/
    .container {
        display: flex;
        flex-direction: column; /* 竖向排列 */
        align-items: center; /* 居中对齐 */
        height: 300px; /* 设置容器高度 */
        border: 1px solid #ccc; /* 边框用于可视化 */
    }

    .item {
        width: 300px;
        height: 50px;
        margin: 50px;
        text-align: center;
        line-height: 50px;
        border: 1px solid #4974A4;
        color: black;
    }
        .item:hover {
            background-color: #4974A4;
            color: #fff;
        }

//灰色线
     .gray-hr {
            border: none;
            border-top: 1px solid #ccc; /* 灰色边框线 */
            margin: 10px 0; /* 可以调整线的上下间距 */
        }
</style>
<div class="flex-container">
    <div class="wide">
        <div class="grid-container" id="typeContainer">
            
                        <div class="grid-item" οnclick="typeClick(@ele.Code)" id="type_@ele.Code">

                           
                                <img src="@ele.STRING_1"  />
                                <span style=" font-size: 16px; font-weight:bold">@ele.TextValue</span>
                           

                        </div>
                    }
                    }
                }


            </div>
    </div>
    <div class="wide"  id="typeChildContainer" style="display: none; flex-direction: column"><div  id="containers"></div>
                                                                    </div>
</div>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

葩熊

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值