You need to enable JavaScript to run this app. jQuery模板开发时,如何实现智能家居应用的响应式卡片列布局?
优惠活动
大模型
产品
解决方案
定价
更多

jQuery模板开发时,如何实现智能家居应用的响应式卡片列布局?

智能家居Web应用响应式卡片布局适配

我目前正在开发一款响应式智能家居 Web应用。
为了让应用在更大尺寸屏幕上获得更好的适配表现,我打算将房间、灯光相关的卡片调整为多列布局:按照响应式断点规则,平板(lg)断点下卡片显示2列,桌面端(xl)断点下卡片显示3列。
目前应用在xs、s尺寸的移动端设备上,卡片是垂直单列堆叠的效果;我预期在lg平板断点下,能实现双列等宽排布的卡片展示效果。
现在我是通过JSON文件加载所有业务数据,逐行遍历数据条目,为每个房间、灯光生成对应的卡片,核心生成逻辑的代码如下:

$.each(rooms_data, function (index, obj) {
    template = 
        `
        <div class="card" style="background-color: #6e6e6e;">
            <div class="card-body" data-cardid="${obj.id}">
                ${html_favourite_light}
                <h6 class="card-title" style="color: #d1d1d1;">Room: ${obj.room}</h6>
                <h5 class="card-subtitle mb-2" style="color: #ffffff;">${obj.name}</h5>
                <p style="color: #ffffff;">Rating:${html_rating_light}</p style="color: #ffffff;">
                <select class="custom-select mb-3" id="sel1" style="background-color: #696969; border: none; color: #ffffff;">
                    <option>${obj.select_1}</option>
                    <option>${obj.select_2}</option>
                    <option>${obj.select_3}</option>
                    <option>${obj.select_4}</option>
                </select>
                ${html_switch_light}
                <h5 class="card-text pt-2" style="color: white;">Main Switch</h5>
            </div>
        </div>
        `
})

我之前尝试过用card decks、card groups两种内置卡片布局方案做调整,始终没能得到预期的多列排布效果。

内容的提问来源于stack exchange,提问作者jakeu_

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.12.02 04:15:06