我添加overflow: scroll
嘗試使滾動條出現,但它不起作用,我無法弄清楚問題出在哪里。請看一下,非常感謝!
更重要的是,我使用的是 MacOS,它不起作用。但是基于同樣的代碼,我朋友用的是windows系統,可以運行。順便說一句,我們都使用Chrome瀏覽器。
這真的讓我很困惑:(
更新:我猜 MacOS 會默認隱藏滾動條?因為基于相同的代碼,MacOS 會隱藏滾動條,如果我向下滾動,則滾動條會在下一個顯示。但我朋友使用的是 Windows,即使他不滾動,滾動條也會一直顯示在頁面上下。
這是代碼。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>The Box Model</title>
<style>
body {
background-color: gray;
margin: 0px;
padding: 10px;
}
#box {
background-color: blue;
border: 10px solid black;
width: 500px;
box-sizing: border-box;
height: 200px;
overflow: scroll;
}
#content {
background-color: #90EE90; /*green*/
margin: 50px;
padding: 20px;
}
h1 {
margin-bottom: 30px;
}
</style>
</head>
<body>
<h1>Box Model</h1>
<div id="box">
<div id="content">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Lorem ipsum dolor sit amet, consectetur adipisicing elit.Lorem ipsum dolor sit amet, consectetur adipisicing elit.Lorem ipsum dolor sit amet, consectetur adipisicing elit.Lorem ipsum dolor sit amet, consectetur adipisicing elit.Lorem ipsum dolor sit amet, consectetur adipisicing elit.Lorem ipsum dolor sit amet, consectetur adipisicing elit.Lorem ipsum dolor sit amet, consectetur adipisicing elit.Lorem ipsum dolor sit amet, consectetur adipisicing elit.Lorem ipsum dolor sit amet, consectetur adipisicing elit.Lorem ipsum dolor sit amet, consectetur adipisicing elit.Lorem ipsum dolor sit amet, consectetur adipisicing elit.</div>
</div>
</body>
</html>
uj5u.com熱心網友回復:
<!DOCTYPE html>
<html>
<head>
<style>
div {
background-color: #eee;
width: 200px;
height: 100px;
border: 1px dotted black;
overflow: scroll;
}
</style>
</head>
<body>
<h2>Overflow: scroll</h2>
<p>Setting the overflow value to scroll, the overflow is clipped and a scrollbar is added to scroll inside the box. Note that this will add a scrollbar both horizontally and vertically (even if you do not need it):</p>
<div>You can use the overflow property when you want to have better control of the layout. The overflow property specifies what happens if content overflows an element's box.</div>
</body>
</html>
overflow : scroll ,只有在您固定框的大小并且框內的內容更大時才有效和可見。
uj5u.com熱心網友回復:
試試這個關于溢位滾動的查詢。
<!DOCTYPE html>
<html>
<head>
<style>
.Scroll-Testing {
background-color: rgb(15, 207, 255); width:500px; height: 400px; border: 1px dotted rgb(255, 95, 95);overflow-y: scroll; }
</style>
</head>
<body>
<h2>Overflow: scroll Testing</h2>
<div class="Scroll-Testing">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
Why do we use it?
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
Where does it come from?
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.</div>
</body>
</html>
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/360141.html