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

保持子元素高度与父元素一直(未设置高度) #15

Open
54leibo opened this issue Mar 26, 2020 · 1 comment
Open

保持子元素高度与父元素一直(未设置高度) #15

54leibo opened this issue Mar 26, 2020 · 1 comment

Comments

@54leibo
Copy link
Owner

54leibo commented Mar 26, 2020

  • 背景:有时候我们想设置父元素min-height属性,而并不想设置其height属性,此时需要如何保持子元素和父元素高度一致呢
  • 方法1:
.parent {
 display: flex;
}
  • 方法2:
.parent {
 position: relative;
}
.child {
 position: absolute;
 top: 0;
 bottom: 0; // 或者 height: 100%;
}
@ChenKun1997
Copy link

学到了

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

No branches or pull requests

2 participants