[CSS] flex
14819 ワード
レイアウトで広く使われているflexというやつについてお話しします.
flexは、ソートするアイテムごとにコンテナロールの親タグを指定する必要があります.親ラベルまたは子ラベルの位置が異なる属性もたくさんあります.
どの部分にどの属性を適用すべきかは毎回分からないようです.
私たちは生活符号化で提供されたコードを使用して文章を書きました.次のコードは文章を続けます.
flex-grow:子供のラベルnを両親にバタンと分けさせます. 注意
ここで特定の物の大きさを調整したい場合は、
2のものだけを持っていくとスペースが大きくなることがわかります.3、4++が占める空間はもっと大きくなります.
flex-basesの値を持つと、baseの値を減らします. holy grail layout その他
ツールバーの
flexは、ソートするアイテムごとにコンテナロールの親タグを指定する必要があります.親ラベルまたは子ラベルの位置が異なる属性もたくさんあります.
<container>
<item></item>
<item></item>
</container>
親コード:<container>
サブコード:<item>
定義時、// 부모태그 컨테이너
<container />
display
flex-direction
flex-wrap
flex-flow
justify-content
align-items
align-content
// 자식태그 정렬대상
<item />
order
flex-grow
flex-shrink
flex-basis
flex
align-self
本当に.プロジェクトをするのに苦労した部分が上のコードの内容です.どの部分にどの属性を適用すべきかは毎回分からないようです.
flex-grow
私たちは生活符号化で提供されたコードを使用して文章を書きました.次のコードは文章を続けます.
<!doctype>
<html>
<head>
<style>
.container{
background-color: powderblue;
height:200px;
display:flex;
flex-direction:row;
}
.item{
background-color: tomato;
color:white;
border:1px solid white;
}
.item:nth-child(2){
}
</style>
</head>
<body>
<div class="container">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
<div class="item">5</div>
</div>
</body>
</html>
flex-grow:子供のラベルnを両親にバタンと分けさせます.
flex-grow(0): 설정값이 0이기에 아무런 변화 X
flex-grow(1): 아래와 같이 변화
ここで特定の物の大きさを調整したい場合は、
.item:nth-child(2)
flex-grow:2;
残りのアイテムのgrowは1人状態で、2番目のアイテムだけが2人状態です.2のものだけを持っていくとスペースが大きくなることがわかります.3、4++が占める空間はもっと大きくなります.
flex-shrink
flex-basesの値を持つと、baseの値を減らします.
.item:nth-child(2)
flex-grow:2;
flex-shrink: 0
:大小変化なしflex-shrink: 1
:縮小flex-shrink: 2
:大きさ変化1よりも早く減少.3 4も同じです完全なコード
<!doctype>
<html>
<head>
<style>
.container{
background-color: powderblue;
height:200px;
display:flex;
flex-direction:row;
}
.item{
background-color: tomato;
color:white;
border:1px solid white;
}
.item:nth-child(1){
flex-basis: 150px;
flex-shrink: 1;
}
.item:nth-child(2){
flex-basis: 150px;
flex-shrink: 2;
}
</style>
</head>
<body>
<div class="container">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
<div class="item">5</div>
</div>
</body>
</html>
その他のプロパティー
Reference
この問題について([CSS] flex), 我々は、より多くの情報をここで見つけました https://velog.io/@potter/CSS-flexテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol