2017-10-09 96 views
-1

我想在文本編輯器中添加註釋,其中註釋出現在文本註釋旁邊。對於我使用此功能:如何避免與固定頂部偏移重疊的文本

jQuery(document).ready(function() { 
    jQuery(this).find('span.comment').each(function() { 
     var id=jQuery(this).attr('data-id'); 
     var top=jQuery(this).offset().top - 40; 
     jQuery(document).find('article[id="'+id+'"]').each(function() { 
      jQuery(this).css('top',top); 
     }); 
    }); 
}); 

在此功能中我發現評論文本的位置,並在同一y位置添加註釋。

但是,當兩個評論文本彼此接近時,評論重疊,他們的文本不再可讀,有沒有辦法避免這個或另一個想法呢?

+2

歡迎來到Stack Overflow,你的問題應該包含[一個最小,完整和可驗證的例子](https://stackoverflow.com/help/mcve)。 – hungerstar

回答

-1

使您的註釋容器可滾動(overflow-y:auto;)並將其最大高度設置爲與註釋文本高度相同。