ç¥è¯ç¹-------å¸å±æ»æ¬~~~~flexå¸å±-gridå¸å±-å£æ¯å¸å±
程序员文章站
2022-03-25 13:49:30
...
flexå¸å±:(导èªå¸å±)
<!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å¸å±</title>
<style lang="">
header {
display: flex;
background-color: antiquewhite;
}
header>div{
padding:5px 10px;
background-color: blueviolet;
}
header>div:last-child {
margin-left: auto;
}
</style>
</head>
<body>
<header>
<div>HOME</div>
<div>SEARCH</div>
<div>LOGOUT</div>
</header>
</body>
</html>
gridå¸å±:(ç®å导èªå¸å±)
<!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>gridå¸å±</title>
<style>
header {
display: grid;
grid-template-columns: repeat(10,
1fr);
/* 10px repeat(8,1fr) 20px æ»å®½å
åå» 10 å 20 å©ä½å®½ â 8 ,å³å©ä½çæ¯ä»½å®½*/
/* repeat(10,1fr)éå¤é¡¹æ¶ä½¿ç¨æä¼,10æ ¼,æ¯æ ¼ä¸º1fr(å)å³æ»å®½â10å³æ¯ä»½ç宽 */
background-color: antiquewhite;
}
header div {
text-align: ceenter;
background-color: aqua;
padding: 10px 20px;
}
header>div:last-child {
grid-column:10;
}
</style>
</head>
<body>
<header>
<div>é¦é¡µ</div>
<div>个æ§å</div>
<div>ç»é</div>
<div>æ¨è</div>
<div>å®å¶</div>
</header>
</body>
</html>
å£æ¯å¸å±:
<!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>å£æ¯å¸å±</title>
<style>
.w200 {
width: 100px;
height: 500px;
background-color: green;
}
.parent {
display: flex;
flex-direction: row;
width: 100%;
}
.center {
width: -webkit-calc(100% - 200px);
height: 500px;
}
</style>
</head>
<body>
<div class="parent">
<div class="left w200">左边</div>
<div class="center">ä¸é´</div>
<div class="right w200">å³è¾¹</div>
</div>
</body>
</html>