列表的響應式排版,列表響應式排版

來源:互聯網
上載者:User

列表的響應式排版,列表響應式排版

效果展示:

     

 

一、每行固定個數:保證排版的美觀

.list li{width:20%;display:inline-block;*display:inline;*zoom:1;overflow:hidden;}

二、隨頁面寬度調整個數和大小:保證圖文的可讀性

.list li{width:20%;display:inline-block;*display:inline;*zoom:1;overflow:hidden;}

1、媒體查詢控制寬度

@media screen and (max-width:1280px){    .list-table1 li{width:25%}}@media screen and (max-width:600px){    .list-table1 li{width:33.3%}}@media screen and (max-width:400px){    .list-table1 li{width:50%}}

方便、但存在相容性

2、JS控制

$(window).resize(function () {    resizeList();})function resizeList(){    var s_width=$(window).width();        //console.log("s_width:"+s_width);        if(s_width>600 && s_width <=1280)        {            $(".list-table1 li").css("width","25%");        }else if(s_width>400 && s_width <=600){            $(".list-table1 li").css("width","33.3%");        }else if(s_width>200 && s_width <=400){            $(".list-table1 li").css("width","50%");        }else if(s_width<=200){             $(".list-table1 li").css("width","100%");        }}
$(window).resize()即時擷取瀏覽器的寬度

注意事項:

1、圖片不變形

.a-common{width:auto;height:auto;}.a-common img{width:100%;height:auto;}

2、文字溢出處理

.title, .subtitle{width:auto;text-align:center;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;}

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.