Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css] 第45天 你知道的等高布局有多少种?写出来 #170

Open
haizhilin2013 opened this issue May 30, 2019 · 7 comments
Open
Labels
css css

Comments

@haizhilin2013
Copy link
Collaborator

第45天 你知道的等高布局有多少种?写出来

@haizhilin2013 haizhilin2013 added the css css label May 30, 2019
@wenyejie
Copy link

现在肯定是flex咯
我记得以前还有一种方案, padding: 10000px; margin: -10000px大概是这样!
要不然就通过js去控制

@cleverboy32
Copy link

flex ;

.wrap > * { height: 100%; }

@Vi-jay
Copy link

Vi-jay commented Jul 31, 2019

  1. flex拉伸
display: flex;
align-items: stretch;
  1. padding margin抵消 然后background-clip默认是border-box所以会在被抵消的位置依然显示背景 造成等高假象
.box,.box2{
    float: left;
    width: 100px;
}
.box {
    background: #cccccc;
    height: 300px;
}
.box2 {
    background: #306eff;
    padding-bottom: 99999px;
    margin-bottom: -99999px;
}

@jiamianmao
Copy link

table 很适合的。

@seho-dev
Copy link

使用浮动:padding-bottom 9999px margin-bottom -9999px互相抵消,父级清除浮动,即子元素最高的高度就是父盒子最高的高度
使用flex:默认的flex的align配置就是自动填充满父级盒子,设置子元素高度即父元素高度
使用定位:top和bottom都是0,然后撑开父元素的高度;

@MrZ2019
Copy link

MrZ2019 commented Nov 6, 2020

使用浮动:padding-bottom 9999px margin-bottom -9999px互相抵消,父级清除浮动,即子元素最高的高度就是父盒子最高的高度
使用flex:默认的flex的align配置就是自动填充满父级盒子,设置子元素高度即父元素高度
使用定位:top和bottom都是0,然后撑开父元素的高度;

@CSLukkun
Copy link

var a=1;
var b=2;
a = a^b
b= a^b;
a= a^b;
console.log(a,b)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css css
Projects
None yet
Development

No branches or pull requests

8 participants