批改状态:合格
老师批语:对于flex,grid来说, 等高列本就是默认状态,而之前却为了实现它, 好难
1、直接用百分比来进行设置
<head><meta charset="utf-8" /><title>123</title><style>* {margin: 0;padding: 0;box-sizing: inherit;}:root,::after,::before {background-color: #eee;box-sizing: border-box;}.box1,.box2 {background-color: #cccccc;border-radius: 1em;padding: 1em;float: left;}.box1 {width: 70%;}.box2 {width: 29%;margin-left: 1%;}</style></head><body><div class="box3"><div class="continal"><div class="box1"></div><div class="box2"></div></div></div></body>
2、列间隙用em来设置
<head><meta charset="utf-8" /><title>123</title><style>* {margin: 0;padding: 0;box-sizing: inherit;}:root,::after,::before {background-color: #eee;box-sizing: border-box;}.box1,.box2 {background-color: #cccccc;border-radius: 1em;padding: 1em;float: left;}.box1 {width: 70%;}.box2 {width: calc(30% - 1em);margin-left: 1em;}</style></head><body><div class="box3"><div class="continal"><div class="box1"></div><div class="box2"></div></div></div></body>
实例演示:
<head><meta charset="utf-8" /><title>123</title><style>* {margin: 0;padding: 0;box-sizing: inherit;}:root,::after,::before {background-color: #eee;box-sizing: border-box;}header {background-color: #0072b0;color: #ffffff;text-align: center;border: 2px solid;border-radius: 0.5em;}.continal {display: table;width: 100%;border-spacing: 1.5em 0;}.box1,.box2 {background-color: #cccccc;border-radius: 1em;padding: 1em;margin-top: 1em;display: table-cell;}.box1 {width: 70%;height: 30vh;}.box2 {width: calc(30% - 1em);margin-left: 1em;}.box3 {margin-left: -1.5em;margin-right: -1.5em;}</style></head><body><header><h1>等高列</h1></header><div class="box3"><div class="continal"><div class="box1"></div><div class="box2"></div></div></div></body>
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号