![](/img/trans.png)
[英]Aligning boxes(divs) of equal size in html symmetrically according to their number
[英]Display number of divs according to the window size
例如,下面的圖像在初始窗口位置。
當我減小窗口大小時,div的數量應相應更改。
編輯:每個地圖代表一個Div。
獲取地圖尺寸:
var maps = document.getElementsByClassName('.map');
for(var i = 0; i < maps.length; i++){
var map = maps[i];
var rect = map.getClientRects()[0];
map.left = rect.left;
map.top = rect.top;
map.width = rect.width;
map.height = rect.height;
}
屏幕調整大小事件,您將在其中檢查:
for(var i = 0; i < maps.length; i++){
if(maps[i].left + maps[i].width > screen.width ||
maps[i].top + maps[i].height> screen.height)
maps[i].style.display = 'none';
else
maps[i].style.display = 'block';
}
我尚未測試,希望它能正常工作
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.