Showing posts with label css3. Show all posts
Showing posts with label css3. Show all posts

Nov 7, 2013

Truncate long text with CSS

Truncate Text CSS

While making websites we usually face width issues for long title text or headings. We can wrap that to next line or using some server side language we truncate it. But this can be done using CSS also.



 


 



[html]
<style type="text/css">
p {
width:170px;
margin:10px;
font-family:Arial;
font-size:14px;
}
p.truncate {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
</style>
<p title="I am a long text and I am wrapped to next line">I am a long text and I am wrapped to next line</p>
<p class="truncate" title="I am a long text and I am truncated">I am a long text and I am truncated</p>
[/html]

Demo:

Aug 2, 2012

CSS3 Visiting Card 3D Transform

My friend Asif made a nice design on visiting card, so I decided to convert that into a 3D flipping Visiting Card

CSS3 Visiting Card

To rotate a div with 3D transform :-

  • transform-style: preserve-3d;

  • perspective: 800px;

  • transform: rotateY(180deg);

  • backface-visibility: hidden;


After setting the above CSS a div will transform.




Final Product

Visiting Card Front-Back

Visiting Card Back-Front




So lets start




[html]
<div id="card">
<div class="front">
<div class="strips">
<p class="strip red"></p>
<p class="strip orange"></p>
<p class="strip green"></p>
<p class="strip blue"></p>
<p class="strip lOrange"></p>
</div>
<div class="businessName">
Webs Tutorial
</div>
</div>
<div class="back">
<div class="strips">
<p class="strip red"><span>www.webstutorial.com</span></p>
<p class="strip orange"><span>Mumbai, India</span></p>
<p class="strip green"></p>
<p class="strip blue"><span>PHP, HTML5, CSS3</span></p>
<p class="strip lOrange"><span>niraj@webstutorial.com</span></p>
</div>
<div class="myName">
<p>Niraj Chauhan</p>
Developer
</div>
</div>
</div>
[/html]




Above we made a parent div and inside that two divs, one will be the front side and another will be the backside. When we :hover on the front facing div, it rotates in Y axis. As we have set the transform style to preserve-3d it will maintain its view and the transform will be displayed in 3D.




[css]
@font-face {
font-family: roboto;
src: url('../Roboto-Regular.ttf');
}

* {
font-family: roboto !important;
}

.container {
position: relative;
}

#card {
position: absolute;
z-index: 11;
-webkit-perspective: 800px;

-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
-ms-transform-style: preserve-3d;
transform-style: preserve-3d;
left: 30%;
}

#card .front,#card .back {
background: #000;
width: 480px;
height: 205px;
display: block;
position: absolute;
color: #fff;
border-radius: 8px;

-webkit-transition: -webkit-transform 1s ease-in-out;
-moz-transition: -moz-transform 1s ease-in-out;
-o-transition: -o-transform 1s ease-in-out;
-ms-transition: -ms-transform 1s ease-in-out;
transition: transform 1s ease-in-out;
}

#card .front {
-webkit-transform: rotateY(0deg);
-moz-transform: rotateY(0deg);
-o-transform: rotateY(0deg);
-ms-transform: rotateY(0deg);
transform: rotateY(0deg);
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
z-index: 13;
}

#card:hover .front {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
transform: rotateY(180deg);
}

#card .back {
-webkit-transform: rotateY(-180deg);
-moz-transform: rotateY(-180deg);
-o-transform: rotateY(-180deg);
-ms-transform: rotateY(-180deg);
transform: rotateY(-180deg);
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
z-index: 12;
background: #000;
}

#card:hover .back {
-webkit-transform: rotateY(0deg);
-moz-transform: rotateY(0deg);
-o-transform: rotateY(0deg);
-ms-transform: rotateY(0deg);
transform: rotateY(0deg);
z-index: 14;
}

/* Front Strips */
.strips {
clear: both;
margin: 0 auto;
position: relative;
width: 125px;
}

.strip {
float: left;
height: 140px;
margin-right: 12px;
position: relative;
width: 12px;
font-family: roboto;
}

.red {
background: #b70000;
color: #b70000;
border: 1px solid #890000;
border-top: 0px;
}

.orange {
background: #f25d07;
color: #f25d07;
border: 1px solid #b64605;
border-top: 0px;
}

.green {
background: #a69e33;
color: #a69e33;
border: 1px solid #837726;
border-top: 0px;
}

.blue {
background: #0092b2;
color: #0092b2;
border: 1px solid #006e86;
border-top: 0px;
}

.lOrange {
background: #ee913f;
color: #ee913f;
margin: 0 !important;
border: 1px solid #b36d2f;
border-top: 0px;
}

.businessName {
clear: both;
font-family: roboto;
font-size: 22px;
padding: 5px 0 0;
text-align: center;
}

/* Back strips */
.back .red {
height: 70px;
}

.back .orange {
height: 100px;
}

.back .green {
height: 140px;
}

.back .blue {
height: 100px;
}

.back .lOrange {
height: 70px;
}

.strip span {
position: absolute;
font-size: 15px;
}

.red span {
left: -162px;
top: 50px;
}

.orange span {
left: -102px;
top: 80px;
width: 100px;
}

.green span {
left: 0;
}

.blue span {
left: 20px;
top: 80px;
width: 140px;
}

.lOrange span {
left: 18px;
top: 50px;
}

.myName {
clear: both;
color: #999999;
font-family: roboto;
font-size: 20px;
padding: 0;
text-align: center;
}

.myName p {
color: #a69e33;
}

#designedBy {
border-radius: 5px 0 0 0;
bottom: 0;
color: #FFFFFF;
min-height: 10px !important;
padding: 10px;
position: fixed;
right: 0;
}
[/css]




Now in CSS we set the backface-visibility: hidden;. With this property the backside of the card will be hidden. When we hover on the front face of the card with the help of css transition we flip the card and now the backside of the card will be visible.

When we move away over mouse from the card it turns back to its original position.This way a 3D flip can be done using CSS3.

Now the latest Firefox also supports the 3D Transform. Previously it was only working on webkit browsers

Jun 18, 2012

CSS3 UI Buttons Set

I just saw the amazing art work by Alessio Atzeni for creating UI Buttons Design. I just converted the PSD to HTML5 and CSS3, so lets start with it. This tut will be having two set of buttons blue and black.

Each button has three states: normal, hover and active.

CSS3-UI-BUTTONS

The css selectors will be :hover and :active.

I will be using Foundation-Icons font for getting the icon image instead of using an image.



Blue Set



CSS3-UI-BUTTONS

HTML :
[html]
<a class="blue">a</a>
[/html]


CSS:
[css]
.blue{
background-image:-moz-linear-gradient(top,transparent,rgba(0,0,0,0.2));
background-image:-webkit-linear-gradient(top,transparent,rgba(0,0,0,0.2));
background-image:-o-linear-gradient(top,transparent,rgba(0,0,0,0.2));

-webkit-transition:all 0.1s linear;
-moz-transition:all 0.1s linear;
-o-transition:all 0.1s linear;
-ms-transition:all 0.1s linear;
transition:all 0.1s linear;

background-color: #5683b1;
/*font-family:icons;*/
border-top:1px solid #8bbfd7;
border-radius: 50% 50% 50% 50%;
font-size: 15px;
font-weight: bold;
color:#24272a;
text-shadow:0 1px 0 #5a92ba;
box-shadow: 0 5px 6px #1C1F22;
cursor: default;
text-align: center;
width: 33px;
height: 33px;
float: left;
margin: 10px;
font-family:icons;
}

.blue:hover{
background-color: #5f94bc;
}

.blue:active{
background-color: #3a6a9b;
box-shadow: 0 0 3px #323638 inset;
border: 1px solid #3c4246;
}
[/css]



Black Set



CSS3-UI-BUTTONS

HTML:
[html]
<p class="blackMask">
<a class="black">a</a>
</p>
[/html]

CSS:
[css]
.black{
background-image:-moz-linear-gradient(top,transparent,rgba(0,0,0,0.2));
background-image:-webkit-linear-gradient(top,transparent,rgba(0,0,0,0.2));
background-image:-o-linear-gradient(top,transparent,rgba(0,0,0,0.2));
-webkit-transition:all 0.1s linear;
-moz-transition:all 0.1s linear;
-o-transition:all 0.1s linear;
-ms-transition:all 0.1s linear;
transition:all 0.1s linear;


background-color: #464d53;
/*font-family:icons;*/
border-top:1px solid #626c74;
border-radius: 50% 50% 50% 50%;
font-size: 15px;
font-weight: bold;
color:#191919;
text-shadow:0 1px 0 #485258;
box-shadow: 0 3px 6px #1f2225;
cursor: default;
text-align: center;
width: 33px;
height: 33px;
float: left;
margin: 7px;
font-family:icons;
}

.black:hover{
background-color: #4b575f;
color:#00b7fb;
text-shadow:0 0 5px #39748c;
}

.black:active{
background-color: #2f383d;
box-shadow: 0 0 3px #323638 inset;
border: 1px solid #20292e;
color:#191919;
text-shadow:0 1px 0 #485258;
}

.blackMask{
background-image:-moz-linear-gradient(top,transparent,rgba(0,0,0,0.2));
background-image:-webkit-linear-gradient(top,transparent,rgba(0,0,0,0.2));
background-image:-o-linear-gradient(top,transparent,rgba(0,0,0,0.2));
background-color:#30363a;
border-radius: 50% 50% 50% 50%;
float: left;
width:47px;
position: relative;
height:47px;
margin: 10px;
border-top:1px solid #3c4247;
border-bottom:1px solid #4a5155;
}

.black:before {
background: none repeat scroll 0 0 transparent;
border-bottom: 1px solid #4F555A;
border-radius: 50% 50% 50% 50%;
border-top: 1px solid #373C40;
content: "";
height: 50px;
left: -2px;
position: absolute;
top: -3px;
width: 50px;
}
[/css]


These buttons can be used widely and advantages of using it, no images, fully flexible and customizable and it can be applied to any container a, button, span, p etc.

Thanks to Alessio, for creating the buttons Design.

May 29, 2012

CSS3 Gradient Textures

A snippet share just to show the power of CSS3 gradient, I just follow some free PSD's texture and try it to code in CSS3. So its time to share with you all.

CSS3 Gradient Texture

[css]
/* Gradient */

#texture1{
background-image: -moz-linear-gradient(90deg, #9fc9d7, #9fc9d7 2px, #a3dcf0 2px, #a3dcf0 4px, #9fc9d7 4px);
background-image: -webkit-linear-gradient(90deg, #9fc9d7, #9fc9d7 2px, #a3dcf0 2px, #a3dcf0 4px, #9fc9d7 4px);
background-repeat: repeat;
background-size: 2px 4px;
}

#texture2{
background-image: -moz-linear-gradient(0deg, #202125, #202125 2px, #292a2e 2px, #292a2e 4px, #202125 4px);
background-image: -webkit-linear-gradient(0deg, #202125, #202125 2px, #292a2e 2px, #292a2e 4px, #202125 4px);
background-repeat: repeat;
background-size: 5px 10px;
}

#texture3{
background-image: -moz-linear-gradient(90deg, #9dd9da, #9dd9da 15px, #a6dcde 15px, #a6dcde 30px, #9dd9da 30px);
background-image: -webkit-linear-gradient(90deg, #9dd9da, #9dd9da 15px, #a6dcde 15px, #a6dcde 30px, #9dd9da 30px);
background-repeat: repeat;
background-size: 15px 30px;
}

#texture4{
background-image: -moz-linear-gradient(45deg, rgba(0, 0, 0, 0.25) 25%, transparent 25%, transparent 75%, rgba(0, 0, 0, 0.25) 75%, rgba(0, 0, 0, 0.25)), -moz-linear-gradient(45deg, rgba(0, 0, 0, 0.25) 25%, transparent 25%, transparent 75%, rgba(0, 0, 0, 0.25) 75%, rgba(0, 0, 0, 0.25));
background-image: -webkit-linear-gradient(45deg, rgba(0, 0, 0, .25) 25%, transparent 25%, transparent 75%, rgba(0, 0, 0, .25) 75%, rgba(0, 0, 0, .25)), -webkit-linear-gradient(45deg, rgba(0, 0, 0, .25) 25%, transparent 25%, transparent 75%, rgba(0, 0, 0, .25) 75%, rgba(0, 0, 0, .25));
background-position: 0 0pt, 2px 2px;
background-size: 4px 4px;
background-color: #202125;
}
[/css]

 

May 26, 2012

HTML5 CSS3 Admin Panel | Dashboard Template

Now a days I go to dribble and see the amazing designs created by users. From their I get amazing ideas and today I ll share my HTML5 and CSS3 coded Admin panel with you all.

This tutorial will consist with :-

Here's the final output of our template:

HTML5-CSS3 Template
Fixed Menubar

Menu bar code is simple, li list with a drop down in it. We will be using box-shadow to give the gradient effect.

[html]
<ul id="admin-bar">
<li title="Home">H</li>
<li title="Users">A</li>
<li title="Add New Post">D</li>
<li title="Settings">G</li>
<li title="Videos">V</li>
<li title="Stats" class="active">v</li>
<li title="More">d
<ul id="drop-down">
<li title="Media Gallery">m<span>Media Gallery</span></li>
<li title="Comments">b<span>Comments</span></li>
<li title="Plugins">C<span>Plugins</span></li>
</ul>
</li>
</ul>
[/html]

Like my previous CSS3 tutorials here also I ll be using fonts instead of images to show the correct icons in menu.

[css]
#menu{
position:fixed;
top:0;
left:0;
width:100%;
background-color: #151515;
background-size: 6px 6px;
border-radius: 2px;
box-shadow: 0 25px 0 0 rgba(255, 255, 255, 0.15) inset;
height: 50px;
z-index: 1;
}

#admin-bar {
float: left;
margin: 0 auto;
padding: 0;
position: relative;
}

#admin-bar li {
color: #FFFFFF;
cursor: default;
display: inline;
float: left;
font-family: icons;
font-size: 25px;
list-style-type: none;
padding: 7px 10px 14px;
position: relative;
}

#admin-bar li:hover, .active{
text-shadow:0 0 5px #fff;
background:-moz-linear-gradient(center top , #1B1B1B 0%, #262626 100%) repeat scroll 0 0 transparent;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1b1b1b), color-stop(100%,#262626));
}

#admin-bar li ul {
-webkit-transition: all 1s ease 0s;
-moz-transition: all 1s ease 0s;
-o-transition: all 1s ease 0s;
-ms-transition: all 1s ease 0s;
transition: all 1s ease 0s;

background: -moz-linear-gradient(center top , #1B1B1B 0%, #262626 100%) repeat scroll 0 0 transparent;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1b1b1b), color-stop(100%,#262626)); /* Chrome,Safari4+ */
border-radius: 0 0 10px 10px;
display: block;
height: 0;
left: 0;
margin: 0;
opacity: 0;
overflow: hidden;
padding: 0;
position: absolute;
top: 50px;
width: 135px;
}

#admin-bar li:hover ul{
height:auto;
overflow:visible;
opacity:1;
}

#drop-down li {
display: block;
float: none;
background-image:url(divider.png);
background-repeat:no-repeat;
}

#drop-down li:hover{
background: -moz-linear-gradient(center top , #1B1B1B 0%, #262626 100%) repeat scroll 0 0 transparent;
}

#drop-down li:last-child {
border-radius: 0 0 10px 10px;
}
[/css]

To show the menu gradient I am using box-shadow: 0 25px 0 0 rgba(255, 255, 255, 0.15) inset; and for drop down menu the logic is really simple. By default overflow to be set as hidden, opacity as 0 and height to 0 and on mouse hover we change these values as visible, 1, auto.

The icons are not images but fonts. And using text-shadow they appear to glow on mouse hover.




Search Box

Its really simple if you have knowledge in CSS3 gradients. A textbox with black blackground color and CSS3 gradient effect to change the looks.

[html]
<input type="text" placeholder="Search" id="df">
[/html]

 

[css]
input[type="text"] {
background: -moz-linear-gradient(center top , #1B1B1B 0%, #262626 100%) repeat scroll 0 0 transparent;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1b1b1b), color-stop(100%,#262626)); /* Chrome,Safari4+ */
border: 1px solid #000000;
border-radius: 5px 5px 5px 5px;
box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2), 0 2px 0 rgba(0, 0, 0, 0.5) inset;
color: #FFFFFF;
float: left;
font-size: 11px;
height: 26px;
padding-left: 10px;
padding-right: 65px;
text-shadow: 0 0 3px #FFFFFF;
width: 130px;
margin-left: 50px;
margin-top: 10px;
}
input[type="text"]:hover, input[type="text"]:active{
background:#1B1B1B;
}
[/css]




Log out Button
Using the search box idea here also we will make use of CSS3 gradients.

[html]
<input type="submit" id="logout" value="Logout" />
[/html]

 

[css]
#logout {
background: -moz-linear-gradient(center top , #CD2525 0%, #B11B1C 50%, #940F10 50%, #861213 100%) repeat scroll 0 0 #CD2525;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#CD2525), color-stop(50%,#B11B1C), color-stop(50%,#940F10), color-stop(100%,#861213)); /* Chrome,Safari4+ */

border-radius: 3px;
color: #FFFFFF;
float: right;
font-family: arial;
font-size: 14px;
margin: 12px;
padding: 5px 15px;
text-decoration: none;
border:0px;
}

#logout:active{
background:#861213;
}
[/css]




Animated Graphs
The logic to design the graph is really simple, make 6-7 div's with same height and width. The height should be longer and width to be thin so that it looks like a standing pole. Then with the help of simple CSS3 gradients and CSS3 animations we have the make it animated so that it looks like animated bar graph.

[html]
<div id="graph">
<div class="progress">
<div style="height: 40%;" class="bar"></div>
<p class="stats-info"><span class="tooltip"></span>Monday</p>
</div>
<div class="progress">
<div style="height: 70%;" class="bar"></div>
<p class="stats-info"><span class="tooltip"></span>Tuesday</p>
</div>
<div class="progress">
<div style="height: 72%;" class="bar"></div>
<p class="stats-info"><span class="tooltip"></span>Wednesday</p>
</div>
<div class="progress">
<div style="height: 80%;" class="bar"></div>
<p class="stats-info"><span class="tooltip"></span>Thursday</p>
</div>
<div class="progress">
<div style="height: 75%;" class="bar"></div>
<p class="stats-info"><span class="tooltip"></span>Friday</p>
</div>
<div class="progress">
<div style="height: 65%;" class="bar"></div>
<p class="stats-info"><span class="tooltip"></span>Saturday</p>
</div>
<div class="progress">
<div style="height: 45%;" class="bar"></div>
<p class="stats-info"><span class="tooltip"></span>Sunday</p>
</div>
</div>
[/html]

To show the tooltip we are using the same logic as drop down menu. Here the tooltip is the class stats-info. On hover we are changing the opacity to give the fade in effect with the help of css3 transition effect

To show the graph animation we will be using animation effect and the css3 gradient:

[css]
.bar {
animation: 2s linear 0s normal none infinite progress-bar-stripes;
background-image: -moz-linear-gradient(-134deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
}

@keyframes "progress-bar-stripes" {
from {
background-position: 0 0;
}
to {
background-position: 40px 0;
}

}

[/css]

Tooltip hover effect

[css]
.stats-info {
-webkit-transition: all 0.3s linear 0s;
-moz-transition: all 0.3s linear 0s;
-o-transition: all 0.3s linear 0s;
-ms-transition: all 0.3s linear 0s;
transition: all 0.3s linear 0s;

background-image: -moz-linear-gradient(center top, #CD2525 0%, #B11B1C 50%, #940F10 50%, #861213 100%);
background-image: -webkit-linear-gradient(-90deg, #CD2525 0%, #B11B1C 50%, #940F10 50%, #861213 100%);

background-repeat:repeat;
background-color:#CD2525;
border-radius: 5px 5px 5px 5px;
bottom: -45px;
color: #FFFFFF;
left: -18px;
opacity: 0;
padding: 5px;
position: absolute;
font-size: 12px;
}

.bar:hover + .stats-info{
opacity:1;
}

.tooltip {
border-bottom: 10px solid #C02020;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
display: block;
height: 0;
left: 17px;
position: absolute;
top: -9px;
width: 0;
z-index: 1;
}
[/css]




Notification messages
If you have gone through all the above parts then I am sure you can guess how the notification messages are coded.

By using CSS3 gradients and fonts we can make it.

[html]
<div id="messages">

<div class="error">Error</div>
<div class="notification">Notification</div>
<div class="success">Success</div>

</div>
[/html]

 

[css]
/* messages */
#messages{
float:left;
}

#messages div{
display:block;
margin:20px;
cursor: pointer;
}

/* Error */
.error {
background-image: -moz-linear-gradient(center top , #CB1634 0%, #C41330 50%, #BC102C 50%, #B70D2A 100%);
background-image: -webkit-linear-gradient(-90deg , #CB1634 0%, #C41330 50%, #BC102C 50%, #B70D2A 100%);
background-color:#CB1634;
background-repeat:repeat;
border-radius: 8px 8px 8px 8px;
color: #FFFFFF;
display: block;
font-size: 18px;
padding: 5px 30px;
position: relative;
width: 200px;
}

.error:before {
content: "X";
font-family: icons;
left: 4px;
position: absolute;
font-size: 18px;
}

/* Notification */

.notification {
background-image: -moz-linear-gradient(center top , #e4b023 0%, #e0ab1b 50%, #dca512 50%, #d79f08 100%);
background-image: -webkit-linear-gradient(-90deg , #e4b023 0%, #e0ab1b 50%, #dca512 50%, #d79f08 100%);
background-color:#e4b023;
background-repeat:repeat;
border-radius: 8px 8px 8px 8px;
color: #FFFFFF;
display: block;
font-size: 18px;
padding: 5px 30px;
position: relative;
width: 200px;
}

.notification:before {
content: "l";
font-family: icons;
font-size: 28px;
left: 0;
position: absolute;
top: -1px;
}

/* Success */

.success {
background-image: -moz-linear-gradient(center top , #6da920 0%, #62991b 50%, #558614 50%, #4d7a10 100%);
background-image: -webkit-linear-gradient(-90deg , #6da920 0%, #62991b 50%, #558614 50%, #4d7a10 100%);
background-color:#6da920;
background-repeat:repeat;
border-radius: 8px 8px 8px 8px;
color: #FFFFFF;
display: block;
font-size: 18px;
padding: 5px 30px;
position: relative;
width: 200px;
}

.success:before {
content: "O";
font-family: icons;
left: 4px;
position: absolute;
}

[/css]




Dialog box

[html]
<div id="dialogbox">

<div id="box-header">Are You Sure?<a id="close">X</a></div>
<div id="box-content">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. </p>

<p style="position: relative; left: 20%; margin: 12px 0pt;">
<a class="yes">Yes</a>
<a class="no">No</a>
</p>
</div>

</div>
[/html]

We are using the div structure to build the dialog box. Again with the help of CSS3 gradients, fonts and other effects we will be making it to look like a Dialog Box.

[css]
/* Modal box */

#dialogbox{
float:left;
width:344px;
padding:5px;
background:rgba(255, 255, 255, 0.2);
border-radius:10px;
}

#box-header {
background-image: -moz-linear-gradient(center top , #D2DEE3 0%, #C7D6DB 50%, #B8CBD1 50%, #BBCDD3 100%);
background-image: -webkit-linear-gradient(-90deg , #D2DEE3 0%, #C7D6DB 50%, #B8CBD1 50%, #BBCDD3 100%);
background-color:#D2DEE3;
background-repeat:repeat;
border-radius: 5px 5px 0 0;
color: #324044;
font-size: 17px;
padding: 15px;
position: relative;
display: block;
cursor: default;
}

#close {
color: #314248;
cursor: pointer;
font-family: icons;
font-size: 26px;
position: absolute;
right: 5px;
top: 10px;
}

/* */
#box-content{
text-align:center;
background:#fff;
color:#7c7c7c;
font-size:13px;
float:left;
padding: 10px 5px;
}

.yes{
background-image: -moz-linear-gradient(center top , #c1e087 0%, #c3e092 50%, #bbdd83 50%, #b7db7a 100%);
background-image: -webkit-linear-gradient(-90deg , #c1e087 0%, #c3e092 50%, #bbdd83 50%, #b7db7a 100%);
background-color:#c1e087;
background-repeat:repeat;
font-size:12px;
padding:10px 35px;
border:1px solid #81aa3c;
border-radius:5px;
margin:2px 5px;
float:left;
cursor:pointer;
}

.yes:hover{
box-shadow: 0 0 5px #a7bc84;
}

.no{
background-image: -moz-linear-gradient(center top , #f6b2b2 0%, #f7bfbf 50%, #f7c1c1 50%, #f5b1b1 100%);
background-image: -webkit-linear-gradient(-90deg , #f6b2b2 0%, #f7bfbf 50%, #f7c1c1 50%, #f5b1b1 100%);
background-repeat:repeat;
background-color:#f6b2b2;
font-size:12px;
padding:10px 35px;
border:1px solid #d38e8e;
color:#582121;
cursor:pointer;
border-radius:5px;
float:left;
margin:2px 5px;
}

.no:hover{
box-shadow: 0 0 5px #B98B8B;
}
[/css]

I hope that with the help of this tutorial you learned a lot, you can use this for free in any of your creative work(don't forget to give me a back-link :P). Tweet, FB Shares and other suggestions are always welcomed at WT.

May 15, 2012

CSS3 & HTML 5 Login Form With Validation

Today's tutorial is based on simple and attractive CSS3 HTML5 login and registering form with fields validation. In html5 we can actually do validation without using any external JQuery or other scripts.

In this tutorial we would:

  • Design a toggle functionality using checkbox.

  • Make two forms with HTML5 validation inputs

  • And CSS3 toppings


css3-login-form
So the logic for toggle is simple, if checked then show the form else hide the form. With CSS3 we can give transition effects.

So here is the HTML markup for Toggle:

[html]
<input type="checkbox" id="login_toggle" checked=""/>
<label id="toggle" for="login_toggle">Click here to login</label>
[/html]

CSS3 Markup for its effect and styling:

[css]
#login_toggle:checked + #login-form {
top: -210px;
}

#toggle {
background-image: url("bg.png");
border: 3px solid #FFFFFF;
float: right;
padding: 5px 50px;
position: relative;
right: 80px;
top: 210px;
color: #fff;
border-top: 0px;
text-shadow: 0 0 1px #000000;

border-radius: 0 0 4px 4px;

-webkit-box-shadow: 1px 4px 4px #000000;
-moz-box-shadow: 1px 4px 4px #000000;
box-shadow: 1px 4px 4px #000000;
cursor: pointer;
}
[/css]

In html5 we can set a new attribute to input type named as required. When this attribute is inserted then the form won't process until its validated.

HTML5 form markup

[html]
<form id="loginForm" class="right">
<div id="input">
<input class="input username" type="text" placeholder="Username" name="username" required />
<span>A</span>
</div>

<div id="input">
<input class="input password" type="password" placeholder="Password" name="password" required />
<span>L</span>
</div>

<div id="input">
<input type="submit" class="submit" value="Login">
</div>
</form>
[/html]

Simple isn't it? Just try the demo and have fun with CSS3, there's so much creativity you can do with it.

Apr 27, 2012

CSS3 Powered Portfolio & Menu

Today I just saw a nice JQuery menu which impressed me and my friends. One of my friend challenged me to make this in CSS3, so within few hours I completed the challenge and came up with a nice concept of PORTFOLIO + MENU.

I am going to share a tutorial on making a portfolio website within a menu using CSS3.

We will make a li list menu and inside that we will wrap our content div,

  • on hover of menu some nice effects + on click our content = a perfect CSS3 powered portfolio website.


css3-menu
HTML Markup:

[html]
<div id="wrapper">
<div id="portfolio">
<ul id="box">
<li style="background-color: #2C618F;">Home
<input type="checkbox" id="oneCheck" />
<label for="oneCheck"></label>
<div class="content" style="background-color: #2C618F;"><p>Welcome to WebsTutorial.Com(WT), find amazing tutorials on CSS3, HTML5, PHP, JQuery, AJAX, Wordpress and many more.<br />
Some cool tutorials.
<dl id="list">
<dt><a href="http://webstutorial.com/range-input-slider-html5-css3/html-5" target="_blank">HTML5 Range Slider</a></dt>
<dt><a href="http://webstutorial.com/css3-tabs/css3" target="_blank">CSS3 Tabs</a></dt>
<dt><a href="http://webstutorial.com/css3-clock/css3" target="_blank">CSS3 Clock</a></dt>
</dl>
</p><label for="oneCheck">X</label></div>
</li>
<li style="background-color: #91AB31;">About Us
<input type="checkbox" id="twoCheck" />
<label for="twoCheck"></label>
<div class="content" style="background-color: #91AB31;"><p>WebsTutorial is a website for all kind of website coders, here we share amazing tutorials on topics like HTML5, CSS3, JQuery, AJAX etc. We also share tutorials for making you learn PHP, cake php, codeigniter. We also work as freelancers for making websites in CMS or Frameworks.</p><label for="twoCheck">X</label></div>
</li>
<li style="background-color: #714A28;">Portfolio
<input type="checkbox" id="threeCheck" />
<label for="threeCheck"></label>
<div class="content" style="background-color: #714A28;">
<p style="overflow-y: scroll; height: 200px; padding: 0pt 40px;">
<img src="http://quanticalabs.com/Nostalgia/Template/image/_sample/thumb_img1.jpg" />
<img src="http://quanticalabs.com/Nostalgia/Template/image/_sample/thumb_img2.jpg" />
<img src="http://quanticalabs.com/Nostalgia/Template/image/_sample/thumb_img3.jpg" />
<img src="http://quanticalabs.com/Nostalgia/Template/image/_sample/thumb_img4.jpg" />
<img src="http://quanticalabs.com/Nostalgia/Template/image/_sample/thumb_img5.jpg" />
<img src="http://quanticalabs.com/Nostalgia/Template/image/_sample/thumb_img6.jpg" />
<img src="http://quanticalabs.com/Nostalgia/Template/image/_sample/thumb_img7.jpg" />
<img src="http://quanticalabs.com/Nostalgia/Template/image/_sample/thumb_img8.jpg" />
</p>
<label for="threeCheck">X</label></div>
</li>
<li style="background-color: #E58600;">Contact Us
<input type="checkbox" id="fourCheck" />
<label for="fourCheck"></label>
<div class="content" style="background-color: #E58600;"><p>You can always contact us by emailing us your queries, suggestions or enquiries on <a href="mailto:admin@webstutorial.com">admin@webstutorial.com</a></p><label for="fourCheck">X</label></div>
</li>
</ul>
</div>
</div>
[/html]

HTML is really simple ti understand, now comes the CSS3 code:

[css]
ul#box {
background: none repeat scroll 0 0 #EEEEEE;

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

-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) inset;
-moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) inset;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) inset;
float: left;
padding: 20px;
position: relative;
width: 400px;
}

#box li {
list-style-type: none;
float: left;
width: 200px;
font-size: 0px;

-webkit-transition: font ease 500ms;
-moz-transition: font ease 500ms;
-o-transition: font ease 500ms;
-ms-transition: font ease 500ms;
transition: font ease 500ms;
width: 200px;
height: 120px;
text-align: center;
color: #fff;
font-style: italic;
overflow: hidden;
}

#box li input[type="checkbox"] {
display: none;
}

#box li:hover {
font-size: 28px;

background-image: -webkit-linear-gradient(center top , rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0));
background-image: -moz-linear-gradient(center top , rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0));
background-image: -o-linear-gradient(center top , rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0));
background-image: -ms-linear-gradient(center top , rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0));
background-image: linear-gradient(center top , rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0));
}

#box li label {
background: transparent;
width: 200px;
height: 120px;
display: block;
}

.content {
height: 0;
overflow: hidden;
padding: 0;
width: 0;
font-size: 12px;

-webkit-transition: all 0.3s ease-out 0s;
-moz-transition: all 0.3s ease-out 0s;
-o-transition: all 0.3s ease-out 0s;
-ms-transition: all 0.3s ease-out 0s;
transition: all 0.3s ease-out 0s;
z-index: 100;
position: absolute;
top: 20px;
left: 20px;
}

#oneCheck:checked ~ .content,#twoCheck:checked ~ .content,#threeCheck:checked ~ .content,#fourCheck:checked ~ .content {
font-size: 12px;
height: 230px;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=95)";
filter: alpha(opacity=95);
opacity: 0.95;
padding: 10px 10px 0;
width: 380px;
overflow: visible;
}

.content label {
display: none;
}

#oneCheck:checked ~ .content label,#twoCheck:checked ~ .content label,#threeCheck:checked ~ .content label,#fourCheck:checked ~ .content label {
border: 5px solid #FFFFFF;

-webkit-border-radius: 40px 40px 40px 40px;
-moz-border-radius: 40px 40px 40px 40px;
border-radius: 40px 40px 40px 40px;
color: #FFFFFF;
cursor: pointer;
font: bold 20px/40px arial,helvetica;
height: 40px;
position: absolute;
right: -20px;
text-align: center;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=95)";
filter: alpha(opacity=95);
opacity: 0.95;
background: #000000;
top: -20px;
width: 40px;
}
[/css]

We are simply using checkbox to show and hide the portfolio content using :checked pseudo class.
On checked we are showing the content div using CSS3 transition effects.

Why to use JQuery when you have power of CSS3 ;)

Apr 19, 2012

CSS3 Image Hover Effects With Caption | NO JAVASCRIPT

A simple css3 snippet share, to show image hover effects with caption text. I recently saw a website where the author of the site nicely presented his description using simple CSS3 and his own photo. Previously we use to do with having our own photo and beneath we use to write small description, but now CSS3 is here to help us.

Lets start with basic HTML layout. We will use an image, and the overlay text will be within the mask. On hover the mask will appear with CSS3 transition effect.

css3-effect

Basic HTML
[html]
<div class="view view-sixth" style="margin-bottom:30px">
<img src="PATH_TO_AUTHOR_IMAGE">
<div class="mask">
<h2>Hi, my name is Ntechi</h2>
<p>I am a php coder and sharing a simple CSS3 effect </p>
<a href="http://webstutorial.com" class="info" target="_blank">Read More</a>
</div>
</div>
[/html]
 


CSS

[css]
.view-sixth img {
-webkit-transition: all 0.4s ease-in-out 0.5s;
-moz-transition: all 0.4s ease-in-out 0.5s;
-o-transition: all 0.4s ease-in-out 0.5s;
-ms-transition: all 0.4s ease-in-out 0.5s;
transition: all 0.4s ease-in-out 0.5s;
}
.view-sixth .mask {
background: rgba(146,96,91,0.5);
-ms-filter: "progid: DXImageTransform.Microsoft.Alpha(Opacity=0)";
filter: alpha(opacity=0);
opacity: 0;
-webkit-transition: all 0.3s ease-in 0.4s;
-moz-transition: all 0.3s ease-in 0.4s;
-o-transition: all 0.3s ease-in 0.4s;
-ms-transition: all 0.3s ease-in 0.4s;
transition: all 0.3s ease-in 0.4s;
}
.view-sixth h2 {
-ms-filter: "progid: DXImageTransform.Microsoft.Alpha(Opacity=0)";
filter: alpha(opacity=0);
opacity: 0;
border-bottom: 1px solid rgba(0, 0, 0, 0.3);
background: transparent;
margin: 20px 40px 0px 40px;
-webkit-transform: scale(10);
-moz-transform: scale(10);
-o-transform: scale(10);
-ms-transform: scale(10);
transform: scale(10);
-webkit-transition: all 0.3s ease-in-out 0.1s;
-moz-transition: all 0.3s ease-in-out 0.1s;
-o-transition: all 0.3s ease-in-out 0.1s;
-ms-transition: all 0.3s ease-in-out 0.1s;
transition: all 0.3s ease-in-out 0.1s;
}
.view-sixth p {
-ms-filter: "progid: DXImageTransform.Microsoft.Alpha(Opacity=0)";
filter: alpha(opacity=0);
opacity: 0;
-webkit-transform: scale(10);
-moz-transform: scale(10);
-o-transform: scale(10);
-ms-transform: scale(10);
transform: scale(10);
-webkit-transition: all 0.3s ease-in-out 0.2s;
-moz-transition: all 0.3s ease-in-out 0.2s;
-o-transition: all 0.3s ease-in-out 0.2s;
-ms-transition: all 0.3s ease-in-out 0.2s;
transition: all 0.3s ease-in-out 0.2s;
}
.view-sixth a.info {
-ms-filter: "progid: DXImageTransform.Microsoft.Alpha(Opacity=0)";
filter: alpha(opacity=0);
opacity: 0;
-webkit-transform: translateY(100px);
-moz-transform: translateY(100px);
-o-transform: translateY(100px);
-ms-transform: translateY(100px);
transform: translateY(100px);
-webkit-transition: all 0.3s ease-in-out 0.1s;
-moz-transition: all 0.3s ease-in-out 0.1s;
-o-transition: all 0.3s ease-in-out 0.1s;
-ms-transition: all 0.3s ease-in-out 0.1s;
transition: all 0.3s ease-in-out 0.1s;
}
.view-sixth:hover .mask {
-ms-filter: "progid: DXImageTransform.Microsoft.Alpha(Opacity=100)";
filter: alpha(opacity=100);
opacity: 1;
-webkit-transition-delay: 0s;
-moz-transition-delay: 0s;
-o-transition-delay: 0s;
-ms-transition-delay: 0s;
transition-delay: 0s;
}
.view-sixth:hover img {
-webkit-transition-delay: 0s;
-moz-transition-delay: 0s;
-o-transition-delay: 0s;
-ms-transition-delay: 0s;
transition-delay: 0s;
}
.view-sixth:hover h2 {
-ms-filter: "progid: DXImageTransform.Microsoft.Alpha(Opacity=100)";
filter: alpha(opacity=100);
opacity: 1;
-webkit-transform: scale(1);
-moz-transform: scale(1);
-o-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
-webkit-transition-delay: 0.1s;
-moz-transition-delay: 0.1s;
-o-transition-delay: 0.1s;
-ms-transition-delay: 0.1s;
transition-delay: 0.1s;
}
.view-sixth:hover p {
-ms-filter: "progid: DXImageTransform.Microsoft.Alpha(Opacity=100)";
filter: alpha(opacity=100);
opacity: 1;
-webkit-transform: scale(1);
-moz-transform: scale(1);
-o-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
-webkit-transition-delay: 0.2s;
-moz-transition-delay: 0.2s;
-o-transition-delay: 0.2s;
-ms-transition-delay: 0.2s;
transition-delay: 0.2s;
}
.view-sixth:hover a.info {
-ms-filter: "progid: DXImageTransform.Microsoft.Alpha(Opacity=100)";
filter: alpha(opacity=100);
opacity: 1;
-webkit-transform: translateY(0px);
-moz-transform: translateY(0px);
-o-transform: translateY(0px);
-ms-transform: translateY(0px);
transform: translateY(0px);
-webkit-transition-delay: 0.3s;
-moz-transition-delay: 0.3s;
-o-transition-delay: 0.3s;
-ms-transition-delay: 0.3s;
transition-delay: 0.3s;
}

.view {
width: 200px;
height: 283px;
margin: 10px;
border: 10px solid #fff;
overflow: hidden;
position: relative;
text-align: center;
-webkit-box-shadow: 1px 1px 2px #e6e6e6;
-moz-box-shadow: 1px 1px 2px #e6e6e6;
box-shadow: 1px 1px 2px #e6e6e6;
cursor: default;
background: #fff url(../images/bgimg.jpg) no-repeat center center;
}
.view .mask,.view .content {
width: 200px;
height: 260px;
position: absolute;
overflow: hidden;
top: 0;
left: 0;
}
.view img {
display: block;
position: relative;
}
.view h2 {
text-transform: uppercase;
color: #fff;
text-align: center;
position: relative;
font-size: 17px;
padding: 10px;
background: rgba(0, 0, 0, 0.8);
margin: 20px 0 0 0;
}
.view p {
font-family: Georgia, serif;
font-style: italic;
font-size: 13px;
position: relative;
color: #fff;
padding: 10px 20px 20px;
text-align: center;
}
.view a.info {
display: inline-block;
text-decoration: none;
padding: 7px 14px;
background: #000;
color: #fff;
text-transform: uppercase;
-webkit-box-shadow: 0 0 1px #000;
-moz-box-shadow: 0 0 1px #000;
box-shadow: 0 0 1px #000;
border-radius:10px;
}
.view a.info:hover {
-webkit-box-shadow: 0 0 5px #000;
-moz-box-shadow: 0 0 5px #000;
box-shadow: 0 0 5px #000;
}
[/css]

 

Simple and clean, use it and share it.

Apr 3, 2012

CSS3 Tabs | NO JAVASCRIPT

TABS, a famous word in website development. Every coder has used it in websites but only using JQuery. Today I ll share a small trick to use tabs without using any JQueries but only using CSS3.

CSS3

Like previous tutorial on CSS3 toggle, in this also we will use pseudo element :target

The logic is really simple, we will form an unordered list, and inside li there will be a div with unique ID, when this unique ID will be called through some href link then the respective div will appear.

So here is the basic HTML Code:

[html]
<div id="container">
<p style="text-align:center;">CSS3 TABS. <b><i>NO JAVASCRIPT&nbsp;</i></b></p>
<div id="tabs">
<ul>
<li id="One"><a href="#One" id="first">One</a>
<div>
<p>In today’s tutorial I am going to share a simple way to make News Ticker and Notification Bar using CSS3, NO JAVASCRIPT. Previously it was very difficult to code it in javascript and make it work with other plugins, but today I decided to make it possible in CSS3 and voila, I succeeded So lets</p>
</div>
</li>
<li id="Two"><a href="#Two" id="sec">Two</a>
<div>
<p>While reading more about HTML5 & CSS3 I just found an amazing css3 button styling. This time I wanted to do something which I was doing from past 2 years using JQuery. In this tutorial I am going to teach you how to make a toggle slideDown and slideUp function using CSS3 and HTML5. To</p>
</div>
</li>
<li id="Three"><a href="#Three" id="third">Three</a>
<div>
<p>Lets start learning CSS3 before its too late, I just saw a website which amazed me with its animation effects. First I thought that the site is using some JQuery libraries but when I actually went into the code, I found it is CSS3. So I started learning it, and today I made my first Read more...</p>
</div>
</li>
</ul>
</div>
</div>
[/html]

We will be using transition to show the fade in fade out effect using opacity. On click of href the transition will be triggered and the opacity of the div changes.

CSS

[css]
li div {
-moz-transition: all 0.5s ease 0s;
-webkit-transition: all 0.5s ease 0s;
border: 1px solid #888888;
float: left;
opacity: 0;
padding: 0 15px;
position: absolute;
visibility: hidden;
width: 250px;
left:0;
background: -moz-linear-gradient(center top , #E3E3E3, #FFFFFF 85px) repeat scroll 0 0 transparent;
}

#tabs li a{
background: -moz-linear-gradient(center top , #E3E3E3, #FFFFFF 18px) repeat scroll 0 0 transparent;
border: 1px solid #888888;
margin: 0 3px 0 0;
padding: 5px 25px;
position: relative;
z-index:1;
font-size: 14px;
border-radius:10px 10px 0 0;
display:block;
top:1px;
}

#One:target div, #Two:target div, #Three:target div{
opacity:1;
visibility:visible;
}
[/css]

You can download and check the demo, share it if you like it and suggestions are always welcome.

Mar 27, 2012

CSS3 News Ticker | CSS3 Notification Like Stackexchange

In today's tutorial I am going to share a simple way to make News Ticker and Notification Bar using CSS3, NO JAVASCRIPT.

CSS3
Previously it was very difficult to code it in javascript and make it work with other plugins, but today I decided to make it possible in CSS3 and voila, I succeeded

So lets start with basic html code:

[html]
<div id="bar">
<input type="checkbox" id="close" />
<label for="close" id="header"><span>Click Here!</span></label>

<div id="fluid-bar">
<div id="wrap">
<div id="news_ticker">
<p style="float: left; color: rgb(255, 255, 255); margin: 5px 0pt 0pt 10px;">Latest news</p>
<ul>
<li><a href="#">Samsung Galaxy S2</a></li>
<li><a href="#">LG Optimus Black</a></li>
<li><a href="#">Samsung Note</a></li>
<li><a href="#">Sony Xperia S</a></li>
</ul>
<p style="float: left; color: #000000; margin: 5px 0pt 0pt 10px;">|</p>
<p style="float: left; color: rgb(255, 255, 255); margin: 5px 0pt 0pt 10px;">Notification message</p>
</div>
</div>
</div>
</div>
[/html]

 
News ticker logic is simple, we make the UL tag height fixed and will change the position of LI to move top all the time.

Notification bar logic is tricky, here we will be using checkbox, if checked then toggle the bar.

CSS for Notification Bar:

 
[css]
#fluid-bar {
background-color: #F26D5E;
height: 35px;

-webkit-transition: all 0.5s ease-out;
-moz-transition: all 0.5s ease-out;
-o-transition: all 0.5s ease-out;
-ms-transition: all 0.5s ease-out;
transition: all 0.5s ease-out;
overflow: hidden;
}

#close {
position: absolute;
right: 5px;
display: none;
}

#close:checked ~ #header:after {
content: "X";
color: #F26D5E;
}

#close:checked ~ #fluid-bar {
height: 0px;
}
[/css]

And the css for notification bar:

 
[css]
@-moz-keyframes ticker {
0% {
top: 0;
}
25% {
top: -20px;
}
50% {
top: -40px;
}
75% {
top: -60px;
}
100% {
top: 0;
}

}

ul {
background: none repeat scroll 0 0 #FFFFFF;

-webkit-border-radius: 5px 5px 5px 5px;
-moz-border-radius: 5px 5px 5px 5px;
border-radius: 5px 5px 5px 5px;
height: 20px;
margin: 5px;
float: left;
overflow: hidden;
width: 150px;
}

li {
list-style: none;
}

li a {
color: #35A2D4;
font-family: tahoma;

-webkit-animation: ticker 10s cubic-bezier(1, 0, .5, 0) infinite;
-moz-animation: ticker 10s cubic-bezier(1, 0, .5, 0) infinite;
-ms-animation: ticker 10s cubic-bezier(1, 0, .5, 0) infinite;
animation: ticker 10s cubic-bezier(1, 0, .5, 0) infinite;
position: relative;
}
[/css]

You can check the demo and download the files. Share it if you found it helpful.

Feb 16, 2012

HTML5 & CSS3 Toggle slideup and slidedown | NO JAVASCRIPT

While reading more about HTML5 & CSS3 I just found an amazing css3 button styling. This time I wanted to do something which I was doing from past 2 years using JQuery. In this tutorial I am going to teach you how to make a toggle slideDown and slideUp function using CSS3 and HTML5.

html5-css3

To achieve this we will have to know the pseudo element :Target.

Target element takes the href value and finds the element with its ID(value).

In this tutorial I am going to take the CSS3 styling from Tympanus and add my CSS3 function of toggle.

So here is the HTML structure

[html]
<div class="container">
<section>
<div id="container_buttons">
<h1>
HTML5 & CSS3 Toggle slideup and slidedown using NO JAVASCRIPT.
</h1>

<div style="clear:both"></div>
<ul>
<li class="toggle">
<a href="#One">A clock made in CSS3 | NO Javascript</a>
<p id="One">
Lets start learning CSS3 before its too late, I just saw a website which amazed me with its animation effects. First I thought that the site is using some JQuery libraries but when I actually went into the code, I found it is CSS3. So I started learning it, and today I made my first <a href="http://webstutorial.com/css3-clock/css3">Read more...</a>
</p>
</li>
<li class="toggle">
<a href="#Two">Learn CakePHP From Novice to Professional : Part 2</a>
<p id="Two">
Model-View-Controller Cake enforces an MVC structure for your web applications. Basically, it effectively separates typical operations into specific areas: MODELS : for all your database interaction VIEWS : for all your output and displays CONTROLLERS : for all your commands/scripts for input and program flow The typical PHP application mixes each of these three functions <a href="http://webstutorial.com/learn-cakephp-novice-professional-part-2/framework">Read more...</a>
</p>
</li>
<li class="toggle">
<a href="#Three">Learn CakePHP From Novice to Professional : Part 1</a>
<p id="Three">
This guide is for beginners to CakePHP. Whether or not you have much experience with the PHP scripting language, working in Cake will require some new methods you may or may not have tried before. If you don't know what a "has-and-belongs-to-many" relationship is, don't know how to build your own class object, or don't <a href="http://webstutorial.com/learn-cakephp-novice-professional-part-1/framework">Read more...</a>
</p>
</li>

<li class="toggle">
<a href="#Four">Google Maps Server Side Geocoding Using PHP and Infobox Fully AJAX</a>
<p id="Four">
Recently I got a new project of real estate where I had to display about 1000 of projects on the google map. I was having the address of 1000 projects, so I started with my php and js code. When I coded and started testing, I found that on the map only 20-30 markers were <a href="http://webstutorial.com/google-server-side-geocoding-php-infobox/website-tweaks/google">Read more...</a>
</p>
</li>

<li class="toggle">
<a href="#Five">Learn Codeigniter | Codeigniter Tutorial | Codeigniter Lessons | Part 1 | Webs Tutorial</a>
<p id="Five">
What is CodeIgniter? CodeIgniter is an open source PHP framework. This framework is used to build web applications and websites. CodeIgniter is best for developers who are into front-end development. It's easy to learn and it's fully flexibe. To learn CI (CodeIgniter), you should know PHP, MYSQL, OOPs and MVC. If you are new to <a href="http://webstutorial.com/codeigniter-tutorials-codeigniter-lessons-part-1/programming/php">Read more...</a>
</p>
</li>
</ul>

<em style="float: right;margin:10px 0;">Credits: <a href="webstutorial.com">WebsTutorial</a> & <a href="http://tympanus.net/codrops/2012/01/11/css-buttons-with-pseudo-elements/" rel="nofollow" target="_blank">Tympanus</a></em>

</div>
</section>
</div>
[/html]

Here we are making a simple unordered list structure, each list consits an anchor tag and a paragraph tag. Anchor will have a href pointing to ID of a paragraph tag.

And the final CSS to toggle the paragraph tag is

[css]
li p {
display: none;
padding: 10px 20px;
}

li p:target{
display:block;
}
[/css]

Feb 15, 2012

A clock made in CSS3 | NO Javascript

Lets start learning CSS3 before its too late, I just saw a website which amazed me with its animation effects. First I thought that the site is using some JQuery libraries but when I actually went into the code, I found it is CSS3. So I started learning it, and today I made my first CSS3 clock. This clock has 3 hands: seconds, minutes and an hour. All hands by default start moving from 12.

CSS3

In this tutorial we going to use some of the CSS3 major elements.

  • Animation

  • Transform

  • Keyframes


All three elements need to be cross browser coded.

  • For firefox -moz-

  • For Chrome -webkit-


So here is the css code for seconds hand.

[css]
.seconds{
width:200px;
height:200px;
border-left:2px solid #2187e7;
display:block;
-moz-animation:rotate 60s infinite linear;
-webkit-animation:rotate 60s infinite linear;
border-radius:50%;
}
[/css]

The animation takes following properties:
animation:name duration timing-function delay iteration-count direction;

Here we are going to use name, duration, direction and iteration-count elements.

Our name is rotate, 60 seconds for one animation, direction will be linear and infinite loop animation.

Following is the keyframe code,

[css]
@-moz-keyframes rotate
{
from {-moz-transform:rotate(0deg);}
to {-moz-transform:rotate(360deg);}
}
[/css]

We set points in this keyframe, the start point and the end point. In from point we will use transform element to rotate it from 0 degree and in to we set it till 360 degree. So in every animation it will rotate from 0 degree to 360 degree.

Similarly we code for the minute and the hour hand.

Entire Code:

[html]
<style>
body{background:#000000;}
#wrapper {
left: 40%;
padding: 10px;
position: absolute;
top: 20%;
width: 300px;
}
.seconds{
width:200px;
height:200px;
border-left:2px solid #2187e7;
display:block;
-moz-animation:rotate 60s infinite linear;
-webkit-animation:rotate 60s infinite linear;
border-radius:50%;
}

.minutes{
-moz-animation:rotate 3600s infinite linear;
-webkit-animation:rotate 3600s infinite linear;
width:100px;
height:100px;
border-top:2px solid #fff;
border-bottom:2px solid #fff;
display:block;
border-radius:50%;
position: absolute;
left: 61px;
top: 60px;
box-shadow: 0 0 35px #fff;
}

.hour{
-moz-animation:rotate 43200s infinite linear;
-webkit-animation:rotate 43200s infinite linear;
width:50px;
height:50px;
border-left:2px solid #fff;
border-right:2px solid #fff;
display:block;
border-radius:50%;
position: absolute;
left: 85px;
top: 87px;
box-shadow: 0 0 35px #fff;
}

@-moz-keyframes rotate
{
from {-moz-transform:rotate(0deg);}
to {-moz-transform:rotate(360deg);}
}

@-webkit-keyframes rotate
{
from {-webkit-transform:rotate(0deg);}
to {-webkit-transform:rotate(360deg);}
}

.seconds span{
border-left: 1px solid #FFFFFF;
display: block;
height: 100px;
left: 100px;
position: relative;
top: 0;
width: 100px;
}

.minutes span{
border-left: 1px solid #FFFFFF;
display: block;
height: 50px;
left: 50px;
position: relative;
top: 0;
width: 50px;
}

.hour span{
border-left: 1px solid #FFFFFF;
display: block;
height: 25px;
left: 25px;
position: relative;
top: 0;
width: 25px;
}

</style>
<div id="wrapper">
<div class="seconds">
<span></span>
</div>
<div class="minutes">
<span></span>
</div>
<div class="hour">
<span></span>
</div>
</div>
[/html]