實現動態加載的圖片頁面中縱向居中顯示

 function showImg(url){
            $("#imgDiv").html("<div id='imgBadDiv' style='display: flex;flex-direction: row;justify-content: center;align-content: center'><img id='badImg' src='"+url+"' style='max-height:600px;max-width:800px;' /></div>");
            $("#imgBadDiv img").load(function(){
                var h = $("#badImg").height();
                var top =(document.body.clientHeight-h)/2;
                $("#badImg").css("margin-top",top)
            });
            $("#imgDiv").show();
        }
發佈了123 篇原創文章 · 獲贊 28 · 訪問量 30萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章