contact: +977-01-2291892 | Email: info@yipl.com.np
CSS3 magic: Creating smilies and box with CSS3
CSS3 is coming and most of us must have already noticed the power (transitions, animation, transformation, gradient, etc.) of CSS3.
Early this morning I was experimenting with some of its properties and ended up creating following figures. I have used the border-radius, transform and text-shadow properties specific to CSS3.
Here's the demo:
Below are two illustrations (followed by their XHTML/CSS) of what can be achieved using CSS 3 only.


Smileys:
CSS:
- #content
- {
- width: 700px;
- margin: 0 auto;
- }
- .block
- {
- display: block;
- }
- .relative
- {
- position: relative;
- }
- .absolute
- {
- position: absolute;
- }
- .head
- {
- background: yellow;
- display: block;
- border: 1px solid #000;
- border-radius: 150px;
- -moz-border-radius: 150px; /* for firefox */
- -webkit-border-radius: 150px; /* for webkit browsers: safari, chrome */
- height: 300px;
- margin: 0 auto;
- width: 300px;
- float: left;
- }
- .head-two
- {
- margin-left: 10px;
- }
- .eye
- {
- border: 2px solid #000;
- background: #fff;
- border-radius: 40px;
- -moz-border-radius: 40px;
- -webkit-border-radius: 40px;
- height: 80px;
- top: 83px;
- width: 80px;
- }
- .left
- {
- left: 50px;
- }
- .right
- {
- right: 50px;
- }
- .pupil
- {
- background: #000;
- border-radius: 13px;
- -moz-border-radius: 13px;
- -webkit-border-radius: 13px;
- height: 26px;
- top: 114px;
- width: 26px;
- }
- .pupil-left
- {
- left: 80px;
- }
- .pupil-right
- {
- right: 80px;
- }
- .mouth
- {
- background: #000;
- height: 8px;
- top: 203px;
- left: 66px;
- width: 171px;
- transform: rotate(-15deg);
- -moz-transform: rotate(-15deg);
- -webkit-transform: rotate(-15deg);
- }
- .head-two .mouth
- {
- transform: none;
- -moz-transform: none;
- -webkit-transform: none;
- }
- .tongue
- {
- background: red;
- border-radius: 0 0 22px 22px;
- -moz-border-radius: 0 0 22px 22px;
- -webkit-border-radius: 0 0 22px 22px;
- height: 45px;
- top: 203px;
- left: 186px;
- width: 45px;
- }
XHTML
- <div id="content">
- <div class="head head-one block relative">
- <div class="eye left block absolute"></div>
- <div class="eye right block absolute"></div>
- <div class="pupil pupil-left block absolute"></div>
- <div class="pupil pupil-right block absolute"></div>
- <div class="mouth block absolute"></div>
- </div>
- <div class="head head-two block relative">
- <div class="eye left block absolute"></div>
- <div class="eye right block absolute"></div>
- <div class="pupil pupil-left block absolute"></div>
- <div class="pupil pupil-right block absolute"></div>
- <div class="mouth block absolute"></div>
- <div class="tongue block absolute"></div>
- </div>
- </div>
Box
CSS
- body
- {
- font-family: "Helvetica Nueue", Helvetica, Arial, sans-serif;
- }
- #container
- {
- margin: 0 auto;
- width: 600px;
- }
- .relative
- {
- position: relative;
- }
- .absolute
- {
- position: absolute;
- }
- .block
- {
- display: block;
- }
- .box
- {
- margin-top: 100px;
- }
- .top
- {
- background: #751616;
- height: 100px;
- width: 200px;
- transform: skew(45deg, 0deg);
- -moz-transform: skew(45deg,0deg);
- -webkit-transform: skew(45deg, 0deg);
- left: 51px;
- top: -51px;
- }
- .front
- {
- background: #a32727;
- color: #8f1a1a;
- display: block;
- font-size: 46px;
- font-weight: bold;
- height: 200px;
- left: 101px;
- top: 50px;
- width: 200px;
- }
- .front p
- {
- margin-top: 100px;
- margin-left: 50px;
- text-shadow: -1px -1px 1px #000;
- }
- .left
- {
- background: #a32727;
- height: 200px;
- width: 100px;
- transform: skew(0deg, 45deg);
- -moz-transform: skew(0deg,45deg);
- -webkit-transform: skew(0deg, 45deg);
- }
XHTML
- <div id="container">
- <div class="box relative">
- <div class="top absolute block"></div>
- <div class="front absolute block"><p>YIPL</p></div>
- <div class="left absolute block"></div>
- </div>
- </div>
These are just simple examples. You can explore following websites, if you want to see more of css3
47 Amazing CSS3 Animation Demos
http://www.the-art-of-web.com/css/css-animation/?nohilite
Using CSS3 Transitions, Transforms and Animation
Have a Field Day with HTML5 Forms
Recent blog posts
- YIPL at Barcamp Kathmandu 2010
- YIPL Podcast aims to inform about new technology
- CSS3 magic: Creating smilies and box with CSS3
- 5 reasons why YIPL is more likely to better manage your software projects
- Solving custom pager 10 only problem with views
- Cellroti.com goes live
- Happy Tihar!!!
- YIPLite featured in Wavemag
- YIPL proud of it's member for being 1st runner up in Open Software Challenge Nepal 2009
- YIPL makes its presence felt at the first BarCamp Kathmandu 2009