[英]JavaScript/jQuery: Offset a <DIV> based on another <DIV> height after page load
我正在嘗試這樣做:
!!! 剛剛得知我不能提交圖片,因為我是新來的...
我已在Diino上放置了完美描述問題的圖像: 鏈接到Diino文件夾 (18,9kb)以及示例文件(html,css等)。
移動的DIV具有以下CSS:
div.linkr-bm {
float:left;
height:1px;
overflow:visible;
position:relative;
top:68px;
z-index:2;
}
具有高度值的DIV具有以下CSS:
.entry-tags {
float:left;
font-family:Calibri;
font-size:small;
font-weight:bold;
line-height:1.6;
margin:0;
padding:0;
width:400px;
display:block;
}
用CSS移動DIV是靜態的,但是使用此腳本在頁面加載后我無法使它隨jQuery移動:
jQuery(document).ready(function(){
$('.entry').each(function(){
var height = $(this).children('.entry-tags').height();
$(this).children('.linkr-bm').css('top', height);
});
});
我非常感謝我能得到的任何幫助。 謝謝!
嘗試使用以下代碼:
jQuery(function(){
jQuery('.entry').each(function(){
$(this).find('.linkr-bm').css('top', $(this).find('.entry_tags').height() + 'px');
});
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.