我用jQuery創建了一個簡單的顯示/隱藏。我有兩個問題:jQuery Show DIV溢出其他DIV(頁腳)
1)當我顯示我隱藏的DIV時,它出現在頁腳上方。我想要發生的是頁腳自動下降。
2)如何在頁面加載時打開聯繫我們DIV而無需介紹ID?
這裏是我的小提琴:http://jsfiddle.net/oampz/WkuMg/10/
HTML:
<ul class="outline">
<li>
<div class="heading"> <a>Contact Us</a>
</div>
<div class="content">
<ul>
<h1>Contact Us</h1>
<li>
<a href="">How to reach us</a>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</li>
<li>
<a href="">How to email us</a>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</li>
<li>
<a href="">Contact Number</a>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</li>
</ul>
</div>
</li>
<li>
<div class="heading">
<a>Products</a>
</div>
<div class="content">
<ul>
<h1>Products</h1>
<li>
<a href="">Tabels</a>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</li>
<li>
<a href="">Ladders</a>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</li>
<li>
<a href="">Chairs</a>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</li>
</ul>
</div>
</li>
<li>
<div class="heading">
<a>Our Offices</a>
</div>
<div class="content">
<ul>
<h1>Our offices</h1>
<li>
<a href="">Bristol</a>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</li>
<li>
<a href="">Manchester</a>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</li>
<li>
<a href="">Leeds</a>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</li>
</ul>
</div>
</li>
</ul>
<div class="footer">Footer</div>
的jQuery:
$(".heading").click(function() {
var $this = $(this);
$this.next(".content").show(400);
$this.parent().siblings().children().next().hide();
return false;
});
CSS:
.content {
display: none;
}
.outline {
position: relative;
}
.heading {
font-weight: bold;
padding: 15px 0 15px 20px;
background: GREY;
width: 30%;
}
.content {
width: 100%;
margin-left: 35%;
position: absolute;
top: -2px;
width: 60%;
overflow:hidden;
}
.footer {
width: 100%;
background: blue;
color: white;
}
你的CSS呢? – TylerH
@TylerH - CSS添加(它也在小提琴) –
看看http://www.cssstickyfooter.com/ @OamPsy – TylerH