借助 CSS 设置一个弹性项目相对于其他弹性项目展开的量
使用 flex-grow 属性增加 flex 项目的大小。可以将它与一个或多个 flex 项目一同使用。
示例
以下代码定义了带有 flex-grow 属性的元素。这里,Q3 flex 项目大于其他项目:
<!DOCTYPE html>
<html>
<head>
<style>
.mycontainer {
display: flex;
background-color: orange;
align-content: space-between;
}
.mycontainer > div {
background-color: white;
text-align: center;
line-height: 40px;
font-size: 25px;
width: 100px;
margin: 5px;
}
</style>
</head>
<body>
<h1>Quiz</h1>
<div class = "mycontainer">
<div style = "flex-grow: 1">Q1</div>
<div style = "flex-grow: 1">Q2</div>
<div style = "flex-grow: 20">Q3</div>
<div style = "flex-grow: 1">Q4</div>
<div style = "flex-grow: 1">Q5</div>
</div>
</body>
</html>
广告
数据结构
联网
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP