有一些浮动 div 相互重叠。当用户将鼠标悬停在它们上面时,高度会随着 jQuery 命令增加:
$(".concert").hover(function () {
$(this).parent().find(".concert[opened='opened'] .concertbody").animate({ height: "0px" }, { duration: 400, queue: false });
$(this).parent().find(".concert[opened='opened'] .concertHeader .middle").css("background-image", "url(Images/concert-header-back.png)");
$(this).parent().find(".concert[opened='opened'] .concertbody").css("border", "none");
$(this).parent().find(".concert[opened='opened'] .concertbody .concertDetails").css("visibility", "hidden");
$(this).find(".concertbody").animate({ height: "276px" }, { duration: 400, queue: false });
$(this).find(".concertHeader .middle").css("background-image", "url(Images/concert-header-back-hover.png)");
$(this).find(".concertbody").css("border", "1px solid whitesmoke");
$(this).find(".concertbody .concertDetails").css("visibility", "visible");
$(this).parent().find(".concert[opened='opened']").removeAttr("opened");
$(this).attr("opened", "opened");
});
布局还可以,其他 div 下降,但是当我使用 firebug 并检查其他 div 标签时,位置没有改变。
页面的 Html :
<div class="parent">
<div class="concert" id="ct1">
<div class="concertHeader">
<div class="middle">
<span class="concertName">کنسرت همایون شجریان</span>
<span class="concertCity">تهران</span>
</div>
</div>
<div class="concertbody">
<div class="concertDetails">
<span>محل دیدار : سالن همایش های بین المللی میلاد تهران</span>
<select class="test2">
<option value="1">16:30</option>
<option value="2">18:50</option>
</select>
<select class="test">
<option value="1">بیست و هشتم اردیبهت ماه نود و دو</option>
<option value="2">بیست و هشتم اردیبهت ماه نود و دو</option>
<option value="3">بیست و هشتم اردیبهت ماه نودو دو</option>
</select>
</div>
</div>
</div>
<div class="concert" id="ct2">
<div class="concertHeader">
<div class="middle">
<span class="concertName">کنسرت همایون شجریان</span>
<span class="concertCity">تهران</span>
</div>
</div>
<div class="concertbody">
<div class="concertDetails"></div>
</div>
</div>
<div class="concert" id="ct3">
<div class="concertHeader">
<div class="middle">
<span class="concertName">کنسرت همایون شجریان</span>
<span class="concertCity">تهران</span>
</div>
</div>
<div class="concertbody">
<div class="concertDetails"></div>
</div>
</div>
<div class="concert" id="ct4">
<div class="concertHeader">
<div class="middle">
<span class="concertName">کنسرت همایون شجریان</span>
<span class="concertCity">تهران</span>
</div>
</div>
<div class="concertbody">
<div class="concertDetails"></div>
</div>
</div>
<div class="concert" id="ct5">
<div class="concertHeader">
<div class="middle">
<span class="concertName">کنسرت همایون شجریان</span>
<span class="concertCity">تهران</span>
</div>
</div>
和 CSS :
.container {
width: 972px;
height: 532px;
margin-right: auto;
margin-left: auto;
border: 1px solid white;
border-radius: 5px;
}
.parent {
width: 324px;
height: 490px;
float: right;
}
.parent .concert {
width: 324px;
height: 40px;
margin: 2px;
}
.middle {
--background-image:url("../Images/concert-header-back.png");
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2JmYmZiZiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNlNWU1ZTUiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, rgba(191,191,191,1) 0%, rgba(229,229,229,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(191,191,191,1)), color-stop(100%,rgba(229,229,229,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(191,191,191,1) 0%,rgba(229,229,229,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(191,191,191,1) 0%,rgba(229,229,229,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(191,191,191,1) 0%,rgba(229,229,229,1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(191,191,191,1) 0%,rgba(229,229,229,1) 100%); /* W3C */
width: 320px;
height: 40px;
float: right;
border-radius: 5px;
}
.concertHeader:hover .middle {
width: 320px;
height: 40px;
float: right;
}
.rightSide {
background-image: url("../Images/concert-header-right-side.png");
width: 5px;
height: 40px;
float: right;
}
.leftSide {
background-image: url("../Images/concert-header-left-side.png");
width: 5px;
float: right;
height: 40px;
}
.concertName, .concertCity {
font-size: 8pt;
color: Black;
margin-top: 16px;
}
.concertName {
width: 250px;
display: inline-block;
margin-right: 10px;
}
.concertCity {
margin-right: 5px;
}
.concertbody {
height: 0px;
width: 318px;
margin-right: 0px;
margin-top: 1px;
margin-bottom: 1px;
border-radius: 5px;
}
这个问题我该怎么办?
问候