Wednesday, January 7, 2015

Add border to odd div's using CSS.

<style type="text/css">

p{
font-family: 'verdana';
font-size: 25px;
}
.wrap {
float: left;
width: 100%;
}
.single_wrap {
float: left;
width: 50%;
padding: 15px 0;
}
.single_div {
float: left;
width: 100%;
}
.single_wrap:nth-child(odd) .single_div {
border-left: 3px solid red;
background: #33b5e5;
}
.single_wrap:nth-child(1) .single_div, .single_wrap:nth-child(2) .single_div {
border-bottom: 5px solid #005555;
}

</style>


<div class="wrap">
<div class="single_wrap">
<div class="single_div">
<p>CSS jQuery</p>
</div>
</div>

<div class="single_wrap">
<div class="single_div">
<p>CSS jQuery</p>
</div>
</div>

<div class="single_wrap">
<div class="single_div">
<p>CSS jQuery</p>
</div>
</div>

<div class="single_wrap">
<div class="single_div">
<p>CSS jQuery</p>
</div>
</div>
</div>


Output :)


Tuesday, January 6, 2015

Timer Animation JavaScript.

<style type="text/css">

body {
background: #333333;
text-align: center;
}

</style>

<svg id="svg">
  <path id="timer" fill="lightseagreen" />
</svg>

<script type="text/javascript">

var timer = document.getElementById('timer');
var svg = document.getElementById('svg');
var width = 150;
svg.setAttribute('width', width);
svg.setAttribute('height', width);
var t = 5;
var theta = 0;
var radius = svg.getAttribute('width') / 2;
timer.setAttribute('transform', 'translate(' + radius + ',' + radius + ')');

(function animate() {
 theta += 0.5;
 theta %= 360;
 var x = Math.sin(theta * Math.PI / 180) * radius;
 var y = Math.cos(theta * Math.PI / 180) * -radius;
 var d = 'M0,0 v' + -radius + 'A' + radius + ',' + radius + ' 1 ' + ((theta > 180) ? 1 : 0) + ',1 ' + x + ',' + y + 'z';
 timer.setAttribute('d', d);
 setTimeout(animate, t)
})();

</script>


Output :)

1)

2)

Monday, January 5, 2015

Birthday Cake CSS.

<style type="text/css">

    .cake-body{
        position:relative;
        margin:100px;
    }
    .layer{
        display:block;
        background:#FFA177;
        height:50px;
        width:150px;
        border-bottom-right-radius: 50%;
        border-bottom-left-radius: 50%;
        position:absolute;
    }

    .f1{
        top:90px;
        background:#774F38;
        height:60px;
    }
    .f2{
        top:60px;
        background:#ECE5CE;
        height:60px;
    }
    .f3{
        top:30px;
        background:#E08E79;
        height:60px;
    }
    .f4{
        border-top-right-radius: 50%;
        border-top-left-radius: 50%;
        background:#59280F;
        top:6px;
    }

    /* Cake Spots */

    .spot-group{
        display:block;
        height:14px;
        width:14px;
        position:absolute;
    }
    .spot{
        display:block;
        height:4px;
        width:4px;
        border-radius: 50%;
        position:absolute;
    }
    .f1 .spot{
        background:#8C5F45;
    }
    .f2 .spot{
        background:#D6CFB6;
    }
    .f3 .spot{
        background:#EB9E8A;
    }
    .sg1{
        bottom:20px;
        left:5px;
    }
    .s1{
        top:2px;
        left:10px;
    }
    .s2{
        top:7px;
        left:5px;
    }
    .s3{
        left:2px;
    }
    .sg1{
        bottom:20px;
        left:5px;
    }
    .sg2{
        bottom:20px;
        right:10px;
    }
    .sg3{
        bottom:21px;
        left:6px;
    }
    .sg4{
        bottom:11px;
        right:33px;
    }
    .sg5{
        bottom:15px;
        left:25px;
    }
    .sg6{
        bottom:20px;
        right:10px;
    }
     /* Icing */

    .icing{
        display:block;
        height:50px;
        width:150px;
        border-radius: 50%;
        background:#59280F;
        background-image: -webkit-gradient( linear, left bottom, left top, color-stop(0.29, #59280F), color-stop(0.8, #692F12));
        position:absolute;
        top:0px;
        z-index:2;
    }

    /* Icing Drips */

    .drip-ctn{
        position:absolute
        top:0;
        z-index:1;
    }
    .drip{
      display:block;
      height:20px;
      width:20px;
      border-radius: 50%;
      background:#59280F;
      position:absolute;
    }
    .d1{
      height:25px;
      top:20px;
    }
    .d2{
      top:30px;
      left:15px
    }
    .d3{
      top:35px;
      left:30px
    }
    .d4{
      top:38px;
      left:47px
    }
    .d5{
      top:40px;
      left:65px;
    }
    .d6{
      top:38px;
      right:47px
    }
    .d7{
      top:35px;
      right:30px
    }
    .d8{
      top:30px;
      right:15px
    }
    .d9{
      height:25px;
      top:20px;
      right:0px;
    }

    /* Candles */

    .candle-ctn{
      display:block;
      width:150px;
      height:80px;
      position:absolute;
      top:-30px;
      z-index:3;
    }
    .candle{
      position:absolute;
      top:20px;
      left:70px;
    }
    .c-base{
      display:block;
      height:30px;
      width:10px;
      background:#5FEDB5;
      position:absolute;
      z-index:2;
    }
    .wick{
      display: block;
      width: 2px;
      height: 6px;
      background: #ccc;
      position: absolute;
      top: -5px;
      left: 4px;
    }
    .flame{
      display:block;
      height:16px;
      width:8px;
       border-radius: 50%  50%  50%  50%  / 60%   60%   40%  40%;
      background:#FF9E00;
      position:absolute;
      top:-20px;
      left:1px;
      box-shadow: 0px 0px 20px yellow;
    }
    .highlight{
      display:block;
      height:30px;
      width:60px;
      background:#333;
      border-radius:50%;
      position:absolute;
      top:17px;
      left:-25px;
      background: -webkit-radial-gradient(center, ellipse cover, rgba(145,66,26,1) 0%,rgba(105,47,18,0) 80%);
      z-index:1;
    }

</style>


<div class="cake-body">
    <div class="layer f1">
        <div class="spot-group sg1">
            <div class="spot s1"></div>
            <div class="spot s2"></div>
            <div class="spot s3"></div>
        </div>
        <div class="spot-group sg2">
            <div class="spot s1"></div>
            <div class="spot s2"></div>
        </div>
    </div>
    <div class="layer f2">
        <div class="spot-group sg3">
            <div class="spot s1"></div>
            <div class="spot s2"></div>
        </div>
        <div class="spot-group sg4">
            <div class="spot s1"></div>
            <div class="spot s2"></div>
            <div class="spot s3"></div>
        </div>
    </div>
    <div class="layer f3">
        <div class="spot-group sg5">
            <div class="spot s1"></div>
            <div class="spot s2"></div>
            <div class="spot s3"></div>
        </div>
    </div>
    <div class="layer f4">
      <div class="drip-ctn">
        <div class="drip d1"></div>
        <div class="drip d2"></div>
        <div class="drip d3"></div>
        <div class="drip d4"></div>
        <div class="drip d5"></div>
        <div class="drip d6"></div>
        <div class="drip d7"></div>
        <div class="drip d8"></div>
        <div class="drip d9"></div>
      <div>
    </div>
    <div class="candle-ctn">
        <div class="candle c1">
          <div class="c-base"></div>
          <div class="wick"></div>
          <div class="flame"></div>
          <div class="highlight"></div>
        </div>
    </div>
</div>


Output :)


Sunday, January 4, 2015

3D Box CSS3.

<style type="text/css">

body {
background: #33b5e5;
}

.foo {
position: relative;
display: inline-block;
-webkit-perspective: 1000px;
-moz-perspective: 1000px;
persepctive: 1000px;
margin: 20px;
margin-top: 50px;
}

.foo .box {
transform: rotateY(-40deg);
height: 350px;
width: 250px;
background-color: black;
}

.foo:before {
content: "";
top: -15px;
position: absolute;
width: 55px;
height: 375px;
background-color: grey;
transform: translateX(215px) translateY(2.7px) rotateY(55deg)
}

</style>

<div class="foo">
    <div class="box"></div>
</div>


Output :)


Saturday, January 3, 2015

Positioning divs in a circle using JavaScript.

<style type="text/css">

div {
 box-sizing: border-box;
}

div#main {
 height: 500px;
 width: 500px;
 position: absolute;
 left: 0%;
 top: 0%;
}

div.circle {
 position: absolute;
 width: 20px;
 height: 20px;
 border: 2px solid black;
 border-radius: 10px;
 -webkit-border-radius: 10px;
 -moz-border-radius: 10px;
}

</style>


<div id="main"></div>


<script type="text/javascript">

var setup = function () {
   var radius = 150;
   var main = document.getElementById('main');
   var mainHeight = parseInt(window.getComputedStyle(main).height.slice(0, -2));
   var theta = [0, Math.PI / 6, Math.PI / 4, Math.PI / 3, Math.PI / 2, 2 * (Math.PI / 3), 3 * (Math.PI / 4), 5 * (Math.PI / 6), Math.PI, 7 * (Math.PI / 6), 5 * (Math.PI / 4), 4 * (Math.PI / 3), 3 * (Math.PI / 2), 5 * (Math.PI / 3), 7 * (Math.PI / 4), 11 * (Math.PI / 6)];
   var circleArray = [];
   var colors = ['red', 'green', 'purple', 'black', 'orange', 'yellow', 'maroon', 'grey', 'lightblue', 'tomato', 'pink', 'maroon', 'cyan', 'magenta', 'blue', 'chocolate', 'DarkSlateBlue'];
   for (var i = 0; i < 16; i++) {
       var circle = document.createElement('div');
       circle.className = 'circle number'+i;
       circleArray.push(circle);
       circleArray[i].posx = Math.round(radius * (Math.cos(theta[i]))) + 'px';
       circleArray[i].posy = Math.round(radius * (Math.sin(theta[i]))) + 'px';
       circleArray[i].style.position = "absolute";
       circleArray[i].style.backgroundColor = colors[i];
       circleArray[i].style.top = ((mainHeight / 2) - parseInt(circleArray[i].posy.slice(0, -2))) + 'px';
       circleArray[i].style.left = ((mainHeight/ 2 ) + parseInt(circleArray[i].posx.slice(0, -2))) + 'px';
       main.appendChild(circleArray[i]);
   }
};
setup();

</script>


Output :)


Friday, January 2, 2015

How to create card hover style effect like GOOGLE now cards.

<style type="text/css">

