本文介绍了使用jQuery砌体与Absolutely Positioned Parent?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个下拉菜单(ul.sub-menu),里面的项目(ul.sub-menu> li)我想应用jQuery Masonry,但我的下拉列表绝对定位。有没有办法做到这一点并保持我对父元素的绝对定位?
I have a dropdown (ul.sub-menu) with items inside (ul.sub-menu > li) that I'd like to apply jQuery Masonry to, but my dropdown is absolutely positioned. Is there a way to do this and keep my absolute positioning on the parent element?
Javascript
jQuery("ul > li > ul.sub-menu").masonry({
itemSelector: '.brick',
columnWidth: 300
});
HTML
<ul>
<li id="menu-item-9451" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-9451"><a href="/solutions/" >Solutions</a>
<ul class="sub-menu">
<li id="menu-item-9458" class="brick"><a href="/solutions/internal-social-software/" >Internal Social Software</a></li>
<li id="menu-item-9457" class="brick"><a href="/solutions/video-content-managment/" >Video Content Managment</a></li>
<li id="menu-item-9456" class="brick"><a href="/solutions/enterprise-content-management/" >Enterprise Content Management</a></li>
<li id="menu-item-9455" class="brick"><a href="/solutions/secure-file-sharing/" >Secure File Sharing</a></li>
<li id="menu-item-9454" class="brick"><a href="/solutions/redaction-and-document-viewing/" >Redaction and Document Viewing</a></li>
<li id="menu-item-9453" class="brick"><a href="/solutions/real-time-business-intelligence/" >Real Time Business Intelligence</a></li>
<li id="menu-item-9452" class="brick"><a href="/solutions/mobile-enterprise-applications/" >Mobile Enterprise Applications</a></li>
</ul>
</li>
</ul>
推荐答案
在您的Masonry设置中尝试:
In your Masonry settings try:
containerStyle: { position: 'absolute' }
默认情况下,Masonry在容器上设置 position:relative
。
By default, Masonry sets position: relative
on the container.
这篇关于使用jQuery砌体与Absolutely Positioned Parent?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!