所以我的段落块不适合我的页面,我的解决方案是使用滚动方法,因此当用户在向下箭头上盘旋时,它将向下滚动段落并显示更多文本。
alt text http://www.picamatic.com/view/2446369_scroll/
所以我附上了我的项目图片,你可以看到我向下滚动并向上滚动按钮。
这是我项目的HTML文件:
<div id="content1" class="scrolling-content">
<div>
<div id="story" style="overflow:hidden; width:40%;">
<h2 style="font-size:30px;">Quirino's Story</h2>
<p>Elpidio Quirino was a Filipino politician, and the sixth President of the Philippines.</p>
<p>He was born in Vigan, Ilocos Sur to Mariano Quirino and Gregoria Rivera, Quirino spent his early years in Aringay, La Union. He received secondary education at Vigan High School, then went to Manila where he worked as junior computer in the Bureau of Lands and as property clerk in the Manila police department. He graduated from Manila High School in 1911 and also passed the civil service examination, first-grade.</p>
<p>Quirino attended the University of the Philippines. In 1915, he earned his law degree from the university's College of Law, and was admitted to the bar later that year. He was engaged in the private practice of law until he was elected as member of the Philippine House of Representatives from 1919 to 1925, then as Senator from 1925 to 1931. He then served as Secretary of Finance and Secretary of the Interior in the Commonwealth government.</p>
<p>In 1934, Quirino was a member of the Philippine Independence mission to Washington D.C., headed by Manuel L. Quezon that secured the passage in the United States Congress of the Tydings-McDuffie Act. This legislation set the date for Philippine independence by 1945. Official declaration came on July 4, 1946.</p>
<p>During the Battle of Manila in World War II, his wife, Alicia Syquia, and three of his five children were killed as they were fleeing their home.</p>
<p>After the war, Quirino continued public service, becoming president pro tempore of the Senate. In 1946, he was elected first vice president of the independent Republic of the Philippines, serving under Manuel Roxas. He also served as secretary of state.</p>
<span onmouseover = "start_scroll_up()"; onmouseout="stopscrolling"; id="up"><img src="images/arrow_up.png" /></span>
<span id="down" onmouseover="start_scroll_down()"; onmouseout="stopscrolling"; ><img src="images/arrow_down.png" /></span>
</div>
</div>
</div>
这是Javascript文件:
var UpdateInterval = 20;
var PixelPerInterval = 2;
var scrollInterval;
function startScrollUp() {
scrollInterval = setInterval(scrollUp, UpdateInterval);
}
function startScrollDown() {
scrollInterval = setInterval(scrollDown, UpdateInterval);
function scrollDown() {
document.getElementById('story').scrollHeight += PixelPerInterval;
}
function scrollUp() {
document.getElementById('story').scrollHeight -= PixelPerInterval;
}
function stop_scrolling() {
clearInterval(scrollInterval);
}
谢谢你们!
答案 0 :(得分:1)
我修改了你的代码并制作了一个实例。这是一个完整的html页面。
<html><head> <title></title> </head> <body> <div id="content1" class="scrolling-content" style="height:100px;overflow-y:auto;"> <h2 style="font-size:30px;">Quirino's Story</h2> <p>Elpidio Quirino was a Filipino politician, and the sixth President of the Philippines.</p> <p>He was born in Vigan, Ilocos Sur to Mariano Quirino and Gregoria Rivera, Quirino spent his early years in Aringay, La Union. He received secondary education at Vigan High School, then went to Manila where he worked as junior computer in the Bureau of Lands and as property clerk in the Manila police department. He graduated from Manila High School in 1911 and also passed the civil service examination, first-grade.</p> <p>Quirino attended the University of the Philippines. In 1915, he earned his law degree from the university's College of Law, and was admitted to the bar later that year. He was engaged in the private practice of law until he was elected as member of the Philippine House of Representatives from 1919 to 1925, then as Senator from 1925 to 1931. He then served as Secretary of Finance and Secretary of the Interior in the Commonwealth government.</p> <p>In 1934, Quirino was a member of the Philippine Independence mission to Washington D.C., headed by Manuel L. Quezon that secured the passage in the United States Congress of the Tydings-McDuffie Act. This legislation set the date for Philippine independence by 1945. Official declaration came on July 4, 1946.</p> <p>During the Battle of Manila in World War II, his wife, Alicia Syquia, and three of his five children were killed as they were fleeing their home.</p> <p>After the war, Quirino continued public service, becoming president pro tempore of the Senate. In 1946, he was elected first vice president of the independent Republic of the Philippines, serving under Manuel Roxas. He also served as secretary of state.</p> </div> <span onmouseover = "startScrollUp();" onmouseout="stop_scrolling();"; id="up"><img src="images/arrow_up.png" /></span> <span id="down" onmouseover="startScrollDown();" onmouseout="stop_scrolling();" ><img src="images/arrow_down.png" /></span> <script type="text/javascript"> var UpdateInterval = 20; var PixelPerInterval = 2; var scrollInterval; function startScrollUp() { scrollInterval = setInterval(function(){scrollUp()}, UpdateInterval); } function startScrollDown() { scrollInterval = setInterval(function(){scrollDown()}, UpdateInterval); } function scrollDown() { document.getElementById('content1').scrollTop += PixelPerInterval; } function scrollUp() { document.getElementById('content1').scrollTop -= PixelPerInterval; } function stop_scrolling() { clearInterval(scrollInterval); } </script> </body>
你很亲密。
干杯,
安德鲁: - )