.landing {
position: relative;
min-height: calc(100vh - 72px);
background-color: orange;
}
.landing .container {
width: 1200px;
margin: auto;
display: flex;
align-items: center;
height:100%;
}
.landing .container .image {
width: 600px;
}
.landing .container .image > img {
max-width: 100%;
}
/*.....................not working..............................*/
.landing .container .text {
flex: 1;
background-color:red;
/* not working */
height: 100%;
}
/*................................not working...................*/
.landing .container .text > h1 {
font-size: 40px;
margin: 0;
letter-spacing: -2px;
}
.landing .container .text > p {
font-size: 23px;
line-height: 1.7;
color: #666;
}
<div >
<div >
<div >
<h1>Welcome, To Elzero World</h1>
<p>
Here Iam gonna share everything about my life. Books Iam reading,
Games Iam Playing, Stories and Events
</p>
</div>
<div >
<img
src=" https://elzerowebschool.github.io/HTML_And_CSS_Template_Three/imgs/landing-image.png"
alt=""
/>
</div>
</div>
<a href="#articles" >
<i ></i>
</a>
</div>
height:100; not working why? when I set it to (.landing .container .text ) it dosen't work please help me.
I don't understand why this feature is not working
How do I deal with this problem please
and when i want to use calc(100% 2px) ,it not working too
CodePudding user response:
So when it comes to percentage based heights in CSS, they only work if the parent element has a defined height. The most common issue with this comes from the <html>
and <body>
elements, which people usually don't set a height for and this can cause elements on the page to not properly use percentage based heights.
The other issue specific to your situation is that your .landing
class has a min-height
set, but not the height
. Because of this, any child elements will not be able to use percentage based heights because the parent element doesn't not have a defined height.
html, body { height: 100%; margin: 0; padding: 0; }
.landing {
position: relative;
min-height: calc(100vh - 72px);
height: 100%;
background-color: orange;
}
.landing .container {
width: 1200px;
margin: auto;
display: flex;
align-items: center;
height:100%;
}
.landing .container .image {
width: 600px;
}
.landing .container .image > img {
max-width: 100%;
}
/*.....................not working..............................*/
.landing .container .text {
flex: 1;
/* not working */
height: 100%;
}
/*................................not working...................*/
.landing .container .text > h1 {
font-size: 40px;
margin: 0;
letter-spacing: -2px;
}
.landing .container .text > p {
font-size: 23px;
line-height: 1.7;
color: #666;
}
<div >
<div >
<div >
<h1>Welcome, To Elzero World</h1>
<p>
Here Iam gonna share everything about my life. Books Iam reading,
Games Iam Playing, Stories and Events
</p>
</div>
<div >
<img
src=" https://elzerowebschool.github.io/HTML_And_CSS_Template_Three/imgs/landing-image.png"
alt=""
/>
</div>
</div>
<a href="#articles" >
<i ></i>
</a>
</div>
CodePudding user response:
Try changing the min-height
on .landing
to height
, is this the effect you want?