donglu5041 2015-02-06 11:21
浏览 76

如何逐行显示div元素

I have a html code which displays ads ,but the ads are display like a coloumn vise, but I want them to display in a horizontal row .How can we display the horizontal rows.And ads are which are coming dynamically based on the user selection.How can we display these ads in a row wise fashion .

Html code is :

<div class="row">
    <div class="col-md-3" id="adsid"></div>
</div>

Code snippet from JS:

<input type="checkbox" id=' + s[i]['id']['0'] + ' />
<a href="#" class="list-group-item ">
    <input type="hidden" id="adsid" name="adsrunning" value=' + s[i]['id']["0"] + '/>
    <h4 class="list-group-item-heading">
        <font color="blue">' + s[i]['hea']["0"] + '</font>
    </h4>
    <p class="list-group-item-text">' + s[i]['desc']["0"] + '</p>
    <p class="list-group-item-text">' + s[i]['desc2']["0"] + '</p>
    <p class="list-group-item-text">
        <font color="green">' + s[i]['url']["0"] + '</font>
    </p>
</a><br/>

And JS is :

$("#groupid").change(function () {
    $("#adsid").html("");

    var grpvalue = $("#groupid").val();
    var accid = $('#accountid').val();
    var adsarray = [];
    $.ajax({
        type: "post",
        dataType: 'json',
        url: "pages/ads.php",
        data: "adgroup=" + grpvalue + "&accid=" + accid,
        success: function (s) {
            for (var i = 0; i < s.length; i++) {

                var head = s[i]['hea']["0"];
                //alert(head);
                var adid = s[i]['id']["0"];
                var desc1 = s[i]['desc']["0"];
                var desc2 = s[i]['desc2']["0"];
                var url = s[i]['url']["0"];
                var p = document.createElement('p');
                var txt = document.createTextNode(head);
                p.appendChild(txt);
                //$('adsid').append(p);  
                adsarray.push(head, adid, desc1, desc2, url);

                $("#adsid").append("");
                $("#adsid").append('<input type="checkbox" id=' + s[i]['id']['0'] + ' /><a href="#" class="list-group-item "><input type="hidden" id="adsid" name="adsrunning" value=' + s[i]['id']["0"] + '/><h4 class="list-group-item-heading"><font color="blue">' + s[i]['hea']["0"] + '</font></h4><p class="list-group-item-text">' + s[i]['desc']["0"] + '</p><p class="list-group-item-text">' + s[i]['desc2']["0"] + '</p><p class="list-group-item-text"><font color="green">' + s[i]['url']["0"] + '</font></p></a><br/>');

            }
        }
    });
});

And Json Data is:

[{
    "hea": {
        "0": "Kidney Stone Removal"
    },
    "id": {
        "0": "40602813172"
    },
    "desc": {
        "0": "Get treated at top kidney center"
    },
    "desc2": {
        "0": "Take a free advice from our experts"
    },
    "url": {
        "0": "www.ainuindia.com"
    }
}]
  • 写回答

3条回答 默认 最新

  • duancunsu9209 2015-02-06 11:30
    关注

    If you can modify the html of ad, try replacing col-md-3 by col-sm12 so the whole thing would read:

     <div class="row">
       <div class="col-sm-12" id="adsid">
    
       </div>
     </div>
    

    I'm assuming you're using bootstrap, so having col-md-3 makes it float left with width 33%. On medium screen.

    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集