溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

CSS3如何實(shí)現(xiàn)微信小程序瀑布流布局

發(fā)布時(shí)間:2020-10-16 16:26:53 來源:億速云 閱讀:202 作者:小新 欄目:web開發(fā)

CSS3如何實(shí)現(xiàn)微信小程序瀑布流布局?這個(gè)問題可能是我們?nèi)粘W(xué)習(xí)或工作經(jīng)常見到的。希望通過這個(gè)問題能讓你收獲頗深。下面是小編給大家?guī)淼膮⒖純?nèi)容,讓我們一起來看看吧!

1.column-count 屬性規(guī)定元素應(yīng)該被分隔的列數(shù):

-moz-column-count:3;     /* Firefox */
-webkit-column-count:3; /* Safari 和 Chrome */
column-count:3;

2.column-gap 屬性規(guī)定列之間的間隔:

-moz-column-gap:40px;        /* Firefox */
-webkit-column-gap:40px;    /* Safari 和 Chrome */
column-gap:40px;

3.column-rule 屬性設(shè)置列之間的寬度、樣式和顏色規(guī)則。

-moz-column-rule:3px outset #ff0000;    /* Firefox */
-webkit-column-rule:3px outset #ff0000;    /* Safari and Chrome */
column-rule:3px outset #ff0000;

4.column-span 屬性規(guī)定元素應(yīng)橫跨多少列。
Internet Explorer 10 和 Opera 支持 column-span 屬性。
Safari 和 Chrome 支持替代的 -webkit-column-span 屬性。
/只有 Chrome 和 Opera 支持 column-span 屬性。/

-webkit-column-span:all; /* Chrome */
column-span:all;

5.column-width 屬性規(guī)定列的寬度。
Internet Explorer 10 和 Opera 支持 column-width 屬性。
Firefox 支持替代的 -moz-column-width 屬性。
Safari 和 Chrome 支持替代的 -webkit-column-width 屬性。
注釋:Internet Explorer 9 以及更早版本的瀏覽器不支持 column-width 屬性。

column-width:100px;
-moz-column-width:100px; /* Firefox */
-webkit-column-width:100px; /* Safari 和 Chrome */

微信小程序瀑布流布局

wxml

<view class='case-page'>
  <view class='list-masonry'>
    <view class='item-masonry' wx:for="{{note}}">
      <image src='{{item.url}}' mode='widthFix'></image>
      <text>{{item.title}}</text>
    </view>
  </view>
</view>

wxss

page{
  background-color: #eee;
}
.case-page{
  padding:20rpx;
}
.list-masonry{
  column-count: 2;
  column-gap: 20rpx;
}
.item-masonry{
  background-color: #fff;
  break-inside: avoid;/*避免在元素內(nèi)部插入分頁符*/
  box-sizing: border-box; 
  padding: 20rpx;
  margin-bottom:20rpx;
}
.item-masonry image {
  width: 100%;
}

JS

Page({
  /**
   * 頁面的初始數(shù)據(jù)
   */
  data: {
    imgWidth: 0, imgHeight: 0,
    note: [
      {
        title: '案例名稱',
        url: 'https://cache.yisu.com/upload/information/20200318/93/10901.jpg',
      },
      {
        title: '你所不知道的紅酒知識',
        url: 'http://img3.imgtn.bdimg.com/it/u=1417732605,3777474040&fm=26&gp=0.jpg',
      },
      {
        title: '紅酒知識',
        url: 'http://f10.baidu.com/it/u=121654667,1482133440&fm=72',
      },
      {
        title: '案例名稱',
        url: 'https://cache.yisu.com/upload/information/20200318/93/10902.jpg',
      },
      {
        title: '案例名稱',
        url: 'http://img3.imgtn.bdimg.com/it/u=1417732605,3777474040&fm=26&gp=0.jpg'
      },

      {
        title: '案例名稱',
        url: 'http://f10.baidu.com/it/u=121654667,1482133440&fm=72'
      },
      {
        title: '案例名稱',
        url: 'http://img4.imgtn.bdimg.com/it/u=2748975304,2710656664&fm=26&gp=0.jpg'
      },
      {
        title: '案例名稱',
        url: 'http://img2.imgtn.bdimg.com/it/u=1561660534,130168102&fm=26&gp=0.jpg'
      },
      {
        title: '案例名稱',
        url: 'http://img3.imgtn.bdimg.com/it/u=1417732605,3777474040&fm=26&gp=0.jpg'
      }
    ]
  }
})

感謝各位的閱讀!看完上述內(nèi)容,你們對CSS3如何實(shí)現(xiàn)微信小程序瀑布流布局大概了解了嗎?希望文章內(nèi)容對大家有所幫助。如果想了解更多相關(guān)文章內(nèi)容,歡迎關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI