Saturday, December 6, 2014

How to put 'fadein' and 'animate' texts in the middle of the page ?

<style type="text/css">

.animated {
    -webkit-animation-fill-mode: both;
    -moz-animation-fill-mode: both;
    -ms-animation-fill-mode: both;
    -o-animation-fill-mode: both;
    animation-fill-mode: both;
    -webkit-animation-duration: 0.5s;
    -moz-animation-duration: 0.5s;
    -ms-animation-duration: 0.5s;
    -o-animation-duration: 0.5s;
    animation-duration: 0.5s;
}
.fade {
    -webkit-animation-name: fade;
    -moz-animation-name: fade;
    -o-animation-name: fade;
    animation-name: fade;
}
@-webkit-keyframes fade {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}
@-moz-keyframes fade {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}
@-o-keyframes fade {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}
@keyframes fade {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}
@-webkit-keyframes flowright {
    0% {
        opacity: 0;
        left: -100px;
    }
    100% {
        opacity: 1;
        left: 0;
    }
}
@keyframes flowright {
    0% {
        opacity: 0;
        left: -100px;
    }
    100% {
        opacity: 1;
        left: 0;
    }
}
@-webkit-keyframes flowleft {
    0% {
        opacity: 0;
        right: -100px;
    }
    100% {
        opacity: 1;
        right: 0;
    }
}
@keyframes flowleft {
    0% {
        opacity: 0;
        right: -100px;
    }
    100% {
        opacity: 1;
        right: 0;
    }
}
@-webkit-keyframes flowup {
    0% {
        opacity: 0;
        margin-top: 100px;
    }
    100% {
        opacity: 1;
        margin-top: 0;
    }
}
@keyframes flowup {
    0% {
        opacity: 0;
        margin-top: 100px;
    }
    100% {
        opacity: 1;
        margin-top: 0;
    }
}
@-webkit-keyframes flowdown {
    0% {
        opacity: 0;
        margin-top: -100px;
    }
    100% {
        opacity: 1;
        margin-top: 0;
    }
}
@keyframes flowdown {
    0% {
        opacity: 0;
        margin-top: -100px;
    }
    100% {
        opacity: 1;
        margin-top: 0;
    }
}
.flow {
    -webkit-animation-duration: 1s;
    -webkit-animation-timing-function: cubic-bezier(0.165, 0.840, 0.440, 1.000);
    -webkit-animation-direction: alternate;
    -webkit-animation-fill-mode: both;
    animation-duration: 1s;
    animation-timing-function: cubic-bezier(0.165, 0.840, 0.440, 1.000);
}
.right {
    -webkit-animation-name: flowright;
    animation-name: flowright;
}
.left {
    -webkit-animation-name: flowleft;
    animation-name: flowleft;
}
.up {
    -webkit-animation-name: flowup;
    animation-name: flowup;
}
.down {
    -webkit-animation-name: flowdown;
    animation-name: flowdown;
}
.sequence01 {
    -webkit-animation-delay: 0.1s;
}
.sequence02 {
    -webkit-animation-delay: 0.2s;
}
.sequence03 {
    -webkit-animation-delay: 0.3s;
}
.sequence04 {
    -webkit-animation-delay: 0.4s;
}
/* Headline Typography */
 .wrapper {
    position: relative;
    height: 100%;
    width: 100%;
}

.headline {
    height: 100%;
    position: relative;
    font-family: helvetica;
    font-weight: bold;
    font-size: 4em;
}
/* Rows */

.row01 {
    position: relative;
}
.row02 {
    text-align: right;
    position: relative;
}
.row03 {
    padding-left: 20%;
    position: relative;
}
/* General Structure */
 body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}
.pagewrap {
    left: 10%;
    right: 10%;
    top: 0;
    bottom: 0;
    position: absolute;
    max-width: 48em;
    background-color: #fff6d6;
}

.top-headline-pad {
    height: 10%;
}
.headline-pad {
    height: 5%;
}
.bottom-headline-pad {
    height: 10%;
}

</style>

<body>
    <div class="pagewrap">
        <div class="wrapper">
            <div class="headline">
                <div class="top-headline-pad"></div>
                <div class="row01 flow left sequence01">ROW 01</div>
                <div class="headline-pad"></div>
                <div class="row02 flow right sequence02">ROW 02</div>
                <div class="headline-pad"></div>
                <div class="row03 flow up sequence03">ROW 03</div>
                <div class="bottom-headline-pad"></div>
            </div>
        </div>
    </div>
</body>


Output :)


Friday, December 5, 2014

How to place div inside another div to absolute position ?

<style type="text/css">

#container{
   width:200px;
   height:200px;
   position:relative;
   border:2px solid #33b5e5;
}
.box{
   border:2px solid #33b5e5;
   position:absolute;
   width:20px;
   height:20px;
   margin: 3px;
}
.top{top:0}
.middle{top:50%;margin-top:-10px;/*half of the .box height*/}
.bottom{bottom:0}

.left{left:0;}
.center{left:50%;margin-left:-10px;/*half of the .box width*/}
.right{right:0;}

</style>

<div id="container" class="box">
    <div class="box top left"></div>
    <div class="box top center"></div>
    <div class="box top right"></div>
 
    <div class="box middle left"></div>
    <div class="box middle center"></div>
    <div class="box middle right"></div>
 
    <div class="box bottom left"></div>
    <div class="box bottom center"></div>
    <div class="box bottom right"></div>
</div>


Output :)


Tuesday, December 2, 2014

Fade a css border to invisible.

<style type="text/css">

body{
background-color:red;
}

div.transition {
border: 5px solid rgba(0,0,0,1);
height: 100px;
width: 100px;
background-color: #ffffff;

transition: border-color 1s linear;
-moz-transition: border-color 1s linear;    /* FF3.7+ */
-o-transition: border-color 1s linear;      /* Opera 10.5 */
-webkit-transition: border-color 1s linear; /* Saf3.2+, Chrome */
}

div.transition:hover {
border-color: rgba(0,0,0,0);
}

</style>

<div class="transition"></div>


Output :)

1)

2)

Friday, November 28, 2014

CSS3 Spin Animation

<style type="text/css">

div {
    margin: 20px;
    width: 100px;
    height: 100px;
    background: #33b5e5;
    -webkit-animation-name: spin;
    -webkit-animation-duration: 4000ms;
    -webkit-animation-iteration-count: infinite;
    -webkit-animation-timing-function: linear;
    -moz-animation-name: spin;
    -moz-animation-duration: 4000ms;
    -moz-animation-iteration-count: infinite;
    -moz-animation-timing-function: linear;
    -ms-animation-name: spin;
    -ms-animation-duration: 4000ms;
    -ms-animation-iteration-count: infinite;
    -ms-animation-timing-function: linear;
 
    animation-name: spin;
    animation-duration: 4000ms;
    animation-iteration-count: infinite;
    animation-timing-function: linear;
}
@-ms-keyframes spin {
    from { -ms-transform: rotate(0deg); }
    to { -ms-transform: rotate(360deg); }
}
@-moz-keyframes spin {
    from { -moz-transform: rotate(0deg); }
    to { -moz-transform: rotate(360deg); }
}
@-webkit-keyframes spin {
    from { -webkit-transform: rotate(0deg); }
    to { -webkit-transform: rotate(360deg); }
}
@keyframes spin {
    from {
        transform:rotate(0deg);
    }
    to {
        transform:rotate(360deg);
    }
}

</style>

<div></div>


Output :)

1)

2)

Wednesday, November 26, 2014

JQuery : Scroll to nth row in a table.

<style type="text/css">

table{margin-top:20px;}

td{padding:3px;}

td:nth-child(1){color:red;}

tr.active{background-color:yellow;}

#control{
line-height:20px;
padding:3px;
position:fixed;
top:0;left:0;right:0;
background-color:#33b5e5;
}

</style>

<script type="text/javascript" src="jquery-1.11.1.min.js"></script> /* Link jQuery file here.. */


<div id="control">
    Line <input type="text" size="5" id="line" /> <button> go </button>
</div>
<table>
    <tr>
        <td></td>
        <td></td>
    </tr>
</table>


<script type="text/javascript">

// create and fill the table
var row = $('tr');
var table = $('table');

for (var i=1;i<100;i++){
   row.clone().appendTo( table );
}

table.find('tr').each(function(idx, elem){
   $(this).find('td:first').text(idx).end().find('td:last').text('This is the line '+(idx)+' of the table');
});

// code to scroll
$('#control button').click(function(){
   var w = $(window);
   var row = table.find('tr')
       .removeClass('active')
       .eq( +$('#line').val() )
       .addClass('active');
 
   if (row.length){
       w.scrollTop( row.offset().top - (w.height()/2) );
   }
});

</script>


Output :)

1)

2)

Monday, November 24, 2014

How to blink a div using jquery ?

<style type="text/css">

.blink{
width: 250px;
padding: 5px;
background: red;
text-align: center;
color: white;
font-weight: bold;
font-size: 25px;
font-family: comic sans ms;
border-radius: 10px;
}

.nblink{
font-family: verdana;
font-weight: bold;
font-size: 27px;
padding-left: 20px;
}

</style>

<script type="text/javascript" src="jquery-1.11.1.min.js"></script> //Attach jQuery file here

<div class="blink">Blinking text</div>
<span class="nblink">Non-Blinking</span>
<div class="blink">Blinking text</div>

<script type="text/javascript">

function blink(selector){
$(selector).fadeOut('slow', function(){
   $(this).fadeIn('slow', function(){
       blink(this);
   });
});
}
 
blink('.blink');

</script>

Output :)

1)

2)

Thursday, November 20, 2014

Play multiple CSS animations at the same time.

<style type="text/css">

.image {
border-radius: 25%;
   -webkit-animation: spin 2s linear infinite;
}

.container {
   position: absolute;
   top: 40%;
   left: 50%;
   margin:-60px 0 0 -60px;
   -webkit-animation: scale 4s linear infinite;
}

@-webkit-keyframes spin {
   100% {
       transform: rotate(180deg);
   }
}

@-webkit-keyframes scale {
   100% {
        transform: scale(2);
   }
}

</style>


<div class="container">
<img class="image" src="p17.png" alt="" width="170" height="170"/>
</div>


Output :)

1)

2)

3)