1
代碼示例:http://codepen.io/asuh/pen/JgdLK我如何定位div讓它們在點擊功能中不可見?
這是用於我正在處理的響應式設計。列的數量將根據我的斷點和div的寬度在此斷點處發生變化
當您單擊任何div時,隱藏內容將顯示在相對於其父級的絕對定位div中。它充當鏈接下拉菜單。
在這個例子中,我需要做的是將活動下拉下的容器作爲目標,並使這些或那些容器淡出或不可見。目前,您可以看到通過下拉邊緣顯示的容器框陰影,我更希望它們完全或大部分不可見。
這裏的JS:
$('.module article').each(function() {
$(this).hide();
});
$('.module-content').click(function() {
var $this = $(this).closest('section').find('article');
$('.module article').not($this).slideUp();
$this.slideToggle('slow').addClass('active');
});
我一直想這樣的事情,但它不工作:
if($('.module article').hasClass('active')) {
$('.module:nth-child(3)').fadeTo('fast',0);
}
如何修改上面,使其工作?或者我以錯誤的方式接近它?
@ dr-molle哦,這看起來不錯!除此之外,當您立即關閉同一個div時,消失的容器不會再出現。有沒有辦法扭轉可見度:關閉div時隱藏? – micah
查看更新的代碼。它只隱藏文章時隱藏下面的元素。 –
這就像魔術一樣。你是一個巫師!非常感謝。 :) – micah