Thursday 26 December 2013

zindex-basics

Z-Index-Basics

I'm sure you're familiar with three-dimensional coordinate space. We have an x-axis which is typically used to represent the horizontal, a y-axis to represent the vertical, and a z-axis used to represent what happens into and out of the page, or the screen in our case.


We don't literally see the z-axis, as the screen is a two-dimensional plane. We see it in the form of perspective and of some elements appearing in front of or behind other elements when they share the same two-dimensional space.

To determine where along this third axis an element is located, CSS allows us to set
three values on the z-index property.
  • auto ( default )
  • integer
  • inherit
For the moment let's focus on the integer value. This can be positive, negative, or 0. The greater the value, the closer to the viewer the element appears. The lower the value, the further away it appears.

If two elements are positioned so they both occupy a shared area of two-dimensional space, the element with the greater z-index will obscure or occlude the element with the lower z-index in the areas where they share the space.

HTML

<div class="one">
  <div class="two"></div>
  <div class="three"></div>
</div>

<div class="four"></div>

CSS
div {
  width: 200px;
  height: 200px;
  padding: 20px;
}

.one, .two, .three, .four {
  position: absolute;
}
  
.one {
  background: #f00;
  outline: 5px solid #000;
  top: 100px;
  left: 200px;
  z-index: 10;
}
  
.two {
  background: #0f0;
  outline: 5px solid #000;
  top: 50px;
  left: 75px;
  z-index: 100;
}

.three {
  background: #0ff;
  outline: 5px solid #000;
  top: 125px;
  left: 25px;
  z-index: 150;
}

.four {
  background: #00f;
  outline: 5px solid #ff0;
  top: 200px;
  left: 350px;
  z-index: 50;

}

jsfiddle link

http://jsfiddle.net/K7J35/

Even though div.two has the greater z-index (100), it actually sits below div.four (z-index = 50) on the page. You can see the result of the code above in the image below. The black and yellow borders show the different stacking contexts each element is in.



Since div.two is contained within div.one, its z-index is relative to div.one's stack. In effect what we really have is the following:
  • .one — z-index = 10
  • .two — z-index = 10.100
  • .three — z-index = 10.150
  • .four — z-index = 5
What we've done is moved div.one and everything it contains below div.four. No matter what values we set on the z-index property of elements inside div.onethey will always display below div.four.

If you're like me, this has probably tripped you up once or twice when working with z-index. Hopefully these examples help clear up why an element with a greater z-index sometimes ends up displaying behind another element with a lower z-index.

Conclusion

When you first encounter it, the z-index property seems like a very simple property to understand. Values represent a location on an axis into and out of the screen, and that's all.


Thursday 19 December 2013

hover styling in inline css

IN CSS a:hover style in inline

<a href="#" style="background-color:white;"

onMouseOver="this.style.backgroundColor='#999999'"
onMouseOut="this.style.backgroundColor='#ffffff'">
YOUR BLOCK YOUR BLOCK YOUR BLOCK 
</a>

Jsfiddle link

http://jsfiddle.net/fsx3L/

Thursday 12 December 2013

Exploring canvas drawing techniques

Free Drawing in <canvas>

In html
<canvas id="c" width="500" height="300"></canvas>

In CSS
canvas{ border: 1px solid #ccc; }

In JS

var el = document.getElementById('c');
var ctx = el.getContext('2d');
var isDrawing;
el.onmousedown = function(e) {
  isDrawing = true;
  ctx.moveTo(e.clientX, e.clientY);
};
el.onmousemove = function(e) {
  if (isDrawing) {
    ctx.lineTo(e.clientX, e.clientY);
    ctx.stroke();
  }
};
el.onmouseup = function() {
  isDrawing = false;
};

BASIC

Editor link

For all drawing techniques 

Monday 9 December 2013

Stop Cooking Live Animals In China

Putting a live dog, or any animal, in boiling water, or a hot oven, or using a blow torch on cats, is not only blatantly wrong, without further explanation---but if one is necessary it is TORTURE. 

The 'reason' that is given for cooking animals alive is that they simply "taste better" after their bodies are adrenaline-soaked with fear and pain. 'Taste' is never an excuse for unspeakable cruelty, nor is 'culture' an excuse. 

China is making so many strides to become a first world country, but with all due respect, with this kind of accepted culinary method, China AND Korea will be looked upon as backward nations by the rest of the civilized world (one foot in the 21st century and one foot in a primitive age). 

Any animal placed in boiling water or cooked, while still alive, in any manner is obviously terrified, in unimaginable pain, despair and doomed to a slow and lingering death. Animals in the food chain should, at the very least, be given the most humane death possible.


Save Animals

The Shocking Truth Behind Snakeskin Fashions


Snakes are remarkable animals, but they have an unearned negative reputation. Some people have even come to fear these stunning animals, but in reality, 
snakes have more reasons to fear us.

Every year, at least 440,000 pythons are slaughtered in Indonesia, Malaysia, and Vietnam—just to be made into shoes and handbags! The real number is probably way higher because this number doesn’t include the thousands of illegally traded pythons who are exported annually.
Most are torn from their own homes deep in the jungles of Indonesia and Malaysia.


Once they are captured, their heads are often forced down and cut off with a machete. Others have their heads nailed to a tree and their skins slowly peeled off. Because of their slow metabolisms, snakes remain conscious and are able to feel pain and fear even after they have their heads cut off.


If they aren’t beheaded or nailed to a tree, they are beaten to death. Their jaws are forced open so that a tube can be jammed down their throats, then their bodies are pumped full of water to make their skins easier to remove. Ropes are tied tightly around their necks to prevent any fluid from escaping their bodies.



It can take up to 10 minutes for snakes to die.



Their bodies are slit open from end to end to loosen their once strong and protective skin.



Once the skin is limp, it is ripped from the snakes’ bodies. The snakes’ skins are no longer their own and are now the prized possessions of their captors. The skins are shipped off to tanneries to be treated with chemicals and sold to the fashion industry.




Many snakes are still alive as they are tossed into a pile of other snakes and left to die slowly. They often suffer for several days before dying from dehydration.

Snakes are not the only animals who suffer for fashion. Millions of lizards, alligators, crocodiles, and other reptiles are violently killed every year so that their skins can be torn from their bodies to make wallets, belts, boots, and handbags. Reptiles may be cold-blooded, but wearing their skins is cold-hearted.

Thursday 5 December 2013