Page Widget How to - Create CSS3 checkerboard pattern








Question

We would like to know how to create CSS3 checkerboard pattern.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
body {<!--from  ww w.jav  a 2 s  .c om-->
  background-image: -moz-linear-gradient(45deg, #000 25%, transparent 25%),
    -moz-linear-gradient(-45deg, #000 25%, transparent 25%),
    -moz-linear-gradient(45deg, transparent 75%, #000 75%),
    -moz-linear-gradient(-45deg, transparent 75%, #000 75%);
  background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(.25, #000),
    color-stop(.25, transparent)),
    -webkit-gradient(linear, 0 0, 100% 100%, color-stop(.25, #000),
    color-stop(.25, transparent)),
    -webkit-gradient(linear, 0 100%, 100% 0, color-stop(.75, transparent),
    color-stop(.75, #000)),
    -webkit-gradient(linear, 0 0, 100% 100%, color-stop(.75, transparent),
    color-stop(.75, #000));
  -moz-background-size: 100px 100px;
  background-size: 200px 200px;
  -webkit-background-size: 100px 101px;
  background-position: 0 0, 50px 0, 50px -50px, 0px 50px;
}
</style>
</head>
<body>
</body>
</html>

The code above is rendered as follows: