【发布时间】:2017-06-04 10:17:51
【问题描述】:
我使用 flexbox 将我的内容垂直居中在“主”标签内,但是当添加太多内容时,它会溢出到“标题”中。有没有一种方法可以计算出如果 div 超出屏幕上的某个垂直位置(256px - 高度设置为标题),它会从“main”中删除一个类(当前设置为 .vertical)。
我知道 .removeClass() 删除了类,但我不知道从哪里开始计算垂直位置。
HTML
<header>Nav</header>
<main class="vertical">A lot of text here</main>
CSS
body, html{margin:0; height:100%}
header{width:100%; height:256px; background:red;}
main{width:100%; height: calc(100% - 256px); background:#fff;}
.vertical{
display: flex;
flex-direction: column;
justify-content: center;
}
我确实希望这是有道理的。 非常感谢。
【问题讨论】:
标签: javascript jquery position removeclass