javascript - 有没有办法使用ajax水平对齐动态卡?

标签 javascript php html ajax

我试图使我的卡片水平,但问题是我有一个ajax来获取我的数据并且它是动态的

我的页面中每行只需要两张卡片

这是我的ajax脚本代码

for(i=0; i<data.length; i++){
    html +='<div class="col-md-6">'+
        '<div class="card" style="width: 15rem; text-align:center;display:inline-block;">'+
            '<div class="card-body">'+
                '<h5 class="card-title">'+data[i].group_name+'</h5>'+
                        '<h6 class="card-subtitle mb-2 text-muted">Modify your Group</h6>'+
                            '<a href="javascript:;" class="btn btn-info item-edit" data="'+data[i].id+'"><span class="iconify" data-icon="feather:edit" data-inline="false"></span></a>&nbsp;'+
                            '<a href="javascript:;" class="btn btn-primary item-delete" data="'+data[i].id+'"><span class="iconify" data-icon="dashicons:remove" data-inline="false"></span></a>'+
            '</div>'+
     '</div>'+
    '</div><hr>';
    }
$('#showdata').html(html);

并在 html 中

 <div class="container">
        <div class="row">

            <div id="showdata"></div>

        </div>
    </div>

最佳答案

我认为你所拥有的大部分都很好。而不是更新单独的 <div id='showdata'> 的 html将其与您的行结合起来。

 <div class="container">
    <div id='showdata' class="row"></div>
 </div>

关于javascript - 有没有办法使用ajax水平对齐动态卡?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60701064/

相关文章:

javascript - 如何更改webix TabView中单元格的标题文本?

php - 运行 PHP cronjob 超过 15 分钟

javascript - 在表单中动态添加数组文本框

javascript - Element.prop ('scrollHeight' ) 为 Angular.js 中的不同列表项返回相同的值

javascript - 防止双击被解释为两次单击?

javascript - bat 侠JS : deeply nested routes

php - Twitter 401 未经授权——OAuth 请求 token

html - :before 上的图像 CSS 转换

html - AngularJS 绑定(bind)不安全 :javascript:void(0) when value is javascipt:void(0)

javascript - jQuery 动画可以工作,但并不总是有效