CSS Width等于高度,反之亦然

菲利普·马雷克(Filip Marek)

因为我的网络项目很重要,所以我的div宽度等于hight反之则不然,因为高度是相对的且设置为80%。就像是:

.key{
    position: relative;
    display: inline-block;
    height: 80%;
    width: *height*;
    border: none;
    cursor: pointer;
}

感谢帮助。

希曼舒·巴德瓦(Himanshu Bhardwaj)

有一种使用CSS的方法!

如果您根据父容器设置宽度,则可以将高度设置为0,并将padding-bottom设置为将根据当前宽度计算的百分比:

.key {
position: relative;
display: inline-block;
border: none;
cursor: pointer;
padding-bottom: 20%;
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章