Thursday, February 26, 2015

What CSS3 CANNOT DO

  1. CANNOT use multiple :before or :after pseudo-elements, but you can use both :before and :after at the same time.

  2. In this demo, the box element creates 5 round-corner rectangles (blue & red).
    The :before pseudo element creates 3 yellow circles.
    The :after pseudo element creates 3 green rectangles.
    You may be wondering why there are more than 3 shapes. It is the power of box-shadow.
    <style>
    .box {
      display: inline-block;
      /*overflow: hidden; */
      position: relative;
      border-radius: .7em;
      /* the lenght of height and width do not matter */
      height: 2em;
      width: 2em;
      margin: 80px 50px; 
      font-size: 1em;
      /* use 'em' as the unit as it's scalable. change font size to make the shape larger or smaller */
      box-shadow: 2em 2em 0 0 red, 2em -2em 0 0 red, -2em -2em 0 0 red, -2em 2em 0 0 red;
      background: blue;
    }
    .box:after {
      content: '';
      position: absolute;
      top: .5em;
      left: 2em;
      height: 1em;
      width: 1em;
      background: lime;
      box-shadow: 2em 2em 0 0 green, 2em -2em 0 0 green;
    }
    .box:before {
      content: 'a';
      position: absolute;
      top: .5em;
      left: -1em;
      height: 1em;
      width: 1em;
      background: yellow;
      border-radius: 1em;
      box-shadow: -2em -2em 0 0 orange, -2em 2em 0 0 orange;
    }
    </style>
    <div class="box"></div>
    
  3. CANNOT use counter inside cacl() function



Create a Successful Online Store at Bigcommerce! Try it Free Now!

Tuesday, February 24, 2015

HTML5 CSS3 Scrolling Slideshow | HTML 5 & CSS 3 - Smooth Scrolling

Smooth scrolling slideshow using pure CSS3 code

In this article, I'm going to demo how to implement image slideshow using
  1. CSS2 and Javascript
  2. CSS3
And for CSS3 approach, I'll show how to implement
  1. Scrolling up
  2. Scrolling up and down
If you move the mouse over and out the slideshow, it will be paused and resumed accordingly.
Keypoints in the demo includes:
  • setInterval and clearInterval
  • transform and translateY
  • calc
  • animation including animation-play-state
To simplify the example, all the images here are standard AD sidebar images (300px * 250px).

1. CSS2 + Javascript

Sponsors
<style type='text/css'>
 	#ad_container {
		margin-bottom: 10px;
		padding: 0;
		height: 304px;
		width: 304px;
		border: 2px solid rgb(111, 126, 255);
		box-shadow: 2px 2px 10px rgb(111, 126, 255);
		border-radius: 15px 15px 0 0;
		overflow: hidden;
	}
	#ad_title {
		margin: 0;
		padding: 0;
		height: 50px;
		line-height: 50px;
		font-size: 24px;
		color: white;
		text-align: center;
		background: rgb(111, 126, 255); 
	}
	#ad_content {
		margin: 5px auto;
		padding: 0;
		height: 250px;
		width: 300px;
		overflow: hidden;
	}

	#ad_content1, #ad_content2 {
		margin: 0;
		padding: 0;
		list-style-type: none;
	}
</style>
<div id='ad_container'>
		<div id='ad_title'>Sponsors</div>
		<div id='ad_content'>
			<ul id='ad_content1'>
			<!-- MYADS CJ Disney -->
				<li><a href='http://www.kqzyfj.com/click-7744766-11138523' target='_top'>
	<img alt='' border='0' height='250' src='http://www.tqlkg.com/image-7744766-11138523' width='300'/></a></li>
			<!-- MYADS CJ Web Hosting -->
				<li><a href='http://www.anrdoezrs.net/click-7744766-11793715' target='_top'>
	<img alt='' border='0' height='250' src='http://www.awltovhc.com/image-7744766-11793715' width='300'/></a></li>
			<!-- MYADS CJ Hotel -->
				<li><a href='http://www.jdoqocy.com/click-7744766-10691018' target='_top'> <img alt='Hotels.com' border='0' height='250' src='http://www.tqlkg.com/image-7744766-10691018' width='300'/></a></li>
			</ul>
			<ul id='ad_content2'/>
		</div>
</div>
<script>
	var ad_content = document.getElementById('ad_content');
	ad_content.scrollTop = 0;

	var ad_content1 = document.getElementById('ad_content1');
	var ad_content2 = document.getElementById('ad_content2');
	ad_content2.innerHTML = ad_content1.innerHTML;

	function scrollUp() {

		if (ad_content.scrollTop >= ad_content1.offsetHeight)
		{
			ad_content.scrollTop = '5px';
		}
		else
		{
			ad_content.scrollTop ++;
		}
	}
	
	var speed = 30;
	var myScroll = setInterval('scrollUp()', speed);
	
	ad_content.onmouseover = function(){
		clearInterval(myScroll);
	}
	ad_content.onmouseout = function(){
		myScroll = setInterval("scrollUp()", speed);
	}
</script>
To make it a smoothing sliding, we need to clone the content of ad_content1 to ad_content2, this is achieved by ad_content2.innerHTML = ad_content1.innerHTML in the Javascript.

2. CSS3

Sponsors
<style type='text/css'>
	#ad_container {
		margin: 100px;
		padding: 0;
		height: 304px;
		width: 304px;
		border: 2px solid rgba(111, 126, 255, 0.9);
		box-shadow: 2px 2px 10px rgba(111, 126, 255, 0.7);
		border-radius: 15px 15px 0 0;
		overflow: hidden;
	}
	#ad_title {
		padding: 0;
		height: 50px;
		line-height: 50px;
		font-size: 24px;
		color: white;
		text-align: center;
		background: rgba(111, 126, 255, 0.8); 
	}

	@-webkit-keyframes scroll-up {
		0%   {-webkit-transform: translateY(0);}
	    /* the height of each image is 250px, so 4 images have the height of 1000px */
	    100% {-webkit-transform: translateY(-75%);}
	}

	@keyframes scroll-up {
		0%   {transform: translateY(0);}
	    /* the height of each image is 250px, so 4 images have the height of 1000px */
	    100% {transform: translateY(-75%);}
	}

	#ad_content {
		margin: 5px auto;
		padding: 0;
		height: 250px;
		width: 300px;
		overflow: hidden;
	}
	#ad_content1 {
		margin: 0;
		padding: 0;
		list-style-type: none;
		-webkit-animation: scroll-up ease-in-out 10s infinite;
		animation: scroll-up ease-in-out 10s infinite;
	}
	#ad_content1:hover {
		-webkit-animation-play-state: paused;
		animation-play-state: paused;
	}
	#ad_content1 li {
		margin: 0 auto;
		padding: 0;
	}
</style>
<div id="ad_container">
		<div id="ad_title">Sponsors</div>
		<div id="ad_content">
			<ul id="ad_content1">
			<!-- MYADS CJ Disney -->
				<li><a href='http://www.kqzyfj.com/click-7744766-11138523' target='_top'>
	<img alt='' border='0' height='250' src='http://www.tqlkg.com/image-7744766-11138523' width='300'/></a></li>
			<!-- MYADS CJ Web Hosting -->
				<li><a href='http://www.anrdoezrs.net/click-7744766-11793715' target='_top'>
	<img alt='' border='0' height='250' src='http://www.awltovhc.com/image-7744766-11793715' width='300'/></a></li>
			<!-- MYADS CJ Hotel -->
				<li><a href='http://www.jdoqocy.com/click-7744766-10691018' target='_top'> <img alt='Hotels.com' border='0' height='250' src='http://www.tqlkg.com/image-7744766-10691018' width='300'/></a></li>
			<!-- repeat the first image for seamless scroll-up, remove this for scroll-up up and down -->
			<!-- MYADS CJ Disney -->
				<li><a href='http://www.kqzyfj.com/click-7744766-11138523' target='_top'>
	<img alt='' border='0' height='250' src='http://www.tqlkg.com/image-7744766-11138523' width='300'/></a></li>
			</ul>
			<ul id="ad_content2"></ul>
		</div>
</div>
CSS3 animation makes it eaiser to implement a smooth image scrolling. Moveover, since animation supports different timing functions, like linear and ease, you can create different animation effects. You can also combine other properties such as opacity in the animation.

The downside for the pure CSS3 solution is that we have to clone the first image and append it to the end manually in our HTML structure.

Another issue in this approach is that we hardcoded the translate offset in the CSS definition, i.e., 100% {transform: translateY(-75%);}. This can be solved by using a CSS3 function called calc(). So the above CSS can be replaced with 100% {transform: translateY(calc(250px - 100%));}. But do check the compatibility table for this function since it is quite new.

3. CSS3 (Scrolling up and down)

Sponsors
<style type='text/css'>
	#ad_container {
		margin: 100px;
		padding: 0;
		height: 304px;
		width: 304px;
		border: 2px solid rgba(111, 126, 255, 0.9);
		box-shadow: 2px 2px 10px rgba(111, 126, 255, 0.7);
		border-radius: 15px 15px 0 0;
		overflow: hidden;
	}
	#ad_container >#ad_title {
		padding: 0;
		height: 50px;
		width: 100%;
		line-height: 50px;
		font-size: 24px;
		color: white;
		text-align: center;
		background: rgba(111, 126, 255, 0.8); 
	}

	@-webkit-keyframes scroll-up-down {
	    0%   {transform: translateY(0);}
	    50% {transform: translateY(-webkit-calc(250px - 100%));}
	    100% {transform: translateY(0);}
	}

	@keyframes scroll-up-down {
	    0%   {transform: translateY(0);}
	    50% {transform: translateY(calc(250px - 100%));}
	    100% {transform: translateY(0);}
	}

	#ad_container >#ad_content {
		margin: 5px auto;
		padding: 0;
		height: 250px;
		width: 300px;
		overflow: hidden;
	}
	#ad_container >#ad_content >#ad_content1 {
		margin: 0;
		padding: 0;
		list-style-type: none;
		-webkit-animation: scroll-up-down ease-in-out 10s infinite;
		animation: scroll-up-down ease-in-out 10s infinite;
	}
	#ad_container >#ad_content >#ad_content1:hover {
		-webkit-animation-play-state: paused;
		animation-play-state: paused;
	}
	#ad_container >#ad_content >#ad_content1 li {
		margin: 0 auto;
		padding: 0;
	}
</style>
<div id="ad_container">
		<div id="ad_title">Sponsors</div>
		<div id="ad_content">
			<ul id="ad_content1">
			<!-- MYADS CJ Disney -->
				<li><a href='http://www.kqzyfj.com/click-7744766-11138523' target='_top'>
	<img alt='' border='0' height='250' src='http://www.tqlkg.com/image-7744766-11138523' width='300'/></a></li>
			<!-- MYADS CJ Web Hosting -->
				<li><a href='http://www.anrdoezrs.net/click-7744766-11793715' target='_top'>
	<img alt='' border='0' height='250' src='http://www.awltovhc.com/image-7744766-11793715' width='300'/></a></li>
			<!-- MYADS CJ Hotel -->
				<li><a href='http://www.jdoqocy.com/click-7744766-10691018' target='_top'> <img alt='Hotels.com' border='0' height='250' src='http://www.tqlkg.com/image-7744766-10691018' width='300'/></a></li>
			</ul>
		</div>
</div>


Create a Successful Online Store at Bigcommerce! Try it Free Now!

Tuesday, February 17, 2015

Windows7 Hibernate | Windows 7 Enable Hibernate

Follow these steps to enable Hibernate Option on Windows 7:

  1. Open command prompt window (press Win Key and "R" key at the same time and key in "cmd" in the popup and then press "Enter") and execute the command "powercfg -h on".

  2. Go to Control Panel -> Power Options, find the active power plan and click "Change plan settings".

  3. In the popup, find "Sleep > Allow hybrid sleep" option, then change the setting to "Off". (Must perform step 1, otherwise this option may not be visible.)

  4.  To deactivate Hibernate option, execute the command "powercfg -h off".


Create a Successful Online Store at Bigcommerce! Try it Free Now!

HTML5 CSS3 Yinyang Bagua | HTML 5 & CSS 3 - Create a Yinyang Bagua Diagram

Create a Yinyang Bagua diagram using pure CSS3 code:

figure
<meta charset="UTF-8">
<style>
.container {
  margin: 100px;
  position: relative;
  width: 137px;
  height: 137px;
  border-left: 2px solid black;
  border-bottom: 2px solid black;
  border-right: 2px solid white;
  border-top: 2px solid white;
  border-radius: 100%;
  -moz-transform: rotate(45deg);
  -webkit-transform: rotate(45deg);
  transform: rotate(45deg);
}

.yinyang {
  width: 136px;
  height: 136px;
  background: -moz-linear-gradient(45deg, white 0%, white 50%, black 51%, black 100%);
  background: -webkit-linear-gradient(45deg, white 0%, white 50%, black 51%, black 100%);
  background: linear-gradient(45deg, white 0%, white 50%, black 51%, black 100%);
  border-radius: 100%;
}

.yinyang::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  top: 58px;
  left: 58px;
  background: white;
  border: 24px solid black;
  border-radius: 100%;
}

.yinyang::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  top: 10px;
  left: 10px;
  background: black;
  border: 24px solid white;
  border-radius: 100%;
}

.yao {
  -moz-transform: rotate(-45deg);
  -webkit-transform: rotate(-45deg);
  transform: rotate(-45deg);
  width: 68px;
  height: 24px;
  position: absolute;
  text-align: center;
}

.yao >div {
  margin: 0 auto;
  padding: 0;
  width: 60px;
  height: 5px;
  margin-bottom: 3px;
}

.qian {
  top: -25px;
  left: -45px;
}

.qian >.positive {
  background: rgb(0, 0, 0);
}

.kun {
  top: 135px;
  left: 115px;
  -moz-transform: rotate(135deg);
  -webkit-transform: rotate(135deg);
  transform: rotate(135deg);
}

.kun >.negative {
  background: -moz-linear-gradient(90deg, rgb(255, 255, 255) 0%, rgb(255, 255, 255) 40%, transparent 41%, transparent 59%, rgb(255, 255, 255) 60%, rgb(255, 255, 255) 100%);
  background: -webkit-linear-gradient(90deg, rgb(255, 255, 255) 0%, rgb(255, 255, 255) 40%, transparent 41%, transparent 59%, rgb(255, 255, 255) 60%, rgb(255, 255, 255) 100%);
  background: linear-gradient(90deg, rgb(255, 255, 255) 0%, rgb(255, 255, 255) 40%, transparent 41%, transparent 59%, rgb(255, 255, 255) 60%, rgb(255, 255, 255) 100%);
}

.li {
  top: 135px;
  left: -45px;
  -moz-transform: rotate(225deg);
  -webkit-transform: rotate(225deg);
  transform: rotate(225deg);
}

.li >.positive {
  background: rgb(0, 255, 0);
}

.li >.negative {
  background: -moz-linear-gradient(90deg, rgb(0, 255, 0) 0%, rgb(0, 255, 0) 40%, transparent 41%, transparent 59%, rgb(0, 255, 0) 60%, rgb(0, 255, 0) 100%);
  background: -webkit-linear-gradient(90deg, rgb(0, 255, 0) 0%, rgb(0, 255, 0) 40%, transparent 41%, transparent 59%, rgb(0, 255, 0) 60%, rgb(0, 255, 0) 100%);
  background: linear-gradient(90deg, rgb(0, 255, 0) 0%, rgb(0, 255, 0) 40%, transparent 41%, transparent 59%, rgb(0, 255, 0) 60%, rgb(0, 255, 0) 100%);
}

.kan {
  top: -25px;
  left: 115px;
  -moz-transform: rotate(45deg);
  -webkit-transform: rotate(45deg);
  transform: rotate(45deg);
}

.kan >.positive {
  background: rgb(255, 0, 255);
}

.kan >.negative {
  background: -moz-linear-gradient(90deg, rgb(255, 0, 255) 0%, rgb(255, 0, 255) 40%, transparent 41%, transparent 59%, rgb(255, 0, 255) 60%, rgb(255, 0, 255) 100%);
  background: -webkit-linear-gradient(90deg, rgb(255, 0, 255) 0%, rgb(255, 0, 255) 40%, transparent 41%, transparent 59%, rgb(255, 0, 255) 60%, rgb(255, 0, 255) 100%);
  background: linear-gradient(90deg, rgb(255, 0, 255) 0%, rgb(255, 0, 255) 40%, transparent 41%, transparent 59%, rgb(255, 0, 255) 60%, rgb(255, 0, 255) 100%);
}

.dui {
  top: 55px;
  left: -80px;
  -moz-transform: rotate(270deg);
  -webkit-transform: rotate(270deg);
  transform: rotate(270deg);
}

.dui >.positive {
  background: rgb(255, 0, 0);
}

.dui >.negative {
  background: -moz-linear-gradient(90deg, rgb(255, 0, 0) 0%, rgb(255, 0, 0) 40%, transparent 41%, transparent 59%, rgb(255, 0, 0) 60%, rgb(255, 0, 0) 100%);
  background: -webkit-linear-gradient(90deg, rgb(255, 0, 0) 0%, rgb(255, 0, 0) 40%, transparent 41%, transparent 59%, rgb(255, 0, 0) 60%, rgb(255, 0, 0) 100%);
  background: linear-gradient(90deg, rgb(255, 0, 0) 0%, rgb(255, 0, 0) 40%, transparent 41%, transparent 59%, rgb(255, 0, 0) 60%, rgb(255, 0, 0) 100%);
}

.gen {
  top: 55px;
  left: 150px;
  -moz-transform: rotate(90deg);
  -webkit-transform: rotate(90deg);
  transform: rotate(90deg);
}

.gen >.positive {
  background: rgb(0, 255, 255);
}

.gen >.negative {
  background: -moz-linear-gradient(90deg, rgb(0, 255, 255) 0%, rgb(0, 255, 255) 40%, transparent 41%, transparent 59%, rgb(0, 255, 255) 60%, rgb(0, 255, 255) 100%);
  background: -webkit-linear-gradient(90deg, rgb(0, 255, 255) 0%, rgb(0, 255, 255) 40%, transparent 41%, transparent 59%, rgb(0, 255, 255) 60%, rgb(0, 255, 255) 100%);
  background: linear-gradient(90deg, rgb(0, 255, 255) 0%, rgb(0, 255, 255) 40%, transparent 41%, transparent 59%, rgb(0, 255, 255) 60%, rgb(0, 255, 255) 100%);
}

.zhen {
  top: 170px;
  left: 35px;
  -moz-transform: rotate(180deg);
  -webkit-transform: rotate(180deg);
  transform: rotate(180deg);
}

.zhen >.positive {
  background: rgb(255, 255, 0);
}

.zhen >.negative {
  background: -moz-linear-gradient(90deg, rgb(255, 255, 0) 0%, rgb(255, 255, 0) 40%, transparent 41%, transparent 59%, rgb(255, 255, 0) 60%, rgb(255, 255, 0) 100%);
  background: -webkit-linear-gradient(90deg, rgb(255, 255, 0) 0%, rgb(255, 255, 0) 40%, transparent 41%, transparent 59%, rgb(255, 255, 0) 60%, rgb(255, 255, 0) 100%);
  background: linear-gradient(90deg, rgb(255, 255, 0) 0%, rgb(255, 255, 0) 40%, transparent 41%, transparent 59%, rgb(255, 255, 0) 60%, rgb(255, 255, 0) 100%);
}

.xun {
  top: -60px;
  left: 35px;
  -moz-transform: rotate(0deg);
  -webkit-transform: rotate(0deg);
  transform: rotate(0deg);  
}

.xun >.positive {
  background: rgb(0, 0, 255);
}

.xun >.negative {
  background: -moz-linear-gradient(90deg, rgb(0, 0, 255) 0%, rgb(0, 0, 255) 40%, transparent 41%, transparent 59%, rgb(0, 0, 255) 60%, rgb(0, 0, 255) 100%);
  background: -webkit-linear-gradient(90deg, rgb(0, 0, 255) 0%, rgb(0, 0, 255) 40%, transparent 41%, transparent 59%, rgb(0, 0, 255) 60%, rgb(0, 0, 255) 100%);
  background: linear-gradient(90deg, rgb(0, 0, 255) 0%, rgb(0, 0, 255) 40%, transparent 41%, transparent 59%, rgb(0, 0, 255) 60%, rgb(0, 0, 255) 100%);
}

</style>

<div class="container">  
  <div class="yinyang">
  </div>
  <div>
    <div class="qian yao">乾<div class="positive"></div><div class="positive"></div><div class="positive"></div></div>
    <div class="kun yao">坤<div class="negative"></div><div class="negative"></div><div class="negative"></div></div>
    <div class="li yao">离<div class="positive"></div><div class="negative"></div><div class="positive"></div></div>
    <div class="kan yao">坎<div class="negative"></div><div class="positive"></div><div class="negative"></div></div>
    <div class="dui yao">兑<div class="negative"></div><div class="positive"></div><div class="positive"></div></div>
    <div class="gen yao">艮<div class="positive"></div><div class="negative"></div><div class="negative"></div></div>
    <div class="zhen yao">震<div class="negative"></div><div class="negative"></div><div class="positive"></div></div>
    <div class="xun yao">巽<div class="positive"></div><div class="positive"></div><div class="negative"></div></div>
  </div>
</div>











Create a Successful Online Store at Bigcommerce! Try it Free Now!

Saturday, February 14, 2015

CSS Layout - Relative and Absolute Position

CSS Layout - Relative and Absolute

The position property is crucial to CSS layout. It has a couple of possible values. This article gives a simple example to help you understand the two most important values: relative and absolute.

CSS Sample

<style type="text/css">
.relative1 {
  position: relative;
  border: 1px solid red;
  color: red;
}
.relative2 {
  position: relative;
  top: -20px;
  left: 20px;
  width: 500px;
  border: 1px solid green;
  color: green;
}
.relative3 {
  position: relative;
  border: 1px solid orange;
  color: orange;
}
.absolute1 {
  position: absolute;
  top: -20px;
  left: 20px;
  width: 500px;
  border: 1px solid blue;
  color: blue;
}
.absolute2 {
  position: absolute;
  top: -20px;
  left: 20px;
  width: 500px;
  border: 1px solid black;
  color: black;
}
</style>
<div style="margin: 30px">
<div class="relative1"><p>relative1</p><p></p><p></p></div>
<div class="relative2"><p>relative2</p><p></p><p></p></div>
<div class="absolute1"><p>absolute1</p><p></p><p></p></div>
<div class="relative3"><p>relative3</p>
<div class="absolute2"><p>absolute2</p><p></p><p></p></div>
</div>
</div>


CSS Rules


There are two rules to remember:
  1. Setting the top, right, bottom, and left properties of a relatively-positioned element will cause it to be adjusted away from its normal position. In the example above, relative2 should be under relative1, however, since we set its top and left properties, it goes higher and to the left of its normal position. 
  2. A absolutely-positioned element is positioned relative to the nearest positioned ancestor (container). If an absolutely-positioned element has no positioned ancestors, it uses the document body. In the example above, absolute2 use relative3 as ancestor and adjusts accordingly. While absolute1 does not have an ancestor, so it adjusts according to the document.


Create a Successful Online Store at Bigcommerce! Try it Free Now!