DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report
  1. DZone
  2. Coding
  3. Languages
  4. CSS3 Optical Illusions

CSS3 Optical Illusions

Andrey Prikaznov user avatar by
Andrey Prikaznov
·
Jan. 05, 12 · Interview
Like (0)
Save
Tweet
Share
7.18K Views

Join the DZone community and get the full member experience.

Join For Free

today i have prepared something interesting for you. this is a demonstration of several optical illusions in css3 (without using any images or javascript). enjoy the results.


here are samples and downloadable package:

live demo

download in package


ok, download the example files and let's start coding!


step 1. html

as usual, we start with the html. here is full html code of all 6 demos.

index.html

<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>css3 optical illusions | script tutorials</title>

        <link href="css/layout.css" type="text/css" rel="stylesheet">
        <link href="css/illusions.css" type="text/css" rel="stylesheet">
    </head>
    <body>

        <header>
            <h2>css3 optical illusions</h2>
            <a href="http://www.script-tutorials.com/css3-optical-illusions/" class="stuts">back to original tutorial on <span>script tutorials</span></a>
        </header>

        <div class="container">
            <span id="page1"></span>
            <span id="page2"></span>
            <span id="page3"></span>
            <span id="page4"></span>
            <span id="page5"></span>
            <span id="page6"></span>

            <a class="contr" href="#page1" title="are these lines parallel? yes, of course">1</a>
            <a class="contr" href="#page2" title="the circles rotate?">2</a>
            <a class="contr" href="#page3" title="the upper half of each figure is same as lower half, is not it? lets turn them, the difference becomes much bigger">3</a>
            <a class="contr" href="#page4" title="at the intersections of white lines, except for the intersection, where you keep your sight at the moment, we can see small gray spots.">4</a>
            <a class="contr" href="#page5" title="see inside for some time. they saw the green stains? but nothing green is not here.">5</a>
            <a class="contr" href="#page6" title="another one move effect">6</a>

            <div class="demos">
                <div id="i1">
                    <div class="row"></div>
                    <div class="row"></div>
                    <div class="row"></div>
                    <div class="row"></div>
                    <div class="row"></div>
                    <div class="row"></div>
                    <div class="row"></div>
                </div>

                <div id="i2">
                    <div class="cir1">
                        <div id="o1"></div><div id="o2"></div><div id="o3"></div>
                        <div id="o4"></div><div id="o5"></div><div id="o6"></div>
                        <div id="o7"></div><div id="o8"></div><div id="o9"></div>
                        <div id="o10"></div><div id="o11"></div><div id="o12"></div>
                    </div>
                    <div class="cir2">
                        <div id="o1"></div><div id="o2"></div><div id="o3"></div>
                        <div id="o4"></div><div id="o5"></div><div id="o6"></div>
                        <div id="o7"></div><div id="o8"></div><div id="o9"></div>
                        <div id="o10"></div><div id="o11"></div><div id="o12"></div>
                    </div>
                    <div class="cir3">
                        <div id="o1"></div><div id="o2"></div><div id="o3"></div>
                        <div id="o4"></div><div id="o5"></div><div id="o6"></div>
                        <div id="o7"></div><div id="o8"></div><div id="o9"></div>
                        <div id="o10"></div><div id="o11"></div><div id="o12"></div>
                    </div>
                    <div class="cir4">
                        <div id="o1"></div><div id="o2"></div><div id="o3"></div>
                        <div id="o4"></div><div id="o5"></div><div id="o6"></div>
                        <div id="o7"></div><div id="o8"></div><div id="o9"></div>
                        <div id="o10"></div><div id="o11"></div><div id="o12"></div>
                    </div>
                    <div class="cir5">
                        <div id="o1"></div><div id="o2"></div><div id="o3"></div>
                        <div id="o4"></div><div id="o5"></div><div id="o6"></div>
                        <div id="o7"></div><div id="o8"></div><div id="o9"></div>
                        <div id="o10"></div><div id="o11"></div><div id="o12"></div>
                    </div>
                    <div class="cir6">
                        <div id="o1"></div><div id="o2"></div><div id="o3"></div>
                        <div id="o4"></div><div id="o5"></div><div id="o6"></div>
                        <div id="o7"></div><div id="o8"></div><div id="o9"></div>
                        <div id="o10"></div><div id="o11"></div><div id="o12"></div>
                    </div>
                    <div class="cir7">
                        <div id="o1"></div><div id="o2"></div><div id="o3"></div>
                        <div id="o4"></div><div id="o5"></div><div id="o6"></div>
                        <div id="o7"></div><div id="o8"></div><div id="o9"></div>
                        <div id="o10"></div><div id="o11"></div><div id="o12"></div>
                    </div>
                    <div class="cir8">
                        <div id="o1"></div><div id="o2"></div><div id="o3"></div>
                        <div id="o4"></div><div id="o5"></div><div id="o6"></div>
                        <div id="o7"></div><div id="o8"></div><div id="o9"></div>
                        <div id="o10"></div><div id="o11"></div><div id="o12"></div>
                    </div>
                    <div class="cir9">
                        <div id="o1"></div><div id="o2"></div><div id="o3"></div>
                        <div id="o4"></div><div id="o5"></div><div id="o6"></div>
                        <div id="o7"></div><div id="o8"></div><div id="o9"></div>
                        <div id="o10"></div><div id="o11"></div><div id="o12"></div>
                    </div>
                </div>

                <div id="i3">
                    <div class="pos">38</div>
                    <div class="rev">38</div>
                </div>

                <div id="i4">
                    <div class="row"></div>
                    <div class="row"></div>
                    <div class="row"></div>
                    <div class="row"></div>
                    <div class="row"></div>
                    <div class="row"></div>
                    <div class="row"></div>
                    <div class="row"></div>
                    <div class="row"></div>
                    <div class="row"></div>
                    <div class="row"></div>
                    <div class="row"></div>
                </div>

                <div id="i5">
                    <div>
                        <div id="o1"></div><div id="o2"></div><div id="o3"></div>
                        <div id="o4"></div><div id="o5"></div><div id="o6"></div>
                        <div id="o7"></div><div id="o8"></div><div id="o9"></div>
                        <div id="o10"></div><div id="o11"></div><div id="o12"></div>
                    </div>
                </div>

                <div id="i6">
                    <div>
                        <div class="yellow r1">
                            <div class="pink r2">
                                <div class="yellow r3">
                                    <div class="pink r4"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div>
                        <div class="yellow r1">
                            <div class="pink r2">
                                <div class="yellow r3">
                                    <div class="pink r4"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div>
                        <div class="yellow r1">
                            <div class="pink r2">
                                <div class="yellow r3">
                                    <div class="pink r4"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div>
                        <div class="yellow r1">
                            <div class="pink r2">
                                <div class="yellow r3">
                                    <div class="pink r4"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </body>
</html>

step 2. css

here are the css styles. maybe you’ve noticed that in our html i have two css files: layout.css and illusions.css. the first file (layout.css) contain the styles of our test page. we will not publish these styles in this article, but if you wish – you can find these styles in our package.

css/illusions.css

span {
    display: none;
}
.contr {
    color: #000000;
    cursor: pointer;
    float: left;
    font-size: 16px;
    font-weight: bold;
    height: 30px;
    line-height: 30px;
    margin: 10px;
    text-align: center;
    text-decoration: none;
    width: 60px;

    -webkit-border-radius:10px;
    -moz-border-radius:10px;
    -ms-border-radius:10px;
    -o-border-radius:10px;
    border-radius:10px;

    background-color:#e3e3ff;
    background: -moz-linear-gradient(#ffffff, #eee);
    background: -ms-linear-gradient(#ffffff, #eee);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #ffffff), color-stop(100%, #eee));
    background: -webkit-linear-gradient(#ffffff, #eee);
    background: -o-linear-gradient(#ffffff, #eee);
    filter: progid:dximagetransform.microsoft.gradient(startcolorstr='#ffffff', endcolorstr='#eee');
    -ms-filter: "progid:dximagetransform.microsoft.gradient(startcolorstr='#ffffff', endcolorstr='#eee')";
    background: linear-gradient(#ffffff, #eee);
}
.contr:hover{
    background-color:#e3e3ff;
    box-shadow:0px 0px 4px rgba(0,0,0,0.5) inset, 0px 0px 0px 4px rgba(51,51,204,0.5);
    -moz-box-shadow:0px 0px 4px rgba(0,0,0,0.5) inset, 0px 0px 0px 4px rgba(51,51,204,0.5);
    -webkit-box-shadow:0px 0px 4px rgba(0,0,0,0.5) inset, 0px 0px 0px 4px rgba(51,51,204,0.5);
}
.demos {
    background-color: #b2b2b2;
    display: block;
    height: 640px;
    margin-top: 55px;
    overflow: hidden;
    position: relative;
}
.demos > div {
    display: none;
}
#page1:target ~ .demos #i1 {
    display: block;
}
#page2:target ~ .demos #i2 {
    display: block;
}
#page3:target ~ .demos #i3 {
    display: block;
}
#page4:target ~ .demos #i4 {
    display: block;
}
#page5:target ~ .demos #i5 {
    display: block;
}
#page6:target ~ .demos #i6 {
    display: block;
}

/* illusion 1 */
#i1 {
    width: 900px;
}
#i1 .row {
    background-color: #fff;
    border-bottom: 2px solid #888;
    height: 90px;

    -webkit-background-size: 140px 70px;
    -moz-background-size: 140px 70px;
    -ms-background-size: 140px 70px;
    -o-background-size: 140px 70px;
    background-size: 140px 70px;

    background-position: 0 50%;
    background-image: -webkit-linear-gradient(0deg, #000 50%, transparent 50%, transparent);
    background-image: -moz-linear-gradient(0deg, #000 50%, transparent 50%, transparent);
    background-image: -ms-linear-gradient(0deg, #000 50%, transparent 50%, transparent);
    background-image: -o-linear-gradient(0deg, #000 50%, transparent 50%, transparent);
    background-image: linear-gradient(0deg, #000 50%, transparent 50%, transparent);
}
#i1 .row:nth-child(3n+3) {
    background-position: 60px 50%;
}
#i1 .row:nth-child(2n+2) {
    background-position: 30px 50%;
}

/* illusion 2 */
#i2 {
    background-color: #98cb00;
    height: 640px;
    margin: 0 auto;
    overflow: hidden;
    padding: 0 150px;
    position: relative;
    width: 600px;
}
#i2  > div {
    float: left;
    height: 105px;
    padding-left: 90px;
    padding-top: 90px;
    position: relative;
    width: 105px;
}
#i2  div div {
    border: 1px outset #fff;
    height: 20px;
    position: absolute;
    width: 30px;

    -webkit-border-radius: 100px / 50px;
    -moz-border-radius: 100px / 50px;
    -ms-border-radius: 100px / 50px;
    -o-border-radius: 100px / 50px;
    border-radius: 100px / 50px;

    background: -webkit-linear-gradient(top, #580402, #a63b17, #580402, #a63b17, #580402);
    background: -moz-linear-gradient(top, #580402, #a63b17, #580402, #a63b17, #580402);
    background: -ms-linear-gradient(top, #580402, #a63b17, #580402, #a63b17, #580402);
    background: -o-linear-gradient(top, #580402, #a63b17, #580402, #a63b17, #580402);
    background: linear-gradient(top, #580402, #a63b17, #580402, #a63b17, #580402);
}
#i2 #o1 {
    -webkit-transform: rotate(-30deg) translatex(70px);
    -moz-transform: rotate(-30deg) translatex(70px);
    -ms-transform: rotate(-30deg) translatex(70px);
    -o-transform: rotate(-30deg) translatex(70px);
    transform: rotate(-30deg) translatex(70px);
}
#i2 #o2 {
    -webkit-transform: rotate(-60deg) translatex(70px);
    -moz-transform: rotate(-60deg) translatex(70px);
    -ms-transform: rotate(-60deg) translatex(70px);
    -o-transform: rotate(-60deg) translatex(70px);
    transform: rotate(-60deg) translatex(70px);
}
#i2 #o3 {
    -webkit-transform: rotate(-90deg) translatex(70px);
    -moz-transform: rotate(-90deg) translatex(70px);
    -ms-transform: rotate(-90deg) translatex(70px);
    -o-transform: rotate(-90deg) translatex(70px);
    transform: rotate(-90deg) translatex(70px);
}
#i2 #o4 {
    -webkit-transform: rotate(-120deg) translatex(70px);
    -moz-transform: rotate(-120deg) translatex(70px);
    -ms-transform: rotate(-120deg) translatex(70px);
    -o-transform: rotate(-120deg) translatex(70px);
    transform: rotate(-120deg) translatex(70px);
}
#i2 #o5 {
    -webkit-transform: rotate(-150deg) translatex(70px);
    -moz-transform: rotate(-150deg) translatex(70px);
    -ms-transform: rotate(-150deg) translatex(70px);
    -o-transform: rotate(-150deg) translatex(70px);
    transform: rotate(-150deg) translatex(70px);
}
#i2 #o6 {
    -webkit-transform: rotate(-180deg) translatex(70px);
    -moz-transform: rotate(-180deg) translatex(70px);
    -ms-transform: rotate(-180deg) translatex(70px);
    -o-transform: rotate(-180deg) translatex(70px);
    transform: rotate(-180deg) translatex(70px);
}
#i2 #o7 {
    -webkit-transform: rotate(-210deg) translatex(70px);
    -moz-transform: rotate(-210deg) translatex(70px);
    -ms-transform: rotate(-210deg) translatex(70px);
    -o-transform: rotate(-210deg) translatex(70px);
    transform: rotate(-210deg) translatex(70px);
}
#i2 #o8 {
    -webkit-transform: rotate(-240deg) translatex(70px);
    -moz-transform: rotate(-240deg) translatex(70px);
    -ms-transform: rotate(-240deg) translatex(70px);
    -o-transform: rotate(-240deg) translatex(70px);
    transform: rotate(-240deg) translatex(70px);
}
#i2 #o9 {
    -webkit-transform: rotate(-270deg) translatex(70px);
    -moz-transform: rotate(-270deg) translatex(70px);
    -ms-transform: rotate(-270deg) translatex(70px);
    -o-transform: rotate(-270deg) translatex(70px);
    transform: rotate(-270deg) translatex(70px);
}
#i2 #o10 {
    -webkit-transform: rotate(-300deg) translatex(70px);
    -moz-transform: rotate(-300deg) translatex(70px);
    -ms-transform: rotate(-300deg) translatex(70px);
    -o-transform: rotate(-300deg) translatex(70px);
    transform: rotate(-300deg) translatex(70px);
}
#i2 #o11 {
    -webkit-transform: rotate(-330deg) translatex(70px);
    -moz-transform: rotate(-330deg) translatex(70px);
    -ms-transform: rotate(-330deg) translatex(70px);
    -o-transform: rotate(-330deg) translatex(70px);
    transform: rotate(-330deg) translatex(70px);
}
#i2 #o12 {
    -webkit-transform: rotate(0deg) translatex(70px);
    -moz-transform: rotate(0deg) translatex(70px);
    -ms-transform: rotate(0deg) translatex(70px);
    -o-transform: rotate(0deg) translatex(70px);
    transform: rotate(0deg) translatex(70px);
}

