Flexbox (Flexbox)
Flexbox (Flexbox) is a CSS layout model designed to provide flexible and adaptive arrangements for web pages. It enables page elements to be arranged and distributed within a container in a predictable manner by defining the behavior of the container and the items within it.
Use of flexbox
Declare it as flexbox by setting the container's display
property to flex
or :inline-flex
<!DOCTYPE html>
<html lang="cn">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>弹性盒</title>
<style>
#box {
width: 600px;
height: 150px;
border: 3px solid black;
display: flex;
}
#box div {
width: 100px;
height: 100px;
border: 1px dashed red;
}
</style>
</head>
<body>
<div id="box">
<div>1</div>
<