我想讓P
能夠承載比高度所能包含的文字更多的文字,以便文字可以向下滾動以便閱讀。 DIV CLASS="others"
有我想要的正確身高。 (500px)其父母高度有限的可滾動段落
問題是,當我使用overflow: scroll
函數時,它一直到頁面的底部。
編輯:忘了提及我希望標題「新聞」和「產品」沒有滾動條。
謝謝。
.others {
position: relative;
vertical-align: middle;
width: 70%;
background-color: #d0d0d0;
height: 500px;
margin: 0px;
padding: 40px 15% 20px 15%;
display: flex;
justify-content: center;
}
.others div {
width: 400px;
display: inline-block;
float: left;
margin: 0px 15px;
}
.others #news {
background-color: black;
color: white;
text-align: center;
}
.others #products {
background-color: black;
color: white;
text-align: center;
}
.others a {
color: white;
text-decoration: none !important;
}
.others #newsfeed, #productsfeed {
margin: 0px;
padding: 10px 0px;
background-color: lightgreen;
}
.others p {
margin: 0px;
padding: 10px 10px;
vertical-align: middle;
height: 800px;
overflow: scroll;
}
<DIV CLASS="others">
<DIV ID="news">
\t <A HREF="#"><H3 ID="newsfeed">News</H3></A>
\t <P>News will come here.</P>
</DIV>
<DIV ID="products">
\t <A HREF="#"><H3 ID="productsfeed">Products</H3></A>
\t <P>Cool photos here.</P>
</DIV>
</DIV>
爲什麼你在內部段落上設置'height:800px;'然後呢?這導致了這個問題。 – 2014-09-20 15:05:03
我試圖證明,如果我有很多文字,它將高達800px。或者正常的文本在代碼上會有不同的表示? – Papu 2014-09-20 15:10:40