tft每日頭條

 > 圖文

 > css怎麼設置display line height

css怎麼設置display line height

圖文 更新时间:2024-08-12 06:14:11

css怎麼設置display line height?有是在寫樣式的時候,會碰到給div無論怎麼加樣式 overflow-y: auto 的時候,都不會出現垂直的滾動條,經過不斷折騰終于知道是啥原因導緻了,現在小編就來說說關于css怎麼設置display line height?下面内容希望能幫助到你,我們來一起看看吧!

css怎麼設置display line height(css設置高度height:100滾動條無法顯示的解決辦法)1

css怎麼設置display line height

有是在寫樣式的時候,會碰到給div無論怎麼加樣式 overflow-y: auto 的時候,都不會出現垂直的滾動條,經過不斷折騰終于知道是啥原因導緻了。

<style>

body{

height: 100%; //若是所有的div的高度都不固定,需要body高度也是100%,才可以出現滾動條

}

.parent{

//你自己樣式

height: 100%; //父元素的高度也需要是100%才可以出現滾動條

}

.children{

overflow-y: auto;

overflow-x: hidden;

height: 100%;

}

</style>

<div class="parent">

<div class="children">

xx-blog主題

xxzhuti主題網

</div>

</div>

大家可以試試,這樣子是無法出現滾動條的,若是想要出現滾動條,需要所有父元素的高度也要是百分之百,這樣才可以。

還有一種就是給父元素設置浮動,也可以出現滾動條,按照你自己頁面的需求寫即可。

<style>

.parent{

height: 100%; //父元素的高度也需要是100%才可以出現滾動條

position: fixed;

right: 0;

top: 0;

bottom: 0;

z-index: 2;

}

.children{

overflow-y: auto;

overflow-x: hidden;

height: 100%;

}

</style>

<div class="parent">

<div class="children">

xx-blog主題

xxzhuti主題網

</div>

</div>

,

更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!

查看全部

相关圖文资讯推荐

热门圖文资讯推荐

网友关注

Copyright 2023-2024 - www.tftnews.com All Rights Reserved