當前任何時候當您縮小頁面時,我的元素最終會相互移動,而不僅僅是導致頁面滾動。任何人都可以指向正確的方向嗎?當頁面縮小時,保持元素不會相互摺疊
<html>
<head>
<title> Div Blocks</title>
<style type="text/css">
html {
background: url(bgo.jpg) no-repeat center center ;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
position:relative;
}
a{
cursor : url("nav.png"), pointer;
}
div.one a
{
position:absolute;
top:50px;
left:60px;
width: 400px;
height: 100px;
text-decoration:none;
background:url("branding.png");
background-repeat:no-repeat;
padding-bottom:35px;
}
div.one a:hover
{background: url("brandingalt.png");
background-position: 0px 0px;
background-repeat:no-repeat;
}
div.two a
{
position: absolute;
top:264px;
left:60px;
width: 400px;
height: 100px;
text-decoration:none;
background:url("marketing.png");
background-repeat:no-repeat;
padding-bottom:35px;
}
div.two a:hover
{background: url("marketingalt.png");
background-position:0px 0px;
background-repeat:no-repeat;
}
div.three a
{
position: absolute;
top:457px;
left:56px;
width: 500px;
height: 100px;
text-decoration:none;
background:url("ecommerce.png");
background-repeat:no-repeat;
padding-bottom:20px;
}
div.three a:hover
{background: url("ecommercealt.png");
background-position: 0 0px;
background-repeat:no-repeat;
}
div.r1 a
{
position: absolute;
top:50px;
right:60px;
width: 400px;
height: 100px;
text-decoration:none;
background:url("webdesign.png");
background-repeat:no-repeat;
padding-bottom:25px;
}
div.r1 a:hover
{background: url("webdesignalt.png");
background-position: 0px 0px;
background-repeat:no-repeat;
}
div.r2 a
{
position: absolute;
top:254px;
right:75px;
width: 450px;
height: 150px;
text-decoration:none;
background:url("optimization.png");
background-repeat:no-repeat;
padding-bottom:20px;
}
div.r2 a:hover
{background: url("optimizationalt.png");
background-repeat:no-repeat;
}
div.r3 a
{
position: absolute;
top:457px;
right:60px;
width: 400px;
height: 75px;
text-decoration:none;
padding-bottom: 20px;
background:url(packaging.png);
background-repeat:no-repeat;
}
div.r3 a:hover
{background: url("packagingalt.png");
background-repeat: no-repeat;
}
</style>
</head>
<body>
<div class="one">
<a href="#" value="Branding" class="go" ></a>
</div>
<div class="two">
<a href="#" class="go"></a>
</div>
<div class="three">
<a href="#"class="go" ></a>
</div>
<div class="r1">
<a href="#"class="go" ></a>
</div>
<div class="r2">
<a href="#"class="go" ></a>
</div>
<div class="r3">
<a href="#"class="go" ></a>
</div>
</body>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script>
$("a").click(function(event){
event.preventDefault(); // prevent the link from changing the location
$(this)
.closest("div") // select the parent div of the link
.siblings() // select all the siblings of the div
.hide("slow") // hide them
setTimeout(function() {
$(".go").animate({top: "0"}, "slow");},1200);
});
</script>
我試着漂浮的元素,使用表技巧,使用溢出,但我似乎無法讓它正常工作。
我不會回答這個問題,因爲我有點不確定,但是您對所有這些div都使用'position:absolute;',所以當您縮小頁面時,畫布大小會發生變化。有些位於左側,右側是一些。如果你把所有東西都放在左邊,它應該可以工作...... – 2011-12-24 19:42:34
你有屏幕截圖嗎?您沒有發佈圖形,因此很難重現。 我試圖在這裏重現您的頁面,但很難弄清楚您想要做什麼。 http://jsfiddle.net/RQ8QA/ – agarcian 2011-12-24 19:43:14
定位一切從左邊的工作很好,非常感謝時間! – matture 2011-12-24 19:45:29