簡體   English   中英

JavaScript / jQuery:偏移a <DIV> 基於另一個 <DIV> 頁面加載后的高度

[英]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);

 }); 
});
  • DIV每頁迭代六次
  • DIV具有類(沒有#ID)
  • 需要說明的是:這是一個黑客,因為我無權訪問DIV訂單,因此必須在呈現該DIV之后將其移動到位。 問題是帶有標簽的div可以從一行更改為三行。 這就是為什么必須計算偏移量的原因。

我非常感謝我能得到的任何幫助。 謝謝!

嘗試使用以下代碼:

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM