CSS Uncategorized

Create flowers with CSS3 gradient background

CSS3 has introduced many new and exiting features to make your web application make more appealing. In this post i am going to demonstrate css3 gradient background effect. I just wanted to introduce it so that the demo created is compatible with firefox only. This demo is not supported in other browsers.
When i thought to explain css3 gradient background, first thing came in my mind was to create flowers and i went with it.Lets start with demo. First of all we will need 4 divs to create flower petals which will have css3 gradient background rotated at different angles.
flowers with CSS3 gradient background

HTML layout for CSS3 gradient background

making of flowers with CSS3 gradient background

CSS3 gradient background and petal rotations

If you like this css3 gradient background tutorial please share it.

6 Comments

  • […] Tweet In our previous tutorials we have had look at different features of css3 and html5 like creating css3 flowers using gradient effect, Introduction to HTML5 web storage, Ajax file upload with drag and drop and progress bar. In this […]

  • Here the code for All Browser support & 100% working!!
    Download jquery-1.7.1.min.js from here : http://blog.jquery.com/2011/11/21/jquery-1-7-1-released/

    CSS3 Flowers

    body {
    margin: 0;
    }
    .container {
    width: 100%;
    max-width: 1002px;
    margin: auto;
    }
    .flower{
    -moz-transform: rotate(15deg);
    position: absolute;
    display: none;
    }

    .flower div{
    width : 40%;
    height : 40%;
    margin : 1px;
    float : left;
    }
    .flower .center{
    width: 20%;
    height: 20%;
    background: #FFFF33;
    background: -ms-radial-gradient(#C0AB16, #FFFF33, #1E90FF);
    background: -moz-radial-gradient(#C0AB16, #FFFF33, #1E90FF);
    background: -webkit-gradient(radial, center center, 0, center center, from(#C0AB16), to(#1E90FF));
    position: absolute;
    top: 32%;
    left:32%;
    border-radius: 50px;
    }
    .flower .tl{
    background: #A09BFB;
    background: -ms-linear-gradient(top, #A09BFB 40%, #DBE2FB 90%);
    background: -webkit-gradient(linear, left top, left bottom, from(#A09BFB), to(#DBE2FB));
    background: -moz-linear-gradient(-45deg, #A09BFB 40%, #DBE2FB 90%);
    border-radius: 30px 15px 0px 15px;
    }
    .flower .tr{
    background: #A09BFB;
    background: -ms-linear-gradient(top, #A09BFB 40%, #DBE2FB 90%);
    background: -webkit-gradient(linear, left top, left bottom, from(#A09BFB), to(#DBE2FB));
    background: -moz-linear-gradient(225deg, #A09BFB 40%, #DBE2FB 90%);
    border-radius: 15px 30px 15px 0px;
    }
    .flower .bl{
    background: #A09BFB;
    background: -ms-linear-gradient(bottom, #A09BFB 40%, #DBE2FB 90%);
    background: -webkit-gradient(linear, left bottom, left top, from(#A09BFB), to(#DBE2FB));
    background: -moz-linear-gradient(45deg, #A09BFB 40%, #DBE2FB 90%);
    border-radius: 15px 0px 15px 30px;
    }
    .flower .br{
    background: #A09BFB;
    background: -ms-linear-gradient(bottom, #A09BFB 40%, #DBE2FB 90%);
    background: -webkit-gradient(linear, left bottom, left top, from(#A09BFB), to(#DBE2FB));
    background: -moz-linear-gradient(135deg, #A09BFB 40%, #DBE2FB 90%);
    border-radius: 0px 15px 30px 15px;
    }

    All Browser support
    <!—
    Basic code to create single flower

    –>

    setTimeout(“addFlower()”, 2000);
    function addFlower(){
    var flower = ”;
    var size = randomNum(40,100)+”px”;
    $(flower).css(“left”,(Math.random()*95)+”%”).css(“top”,(Math.random()*95+”%”)).css(“height”,size).css(“width”,size).appendTo(‘body’).fadeIn(“slow”);
    setTimeout(“addFlower()”, 1000);
    }
    function randomNum(pMin, pMax){
    min = pMin pMin ? pMax : pMin;
    var resultArr = [], randNumber;
    randNumber = Math.round(min + Math.random() * (max – min));
    if (resultArr.indexOf(randNumber) == -1) {
    resultArr.push(randNumber);
    }
    return resultArr;
    }

    • I did not test this code, may be i will do it some day, But anyways thanks for the css code. Great Job

Leave a Comment

*

Notify me of followup comments via e-mail. You can also subscribe without commenting.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Shares

Let your friends know what are you reading

Share this post with your friends!