DEV Community

Cover image for The sexyest fade effect !
Ustariz Enzo
Ustariz Enzo

Posted on • Updated on

The sexyest fade effect !

Hey fellow creators.

Let's face it, this effect rocks, let's code it right away.

If you prefer to watch the video version it's right here :

1. The HTML structure.

We need one block after another, so let's just code a flex container.

    <div class="home">
        <div class="bloc-fade">
            <h1>DEEP BREATH</h1>
            <p>Lorem ipsum100</p>
            <p>Lorem ipsum30</p>
        <div class="bloc-background"></div>
Enter fullscreen mode Exit fullscreen mode

2. CSS time.

Now let's just style this quickly.

*, ::before, ::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;

body {
    font-family: Arial, Helvetica, sans-serif;
    height: 100vh;
    color: #2a3d4e;
.home {
    position: relative;
    display: flex;
    width: 100%;
    height: 100%;
    flex-shrink: 0;
    position: relative;
    display: flex;
    align-items: center;
    flex-direction: column;
    width: 800px;
    height: 100%;
    background: #fff;
.bloc-background {
    background-image: url("");
    background-repeat: no-repeat;
    flex-grow: 1;
    height: 100%;

h1 {
    text-align: center;
    font-size: 70px;
    padding: 100px 0 50px 0;

.bloc-fade p {
    width: 70%;
    font-size: 18px;
    text-align: justify;

Enter fullscreen mode Exit fullscreen mode

Ok so now we do have that kind of interface :
Alt Text

Which is already good looking isn't it ?

But we need to add the last touch for the fade effect.

3. The last touch

Add this to ".bloc-fade".

.bloc-fade {
   box-shadow: 100px 0 100px 100px  #fff;
Enter fullscreen mode Exit fullscreen mode

The trick here is to put 100px to the 4th values, the spread value.
It will create a nice harmonized shadow, and, indeed, our desired fade effect.

Bravo bravo ! 🥖🧀🍷

The source code :

Come and take a look at my brand new Youtube channel :
Be part the first pioneers that follow me uh ? ⛰️

My Yt :

Take care of you and see you next time.


Top comments (0)