WIKI使用導(dǎo)航
站長百科導(dǎo)航
站長專題
- 網(wǎng)站推廣
- 網(wǎng)站程序
- 網(wǎng)站賺錢
- 虛擬主機(jī)
- cPanel
- 網(wǎng)址導(dǎo)航專題
- 云計(jì)算
- 微博營銷
- 虛擬主機(jī)管理系統(tǒng)
- 開放平臺
- WIKI程序與應(yīng)用
- 美國十大主機(jī)
Gallery: 外觀主題:AutoRC JavaScript:修訂間差異
來自站長百科
Firebrance(討論 | 貢獻(xiàn)) |
Firebrance(討論 | 貢獻(xiàn)) 無編輯摘要 ? |
||
第1行: | 第1行: | ||
這是AutoRC外觀主題的JavaScript源代碼。 | |||
?? /** | ?? /** | ||
?? * | ?? * 將邊欄或相冊容器的高度設(shè)為較高的那個(gè)值 | ||
?? */ | ?? */ | ||
?? function setWidthHeights() { | ?? function setWidthHeights() { | ||
?? ? var sidebar = document.getElementById('sidebar'); | ?? ? var sidebar = document.getElementById('sidebar'); | ||
?? ? var album = document.getElementById('album'); | ?? ? var album = document.getElementById('album'); | ||
?? ? // | ?? ? // 相片頁面 | ||
?? ? ? var photo = document.getElementById('photo'); | ?? ? ? var photo = document.getElementById('photo'); | ||
?? ? ? if (photo) { | ?? ? ? if (photo) { | ||
?? ? ? ? var photoWidth = album.offsetWidth - sidebar.offsetWidth; | ?? ? ? ? var photoWidth = album.offsetWidth - sidebar.offsetWidth; | ||
?? ? ? ? photo.style.width = (photoWidth - 18) + 'px'; | ?? ? ? ? photo.style.width = (photoWidth - 18) + 'px'; | ||
?? ? // | ?? ? // 相冊頁面 | ||
?? ? } else { | ?? ? } else { | ||
?? ? ? ? var item = getElementsByClassName('item', 'div'); | ?? ? ? ? var item = getElementsByClassName('item', 'div'); | ||
第23行: | 第23行: | ||
?? ? ? ? } | ?? ? ? ? } | ||
?? ? } | ?? ? } | ||
?? ? // | ?? ? // 將邊欄高度和相冊/相片容器高度設(shè)為均等 | ||
?? ? if (sidebar.offsetHeight > album.offsetHeight) { | ?? ? if (sidebar.offsetHeight > album.offsetHeight) { | ||
?? ? ? album.style.height = sidebar.offsetHeight + 'px'; | ?? ? ? album.style.height = sidebar.offsetHeight + 'px'; |
2008年11月4日 (二) 16:55的最新版本
這是AutoRC外觀主題的JavaScript源代碼。
/** * 將邊欄或相冊容器的高度設(shè)為較高的那個(gè)值 */ function setWidthHeights() { var sidebar = document.getElementById('sidebar'); var album = document.getElementById('album'); // 相片頁面 var photo = document.getElementById('photo'); if (photo) { var photoWidth = album.offsetWidth - sidebar.offsetWidth; photo.style.width = (photoWidth - 18) + 'px'; // 相冊頁面 } else { var item = getElementsByClassName('item', 'div'); var albumWidth = album.offsetWidth - sidebar.offsetWidth; var columns = Math.floor(albumWidth / item[0].offsetWidth); var difference = albumWidth - (columns * item[0].offsetWidth); var newItemWidth = (difference / columns) + item[0].offsetWidth - 18; for (var i=0; i<item.length; i++) { item[i].style.width = newItemWidth + 'px'; } } // 將邊欄高度和相冊/相片容器高度設(shè)為均等 if (sidebar.offsetHeight > album.offsetHeight) { album.style.height = sidebar.offsetHeight + 'px'; } else { sidebar.style.height = album.offsetHeight + 'px'; } } function getElementsByClassName(cssclass, element) { var arr = new Array(); var elem; var elems = document.getElementsByTagName(element); for (var cls, i = 0; (elem = elems[i]); i++ ) { if (elem.className == cssclass) { arr[arr.length] = elem; } } return arr; }