flex-basis: auto | width | initial | inherit;
<!DOCTYPE html>
<html>
<head>
<style>
.container {
display: flex;
background-color: lightblue;
}
.flex-item {
background-color: white;
text-align: center;
line-height: 40px;
font-size: 25px;
margin: 5px;
}
</style>
</head>
<body>
<h1> 示例 of the flex-basis property </h1>
<div class = "container">
<div class = "flex-item" style = "flex-basis: auto;"> auto </div>
<div class = "flex-item" style = "flex-basis: initial;"> initial </div>
<div class = "flex-item" style = "flex-basis: inherit;"> inherit </div>
<div class = "flex-item" style = "flex-basis: 150px;"> 150px </div>
<div class = "flex-item" style = "flex-basis: auto"> auto </div>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
.container {
height: 100px;
border: 2px solid red;
display: flex;
background-color: blue;
}
.container div{
padding-top: 25px;
flex-basis: 100px;
}
.flex-item{
text-align: center;
font-size: 25px;
}
.container div:nth-of-type(1) {
flex-basis: 50%;
}
.container div:nth-of-type(3) {
flex-basis: 200px;
}
.container div:nth-of-type(5) {
flex-basis: 7em;
}
</style>
</head>
<body>
<h1>
The flex-basis Property
</h1>
<div class = "container">
<div class = "flex-item" style= "background-color: lightblue;">
50%
</div>
<div class = "flex-item" style= "background-color: yellow;">
100px
</div>
<div class = "flex-item" style= "background-color: pink;">
200px
</div>
<div class = "flex-item" style= "background-color: orange;">
100px
</div>
<div class = "flex-item" style= "background-color: lightgreen;">
7em
</div>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
.container {
height: 100px;
border: 2px solid red;
display: flex;
}
.container div{
padding-top: 25px;
flex: 0 0 100px;
}
.flex-item{
text-align: center;
font-size: 25px;
}
</style>
</head>
<body>
<div class = "container">
<div class = "flex-item" style= "background-color: lightblue;">
1
</div>
<div class = "flex-item" style= "background-color: yellow;">
2
</div>
<div class = "flex-item" style= "background-color: pink;">
3
</div>
<div class = "flex-item" style= "background-color: orange;">
4
</div>
<div class = "flex-item" style= "background-color: lightgreen;">
5
</div>
</div>
</body>
</html>