/* illusion 3 */
#i3 {
    color: #000000;
    font-family: times new roman;
    font-size: 250px;
    padding-left: 300px;
}
#i3 .rev {
    text-align: right;

    -webkit-transform: rotate(-180deg);
    -moz-transform: rotate(-180deg);
    -ms-transform: rotate(-180deg);
    -o-transform: rotate(-180deg);
    transform: rotate(-180deg);
}

/* illusion 4 */
#i4 .row {
    background-color: #fff;
    border-bottom: 5px solid #fff;
    height: 50px;

    -webkit-background-size: 60px 50px;
    -moz-background-size: 60px 50px;
    -ms-background-size: 60px 50px;
    -o-background-size: 60px 50px;
    background-size: 60px 50px;

    background-position: 0 50%;
    background-image: -webkit-linear-gradient(0deg, #000 90%, transparent 10%, transparent);
    background-image: -moz-linear-gradient(0deg, #000 90%, transparent 10%, transparent);
    background-image: -ms-linear-gradient(0deg, #000 50%, transparent 50%, transparent);
    background-image: -o-linear-gradient(0deg, #000 50%, transparent 50%, transparent);
    background-image: linear-gradient(0deg, #000 50%, transparent 50%, transparent);
}

/* illusion 5 */
@-webkit-keyframes custom_effect {
    0% {opacity: 0;}
    33% {opacity: 1;}
    100% {opacity: 1;}
}
@-moz-keyframes custom_effect {
    0% {opacity: 0;}
    33% {opacity: 1;}
    100% {opacity: 1;}
}
#i5 {
    background-color: #b2b2b2;
    height: 600px;
    margin: 0 auto;
    overflow: hidden;
    position: relative;
    width: 600px;
}
#i5  > div {
    float: left;
    height: 200px;
    padding-left: 200px;
    padding-top: 200px;
    position: relative;
    width: 200px;
}
#i5  div div {
    height: 50px;
    position: absolute;
    width: 50px;

    -webkit-border-radius: 50px;
    -moz-border-radius: 50px;
    -ms-border-radius: 50px;
    -o-border-radius: 50px;
    border-radius: 50px;

    background-color: #b2b2b2;
    background-image: -webkit-radial-gradient(50% 50%, circle, #fd19fd, #b2b2b2 70%);
    background-image: -moz-radial-gradient(50% 50%, circle, #fd19fd, #b2b2b2 70%);
    background-image: -o-radial-gradient(50% 50%, circle, #fd19fd, #b2b2b2 70%);
    background-image: radial-gradient(50% 50%, circle, #fd19fd, #b2b2b2 70%);

    -moz-animation-name: custom_effect;
    -moz-animation-duration: 1.2s;
    -moz-animation-timing-function: linear;
    -moz-animation-iteration-count: infinite;
    -moz-animation-direction: normal;
    -moz-animation-delay: 0;
    -moz-animation-play-state: running;
    -moz-animation-fill-mode: forwards;

    -webkit-animation-name: custom_effect;
    -webkit-animation-duration: 1.2s;
    -webkit-animation-timing-function: linear;
    -webkit-animation-iteration-count: infinite;
    -webkit-animation-direction: normal;
    -webkit-animation-delay: 0;
    -webkit-animation-play-state: running;
    -webkit-animation-fill-mode: forwards;
}

#i5 #o1 {
  -moz-transform: rotate(30deg) translatex(150px);
  -moz-animation-delay: 0.1s;
  -webkit-transform: rotate(30deg) translatex(150px);
  -webkit-animation-delay: 0.1s;
}
#i5 #o2 {
  -moz-transform: rotate(60deg) translatex(150px);
  -moz-animation-delay: 0.2s;
  -webkit-transform: rotate(60deg) translatex(150px);
  -webkit-animation-delay: 0.2s;
}
#i5 #o3 {
  -moz-transform: rotate(90deg) translatex(150px);
  -moz-animation-delay: 0.3s;
  -webkit-transform: rotate(90deg) translatex(150px);
  -webkit-animation-delay: 0.3s;
}
#i5 #o4 {
  -moz-transform: rotate(120deg) translatex(150px);
  -moz-animation-delay: 0.4s;
  -webkit-transform: rotate(120deg) translatex(150px);
  -webkit-animation-delay: 0.4s;
}
#i5 #o5 {
  -moz-transform: rotate(150deg) translatex(150px);
  -moz-animation-delay: 0.5s;
  -webkit-transform: rotate(150deg) translatex(150px);
  -webkit-animation-delay: 0.5s;
}
#i5 #o6 {
  -moz-transform: rotate(180deg) translatex(150px);
  -moz-animation-delay: 0.6s;
  -webkit-transform: rotate(180deg) translatex(150px);
  -webkit-animation-delay: 0.6s;
}
#i5 #o7 {
  -moz-transform: rotate(210deg) translatex(150px);
  -moz-animation-delay: 0.7s;
  -webkit-transform: rotate(210deg) translatex(150px);
  -webkit-animation-delay: 0.7s;
}
#i5 #o8 {
  -moz-transform: rotate(240deg) translatex(150px);
  -moz-animation-delay: 0.8s;
  -webkit-transform: rotate(240deg) translatex(150px);
  -webkit-animation-delay: 0.8s;
}
#i5 #o9 {
  -moz-transform: rotate(270deg) translatex(150px);
  -moz-animation-delay: 0.9s;
  -webkit-transform: rotate(270deg) translatex(150px);
  -webkit-animation-delay: 0.9s;
}
#i5 #o10 {
  -moz-transform: rotate(300deg) translatex(150px);
  -moz-animation-delay: 1.0s;
  -webkit-transform: rotate(300deg) translatex(150px);
  -webkit-animation-delay: 1.0s;
}
#i5 #o11 {
  -moz-transform: rotate(330deg) translatex(150px);
  -moz-animation-delay: 1.1s;
  -webkit-transform: rotate(330deg) translatex(150px);
  -webkit-animation-delay: 1.1s;
}
#i5 #o12 {
  -moz-transform: rotate(0deg) translatex(150px);
  -moz-animation-delay: 1.2s;
  -webkit-transform: rotate(0deg) translatex(150px);
  -webkit-animation-delay: 1.2s;
}

