Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

TranslateY is increasing the size of page

In first-child of container, translateY property make element disappear but when it comes to last child it increases the size of page and stays on page. I want it to disappear and gives the transition effect on both the child.

body{
    height: 100vh;
}
.container{
    height: 100vh;
    width: 100vw;
    font-size: 2em;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
}
.container > :first-child{
    transform: translateY(-200px);
}

.container > :last-child{
    transform: translateY(200px);
}
<body>
    <div class="container">
        <p>Abc</p>
        <p>Xyz</p>
        <p>Abc</p>
    </div>
</body>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Just add overflow : hidden; style to the container class.

body{
    height: 100vh;
}
.container{
    height: 100vh;
    width: 100vw;
    font-size: 2em;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
    overflow:hidden;

}
.container > :first-child{
    transform: translateY(-200px);
}

.container > :last-child{
    transform: translateY(200px);
}
<body>
    <div class="container">
        <p>Abc</p>
        <p>Xyz</p>
        <p>Abc</p>
    </div>
</body>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading