css 实现宽高相等
- demo 1
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>css设置高和宽相等~~</title>
<style>
*{
margin: 0;
padding: 0;
}
.box{
width: 300px;/* 也可以用20% */
position:relative;
background-color: aquamarine;
}
.box:before{
content: '';
padding-top: 100%;
box-sizing: border-box;
display: block;
width: 0;
}
.pox{
position:absolute;
height:100%;
width:100%;
left: 0;
top: 0;
border: 1px solid red;
box-sizing: border-box;
/* border-radius: 500px; */
}
</style>
</head>
<body>
<div class="box">
<div class="pox">内容</div>
</div>
</body>
</html>
- demo2
<!DOCTYPE html>
<html>
<head>
<title>test</title>
</head>
<style>
.wrapper {
position: relative;
height: 0;
padding-top: 20%;
background-color: brown;
}
.box {
position: absolute;
width: 20%;
height: 100%;
top: 0;
border: 1px solid #ccc;
background-color: aquamarine;
}
</style>
<body>
<div class="wrapper">
<div class="box"></div>
</div>
</body>
</html>
相信坚持的力量,日复一日的习惯.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
2019-10-21 SQL语句 update 字段=字段+字符串 拼接