0
我想讓我的右手欄div向下滾動,我遇到了一些問題,我嘗試過使用position:fixed;但我寧願它保持靜止,直到它滾動過去。使用Javascript問題粘貼一個div
<script type="text/javascript">
$(document).ready(function() {
var s = $(".rightcol_infobox");
var pos = s.position();
$(window).scroll(function() {
var windowpos = $(window).scrollTop();
s.html("Distance from top:" + pos.top + "<br />Scroll position: " + windowpos);
if (windowpos >= pos.top) {
s.addClass("stick");
} else {
s.removeClass("stick");
}
});
});
</script>
看起來非常接近我想要的東西,但它似乎並沒有工作。這裏是一些使用CSS IM的:
div.rightcol_infobox {
float:left;
margin-left:20px;
margin-top:20px;
width:283px;
padding:0px 2px 10px 2px;
background-color:#eee;
border-radius:10px
}
div.mainpage {
float:left;
clear:left;
min-width:1000px;
overflow:visible;
margin:20px 0px 0px 0px;
}
div.maincontent {
float:left;
clear:left;
width:670px;
margin-top:20px;
}
.stick {
position:fixed;
top:0px;
}
HTML:
<!-- Right-column -->
<div class="rightcol_infobox">
<script SRC="../general/Socials_Techauth.js"></script>
<div class="infobox rounded">
<P class="infoboxheading">Enquiries</p>
<p class="leftcol_text">Enquire about our technical authoring services<A href="..\enquiry\enquirytechnicalauthoring_sb.htm" rel="shadowbox;width=400;height=450"> Click here</a></p>
</div>
<div class="infobox rounded">
<P class="infoboxheading">See also</p>
<p class="leftcol_text">Why use Armada to write your online help and user guides? <A href="whyusearmada.htm"> Click here</a></p>
<script SRC="../general/socials2_techauth.js"></script>
</div>
</div>
我一直在這幾天的現在似乎無法破解它 http://jsfiddle.net/dHW6b/1/
張貼您的HTML。或創建一個小提琴。 –
請創建一個小提琴。 –
@AvinVarghese「Javascript」不是「JavaScript」:) –