/* illusion 5 */
#i6 {
    background-color: #3f023e;
    height: 640px;
    margin: 0 auto;
    overflow: hidden;
    padding-left: 120px;
    position: relative;
    width: 900px;
}

#i6 .yellow {
    background-color: #b9bd04;
    background-image: -webkit-radial-gradient(50% 50%, circle, #fff531 40%, #b9bd04 80%);
    background-image: -moz-radial-gradient(50% 50%, circle, #fff531 40%, #b9bd04 80%);
    background-image: -o-radial-gradient(50% 50%, circle, #fff531 40%, #b9bd04 80%);
    background-image: radial-gradient(50% 50%, circle, #fff531 40%, #b9bd04 80%);
}
#i6 .pink {
    background-color: #f101e8;
    background-image: -webkit-radial-gradient(50% 50%, circle, #0e0403 40%, #f101e8 80%);
    background-image: -moz-radial-gradient(50% 50%, circle, #0e0403 40%, #f101e8 80%);
    background-image: -o-radial-gradient(50% 50%, circle, #0e0403 40%, #f101e8 80%);
    background-image: radial-gradient(50% 50%, circle, #0e0403 40%, #f101e8 80%);
}
#i6 > div {
    float: left;
    height: 320px;
    position: relative;
    width: 320px;
}
#i6 .r1 {
    height: 320px;
    position: absolute;
    width: 320px;

    -webkit-border-radius: 320px;
    -moz-border-radius: 320px;
    -ms-border-radius: 320px;
    -o-border-radius: 320px;
    border-radius: 320px;
}
#i6 .r2 {
    height: 240px;
    left: 40px;
    position: absolute;
    top: 40px;
    width: 240px;

    -webkit-border-radius: 240px;
    -moz-border-radius: 240px;
    -ms-border-radius: 240px;
    -o-border-radius: 240px;
    border-radius: 240px;
}
#i6 .r3 {
    height: 160px;
    left: 40px;
    position: absolute;
    top: 40px;
    width: 160px;

    -webkit-border-radius: 160px;
    -moz-border-radius: 160px;
    -ms-border-radius: 160px;
    -o-border-radius: 160px;
    border-radius: 160px;
}
#i6 .r4 {
    height: 80px;
    left: 40px;
    position: absolute;
    top: 40px;
    width: 80px;

    -webkit-border-radius: 80px;
    -moz-border-radius: 80px;
    -ms-border-radius: 80px;
    -o-border-radius: 80px;
    border-radius: 80px;
}

this is very big pack of styles, but i hope that this is ok. i have used several different css3 techniques: and keyframe animation, and transform rotate, and sometimes – gradients.



live demo

download in package

conclusion

hope you enjoyed the new demo. don’t forget to give thanks and leave a comment :) good luck!

source: http://www.script-tutorials.com/css3-optical-illusions/

CSS

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • REST vs. Messaging for Microservices
  • Cloud Performance Engineering
  • Building a Real-Time App With Spring Boot, Cassandra, Pulsar, React, and Hilla
  • How To Choose the Right Streaming Database

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: