亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
  • 11111

    查看全部
    0 采集 收起 來源:練習題

    2022-02-28

  • 444

    查看全部
    0 采集 收起 來源:練習題

    2022-02-28

  • 333

    查看全部
  • offsetWidth = 本身寬度 + 內層padding*2 + border*2 + 外層padding*2

    查看全部
  • flaot


    等寬不等高

    查看全部
  • 查看全部
  • offsetHeight 不包括 margin

    查看全部
  • 2-7編程練習


    查看全部
    0 采集 收起 來源:編程練習

    2019-10-03

  • 2-6編程練習

    查看全部
    0 采集 收起 來源:編程練習

    2019-10-03

  • 藍色線條是藍塊距離頁面頂端的距離加上滑塊一半的高度,黑色線條是瀏覽器高度加上已經劃過的距離。滾動時候,藍色線條小于黑色時發生預加載。

    查看全部
  • <template>
    ??<div?id="main">
    ????<div?class="box"?v-for="i?in?arr">
    ??????<div?class="pic">
    ????????<img?:src="i.src"?alt="">
    ??????</div>
    ????</div>
    ??</div>
    </template>
    
    <script>
    ????export?default?{
    ????????name:?"waterfall",
    ????????data(){
    ??????????return?{
    ????????????arr:[
    ??????????????{src:"../../static/images/0.jpg"},{src:"../../static/images/1.jpg"},{src:"../../static/images/2.jpg"},
    ??????????????{src:"../../static/images/3.jpg"},{src:"../../static/images/4.jpg"},{src:"../../static/images/5.jpg"},
    ??????????????{src:"../../static/images/6.jpg"},{src:"../../static/images/7.jpg"},{src:"../../static/images/8.jpg"},
    ??????????????{src:"../../static/images/9.jpg"},{src:"../../static/images/10.jpg"},{src:"../../static/images/11.jpg"},
    ??????????????{src:"../../static/images/12.jpg"},{src:"../../static/images/13.jpg"},{src:"../../static/images/14.jpg"},
    ??????????????{src:"../../static/images/15.jpg"},{src:"../../static/images/16.jpg"},{src:"../../static/images/17.jpg"},
    ??????????????{src:"../../static/images/18.jpg"},?{src:"../../static/images/19.jpg"},{src:"../../static/images/20.jpg"}
    ??????????????],
    
    ????????????arr_high:[],?minHigh:"",?minIndex:"",?flag:true,?count:0
    ??????????}
    ????????},
    ????????methods:{
    ??????????//預加載
    ??????????loadimg(){
    ????????????var?count?=?0;
    ????????????var?len?=?this.arr.length;
    
    ????????????this.arr.forEach((val,index)=>{
    ??????????????var?imgObj?=?new?Image();
    ??????????????imgObj.src?=?val.src;
    ??????????????imgObj.onload?=?()=>?{
    ????????????????count++;
    ????????????????if(count?===?len){
    ??????????????????this.waterfall();
    ????????????????}
    ??????????????}
    ????????????});
    ??????????},
    ??????????//流式布局
    ??????????waterfall(){
    ????????????var?boxW?=?document.getElementsByClassName("box")[0].offsetWidth;
    ????????????var?windowW?=?document.documentElement.offsetWidth?||?document.body.offsetWidth;
    ????????????var?cols?=?Math.floor(windowW/boxW);
    ????????????document.getElementById("main").style.width?=?boxW?*?cols?+?"px";
    ????????????this.arr_high?=?[];
    ????????????for(var?i?=?0;i?<?document.getElementsByClassName("box").length;i++){
    ??????????????if(i?<?cols){
    ????????????????this.arr_high.push(document.getElementsByClassName("box")[i].offsetHeight);
    ??????????????}else{
    ????????????????this.minHigh?=?Math.min.apply(null,this.arr_high);
    ????????????????this.arr_high.forEach((val,index)=>{
    ??????????????????if(val?===?this.minHigh)
    ????????????????????this.minIndex?=?index;
    ????????????????});
    ????????????????document.getElementsByClassName("box")[i].style.position?=?"absolute";
    ????????????????document.getElementsByClassName("box")[i].style.left?=?boxW?*?this.minIndex?+?"px";
    ????????????????document.getElementsByClassName("box")[i].style.top?=?this.minHigh?+?"px";
    ????????????????this.arr_high[this.minIndex]?+=?document.getElementsByClassName("box")[i].offsetHeight;
    ??????????????}
    ????????????}
    ??????????},
    ??????????//是否滑動到底部
    ??????????ifLastBox(){
    ????????????var?lastBox?=?document.getElementsByClassName("box")[document.getElementsByClassName("box").length?-?1];
    ????????????var?scrollHigh?=?document.body.scrollTop?||?document.documentElement.scrollTop;
    ????????????var?screenHigh?=?document.body.clientHeight?||?document.documentElement.clientHeight;
    ????????????return?((scrollHigh?+?screenHigh)?>?(lastBox.offsetTop?+?lastBox.offsetHeight/2))???true?:?false;
    ??????????},
    ????????},
    ????????mounted:function?()?{
    ??????????this.$nextTick(function?()?{
    ????????????this.loadimg();
    ????????????window.onscroll?=?()=>?{
    ??????????????if(this.ifLastBox()){
    ????????????????this.arr.forEach((val,index)=>{
    ??????????????????var?obj?=?{};
    ??????????????????obj.src?=?val.src;
    ??????????????????this.arr.push(obj);
    ????????????????});
    ????????????????this.loadimg();
    ??????????????}
    ????????????}
    ??????????});
    ????????}
    ????}
    </script>
    
    <style?scoped>
    ??*{margin:?0;?padding:?0;}
    ??#main{position:?relative;?margin:?0?auto;}
    ??.box{padding:?10px;?float:?left;}
    ??.pic{padding:?10px;?background-color:?#fff;?border-radius:?10px;?box-shadow:?0?0?5px?#ccc;?border:?1px?#ccc?solid;}
    ??.pic?img{width:?300px;?height:?auto;?background:?url("../../static/echo/images/loading.gif")?50%?no-repeat;}
    </style>

    vue.js ?—— 原生JS + 圖片預加載重寫流式布局,解決代碼堆疊問題 ?

    查看全部
  • 什么情況下適合使用內邊距卻不適使用外邊距?

    查看全部
  • 記得補噢噢噢噢

    查看全部
    0 采集 收起 來源:編程挑戰

    2018-10-24

  • jQuery的兩大優點:支持連綴,隱式迭代

    查看全部
  • 瀑布流
    查看全部
  • 瀑布流布局三種實現方式:JavaScript原生方法;jQuery方法;CSS3的多欄布局。

    瀑布流特點:等寬不登高。

    查看全部
  • <!DOCTYPE?html>
    <html>
    <head>
    ????<meta?charset="utf-8">
    ????<title>圖片瀑布流特效</title>
    ????<style?type="text/css"?media="screen">
    ????????*{margin:?0;padding:?0;}
    ????????.container{
    ????????width:?1150px;
    ????????margin:?0?auto;
    ????????height:?auto;
    ????????padding:?50px?0?50px?0;
    ????????-webkit-column-count:?5;
    ????????-moz-column-count:?5;
    ????????-o-column-count:?5;
    ????????-ms-column-count:?5;
    ????????}
    ????????.container?img{
    ????????width:?165px;
    ????????height:?auto;
    ????????padding:?10px;
    ????????margin-top:?15px;
    ????????border:?1px?solid?#ccc;
    ????????border-radius:?6px;
    ????????}
    </style>
    </head>
    <boy>
    ????<div?class="container">
    ????????<img?src="img/0.jpg"?alt="">
    ????????<img?src="img/1.jpg"?alt="">
    ????????<img?src="img/2.jpg"?alt="">
    ????????<img?src="img/3.jpg"?alt="">
    ????????<img?src="img/4.jpg"?alt="">
    ????????<img?src="img/5.jpg"?alt="">
    ????????<img?src="img/6.jpg"?alt="">
    ????????<img?src="img/7.jpg"?alt="">
    ????????<img?src="img/8.jpg"?alt="">
    ????????<img?src="img/9.jpg"?alt="">
    ????????<img?src="img/10.jpg"?alt="">
    ????????<img?src="img/11.jpg"?alt="">
    ????????<img?src="img/12.jpg"?alt="">
    ????</div>
    </body>
    </html>

    圖片來自于慕課網本堂課程跟學圖片

    https://img1.sycdn.imooc.com//5b1fbe7b000187ec13580940.jpg

    查看全部
  • https://codepen.io/yu363474235/pen/BVzdLZ

    這個是我寫的瀑布流demo

    瀑布流的特點是等寬不等高

    瀑布流的原理是通過計算,按照絕對定位的原理讓他出現在相對應的位置上的。

    • 大的盒子第一個盒子#main是要按照相對定位

    • 每個盒子之間的距離是通過padding的方式作用在第二個.box的盒子實現的。

    查看全部
  • 瀑布流的實現方式:

    1. JavaScript實現

    2. JQuery

    3. CSS3


    查看全部
  • 瀑布流布局

    查看全部
首頁上一頁1234567下一頁尾頁

舉報

0/150
提交
取消
課程須知
1.你一定對HTML+CSS比較熟悉; 2.掌握一定的JS基礎知識,尤其是函數封裝、調用等知識; 3.對jQuery相關知識掌握。
老師告訴你能學到什么?
1.學會實現瀑布流布局實現的三種方式; 2.div如何定位和排序; 3.掌握CSS3中多欄布局的知識。

微信掃碼,參與3人拼團

微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

友情提示:

您好,此課程屬于遷移課程,您已購買該課程,無需重復購買,感謝您對慕課網的支持!