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丨设置height:100%无效 #5

Closed
wangjianuo opened this issue Jun 18, 2019 · 0 comments
Closed

CSS丨设置height:100%无效 #5

wangjianuo opened this issue Jun 18, 2019 · 0 comments

Comments

@wangjianuo
Copy link
Owner

  • 设置height:100%的原理:
    当让一个元素的高度设置为百分比高度时,是相对于父元素的高度根据百分比来计算高度。
    所以当父元素没有高度时,height:100%也就没有高度值。
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>设置height:100%无效</title>
    <style>
        * {
            margin: 0 auto;
            padding: 0;
        }

        html {
            height: 100%;
        }

        body {
            height: 100%;
        }
    </style>
</head>

<body>
    <div style="height: 100%; background-color: pink;">666</div>
</body>

</html>
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

1 participant