body {
   background: url(gre.jpg);
}
.container {
   position: relative;
   margin: 0 auto;
   top: 10px;
   width: 100%;
   height: 350px;
   -webkit-perspective: 600px;
   perspective: 600px;
   text-align: center;
}
.item {
   display: inline-block;
   position: relative;
font-family: verdana;
color: white;
font-size: 20px;
   margin: 15px;
   width: 200px;
   height: 250px;
   line-height: 300px;
   background-color: #33b5e5;
   border-radius: 10px;
   -webkit-animation: animOpp 0.4s 1;
   animation: animOpp 0.4s 1;
   box-shadow: 1px 1px 5px white;
}
.item:hover {
   -webkit-animation: anim ease-out 0.5s 1;
   animation: anim 0.5s 1;
   transform: translateZ(30px);
   cursor: pointer;
}
.item:active {
   -webkit-transform: translateZ(26px);
   transform: translateZ(26px);
}
@-webkit-keyframes anim {
   0% {
       transform: rotateX(0deg) translateZ(0px);
   }
   25% {
       transform: rotateX(-4deg) translateZ(15px);
   }
   37% {
       transform: rotateX(-8deg) translateZ(30px);
       transform-origin: 50% 0%;
   }
   72% {
    transform-origin: 50% 0%;
       transform: rotateX(-4deg) translateZ(30px);
   }
   100% {
    transform-origin: 50% 0%;
       transform: rotateX(0deg) translateZ(30px);
   }
}

@-moz-keyframes anim {
   0% {
       transform: rotateX(0deg) translateZ(0px);
   }
   25% {
       transform: rotateX(-4deg) translateZ(15px);
   }
   37% {
       transform: rotateX(-8deg) translateZ(30px);
       transform-origin: 50% 0%;
   }
   72% {
    transform-origin: 50% 0%;
       transform: rotateX(-4deg) translateZ(30px);
   }
   100% {
    transform-origin: 50% 0%;
       transform: rotateX(0deg) translateZ(30px);
   }
}
@-webkit-keyframes animOpp {
   0% {
       transform: translateZ(30px);
   }
   35% {
    transform: translateZ(20px);
   }
   100% {
       transform: translateZ(0px);
   }
}
@-moz-keyframes animOpp {
   0% {
       transform: translateZ(30px);
   }
   35% {
    transform: translateZ(20px);
   }
   100% {
       transform: translateZ(0px);
   }
}

</style>


<body>
  <div class="container">
    <div class="item">Content Goes Here</div>
    <div class="item">Content Goes Here</div>
    <div class="item">Content Goes Here</div>
    <div class="item">Content Goes Here</div>
    <div class="item">Content Goes Here</div>
    <div class="item">Content Goes Here</div>
    <div class="item">Content Goes Here</div>
    <div class="item">Content Goes Here</div>
  </div>
</body>


Output :)

1)

2)

Thursday, January 1, 2015

Table generator Jquery.

<style type="text/css">

body {
background: oldlace;
font-family: verdana;
}

select {
margin-right:40px;
}

td, th, table {
border:  solid 1px;
border-collapse: collapse;
padding: 5px;
padding-left: 10px;
padding-right: 10px;
text-align: center;
}

</style>

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

<span id="cols">Columns:</span>

<select id="coluna">
    <option disabled selected>Select</option>
    <option>0</option>
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
    <option>5</option>
    <option>6</option>
    <option>7</option>
    <option>8</option>
    <option>9</option>
    <option>10</option>
</select>
<span class="ros">Rows:</span>

<select id="fila">
    <option disabled selected>Select</option>
    <option>0</option>
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
    <option>5</option>
    <option>6</option>
    <option>7</option>
    <option>8</option>
    <option>9</option>
    <option>10</option>
</select>
<button class="criar">Generate</button>
<br><br>
<table id="tabelas"></table>

<script type="text/javascript">

$(document).ready(function () {
 
    String.prototype.repeat = function(n) {
        return new Array(n + 1).join(this);
    }
 
    $('.criar').click(function () {
        $('table').empty();
        var col = parseInt($('#coluna').val());
        var row = parseInt($('#fila').val());
        var Head = "<th>Heading</th>".repeat(row);
        var tableHead = "<tr>" + Head + "</tr>"
        var tableData = "<td>Details</td>".repeat(row);
        var tableRow = "<tr>" + tableData + "</tr>";
        var table = tableRow;
     
        $('#tabelas').append(tableHead);
     
        for (i = 0; i < col; i++) {
            $('#tabelas tr:last').after(table);
        }
    });
});

</script>


Output :)

1)

2)