flex實(shí)現(xiàn)中間內(nèi)容自適應(yīng)高度

dmeo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>用flex 實(shí)現(xiàn)中間內(nèi)容自適應(yīng)高度</title>
<style>
body, html {
width: 100%;
height: 100%;
}
.content {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
}
.content .flex-test {
display: flex;
/* 排列方向-自上向下 */
flex-direction: column;
flex: auto;
width: 150px;
}
.content .flex-test .test1 {
display: flex;
justify-content: center;
margin-top: 10px;
background: #c6c6c6;
}
.content .flex-test .test2{
flex: auto;
overflow-y: scroll;
height: 0;
background: #666;
}
.content .flex-test .test3{
height: 50px;
background: #ccc;
display: flex;
align-items: center;
justify-content: center;
}
</style>
</head>
<body>
<div class="content">
<div class="flex-test">
<div class="test1">
<p>java</p>
<p>c++ </p>
<p>node </p>
</div>
<div class="test2">
開(kāi)始~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~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(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容