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)

Wednesday, December 31, 2014

CSS arrow positioning.

<style type="text/css">

.home-link-left,.home-link-right {
 vertical-align: middle;
 margin: auto;
 width: 35vmin;
 height: 12vmin;
 border: 0.7vmin outset #232323;
 background-color: #606060;
 background: -webkit-radial-gradient(#707070, #505050);
 background: -moz-radial-gradient(#707070, #505050);
 background: -o-radial-gradient(#707070, #505050);
 background: radial-gradient(#707070, #505050);
 color: white;
 position: relative;
}
.home-link-left {
 border-radius: 20px 0px 0px 20px;
 left: 0px;
 border-right: 0px solid transparent;
}
.home-link-right {
 border-radius: 0px 20px 20px 0px;
 right: 0px;
 border-left: 0px solid transparent;
}
.home-link-left:before,
.home-link-right:after {
 content: '';
 position: absolute;
 width: 0px;
 height: 0px;
 border-bottom: 6vmin solid transparent;
 border-top: 6vmin solid transparent;
 vertical-align: middle;
 display: block;
}
.home-link-container {
 width: 45vmin;
 height: 13vmin;
 margin: auto;
 vertical-align: middle;
}
.home-link-left:before {
 border-left: 4vmin solid red;
 right: -4vmin;
}
.home-link-right:after {
 border-right: 4vmin solid red;
 left: -4vmin;
}
.home-link-image {
 border: 0.7vmin outset #333333;
 vertical-align: middle;
 margin-top: -10%;
 margin: auto;
 width: 35vmin;
 height: 25vmin;
 border-radius: 20px;
}

</style>

<table id="home-table">
  <tr>
    <td>
      <div class="home-link-container">
        <div class="home-link-left">
          <a href="#"></a>
        </div>
      </div>
    </td>
    <td>
      <div class="home-link-image"></div>
    </td>
  </tr>
  <tr>
    <td>
      <div class="home-link-image"></div>
    </td>
    <td>
      <div class="home-link-container">
        <div class="home-link-right">
          <a href="#"></a>
        </div>
      </div>
    </td>
  </tr>
  <tr>
    <td>
      <div class="home-link-container">
        <div class="home-link-left">
          <a href="#"></a>
        </div>
      </div>
    </td>
    <td>
      <div class="home-link-image"></div>
    </td>
  </tr>
</table>


Output :)


Tuesday, December 30, 2014

Select first element of the same class.

<style type="text/css">

.group .element:first-child {
 color: red;
}

div{
font-size: 25px;
font-weight: bold;
font-family: verdana;
}

</style>

<div class="group">
    <div class="element">CSS Tution</div>
    <div class="element">CSS Tution</div>
    <div class="element">CSS Tution</div>
    <div class="element">CSS Tution</div>
</div>

<div class="group">
    <div class="element">CSS Tution</div>
    <div class="element">CSS Tution</div>
    <div class="element">CSS Tution</div>
    <div class="element">CSS Tution</div>
</div>

<div class="group">
    <div class="element">CSS Tution</div>
    <div class="element">CSS Tution</div>
    <div class="element">CSS Tution</div>
    <div class="element">CSS Tution</div>
</div>


Output :)


Saturday, December 27, 2014

Insert a circle between li's.

<style type="text/css">

li {
list-style: none;
display: inline-block;
position: relative;
}

.nav-container {
top: 20px;
position: absolute;
width: 100%;
height: 40px;
line-height: 40px;
text-align: center;
left: 0;
}
.nav {
width: 100%;
height: 40px;
maring: 0 auto;
text-align: center;
line-height: 20px;
border-top: 1px solid red;
border-bottom: 1px solid red;
}
.menu-item {
display: inline-block;
width: 50px;
padding-left: 30px;
padding-right: 30px;
padding-top: 10px;
padding-bottom: 10px;
color: #777777;
margin-left: 6px;
margin-right: 6px;
}
.menu-item:not(:first-child)::before {
content: "";
position: absolute;
left: -13px;
top: 15px;
   width:8px;
   height:8px;
   border:2px solid red;
   border-radius:10px;
}
.menu-item:hover {
background-color: black;
cursor: pointer;
border-radius: 2px;
}

</style>

<body>

<div class="nav-container">
<ul class="nav">
<!--Items-->
<li id="menu-item-1" class="menu-item">Item 1</li>
<li id="menu-item-2" class="menu-item">Item 2</li>
<li id="menu-item-3" class="menu-item">Item 3</li>
<li id="menu-item-4" class="menu-item">Item 4</li>
<li id="menu-item-5" class="menu-item">Item 5</li>
</ul>
</div>

</body>


Output :)