понедельник, 17 марта 2014 г.

3D CSS3 Effects

3D Выделение с приближением

.box {
  transition: all 500ms cubic-bezier(0.190, 1.000, 0.220, 1.000);

  box-shadow: 0 1px 1px rgba(0,0,0,0.3);
  transform: translateY(0) scale(0.95, 0.95);
}

.box.active {
  box-shadow: 0 11px 18px rgba(0,0,0,0.2);
  transform: translateY(-20px) scale(1, 1);
}

3D Поворот


3D Переворачивающаяся карточка


flip-animations-with-shadow.css

@-webkit-keyframes back {
  0% {
    box-shadow: 0px 1px 1px rgba(0,0,0,0.3);
    -webkit-transform:
    scale(1)
    rotateY(180deg);
  }

  10% {
    box-shadow: 0px 1.0972799999999998px 1.0972799999999998px rgba(0,0,0,0.3);
    -webkit-transform:
    scale(1.000768)
    rotateY(180deg);
  }

  20% {
    box-shadow: 0px 4.112960000000001px 4.112960000000001px rgba(0,0,0,0.3);
    -webkit-transform:
    scale(1.024576)
    rotateY(180deg);
  }

  30% {
    box-shadow: 0px 16.88704px 16.88704px rgba(0,0,0,0.3);
    -webkit-transform:
    scale(1.125424)
    rotateY(180.17135717260666deg);
  }

  40% {
    box-shadow: 0px 19.90272px 19.90272px rgba(0,0,0,0.3);
    -webkit-transform:
    scale(1.149232)
    rotateY(185.48342952341287deg);
  }

  50% {
    box-shadow: 0px 20px 20px rgba(0,0,0,0.3);
    -webkit-transform:
    scale(1.15)
    rotateY(221.6397929434164deg);
  }

  60% {
    box-shadow: 0px 19.90272px 19.90272px rgba(0,0,0,0.3);
    -webkit-transform:
    scale(1.149232)
    rotateY(318.3602070565836deg);
  }

  70% {
    box-shadow: 0px 16.887040000000006px 16.887040000000006px rgba(0,0,0,0.3);
    -webkit-transform:
    scale(1.125424)
    rotateY(354.51657047658716deg);
  }

  80% {
    box-shadow: 0px 4.112959999999997px 4.112959999999997px rgba(0,0,0,0.3);
    -webkit-transform:
    scale(1.024576)
    rotateY(359.8286428273933deg);
  }

  90% {
    box-shadow: 0px 1.0972799999999998px 1.0972799999999998px rgba(0,0,0,0.3);
    -webkit-transform:
    scale(1.000768)
    rotateY(360deg);
  }

  100% {
    box-shadow: 0px 1px 1px rgba(0,0,0,0.3);
    -webkit-transform:
    scale(1)
    rotateY(360deg);
  }


}

@-moz-keyframes back {
  0% {
    box-shadow: 0px 1px 1px rgba(0,0,0,0.3);
    -moz-transform:
    scale(1)
    rotateY(180deg);
  }

  10% {
    box-shadow: 0px 1.0972799999999998px 1.0972799999999998px rgba(0,0,0,0.3);
    -moz-transform:
    scale(1.000768)
    rotateY(180deg);
  }

  20% {
    box-shadow: 0px 4.112960000000001px 4.112960000000001px rgba(0,0,0,0.3);
    -moz-transform:
    scale(1.024576)
    rotateY(180deg);
  }

  30% {
    box-shadow: 0px 16.88704px 16.88704px rgba(0,0,0,0.3);
    -moz-transform:
    scale(1.125424)
    rotateY(180.17135717260666deg);
  }

  40% {
    box-shadow: 0px 19.90272px 19.90272px rgba(0,0,0,0.3);
    -moz-transform:
    scale(1.149232)
    rotateY(185.48342952341287deg);
  }

  50% {
    box-shadow: 0px 20px 20px rgba(0,0,0,0.3);
    -moz-transform:
    scale(1.15)
    rotateY(221.6397929434164deg);
  }

  60% {
    box-shadow: 0px 19.90272px 19.90272px rgba(0,0,0,0.3);
    -moz-transform:
    scale(1.149232)
    rotateY(318.3602070565836deg);
  }

  70% {
    box-shadow: 0px 16.887040000000006px 16.887040000000006px rgba(0,0,0,0.3);
    -moz-transform:
    scale(1.125424)
    rotateY(354.51657047658716deg);
  }

  80% {
    box-shadow: 0px 4.112959999999997px 4.112959999999997px rgba(0,0,0,0.3);
    -moz-transform:
    scale(1.024576)
    rotateY(359.8286428273933deg);
  }

  90% {
    box-shadow: 0px 1.0972799999999998px 1.0972799999999998px rgba(0,0,0,0.3);
    -moz-transform:
    scale(1.000768)
    rotateY(360deg);
  }

  100% {
    box-shadow: 0px 1px 1px rgba(0,0,0,0.3);
    -moz-transform:
    scale(1)
    rotateY(360deg);
  }


}

@-ms-keyframes back {
  0% {
    box-shadow: 0px 1px 1px rgba(0,0,0,0.3);
    -ms-transform:
    scale(1)
    rotateY(180deg);
  }

  10% {
    box-shadow: 0px 1.0972799999999998px 1.0972799999999998px rgba(0,0,0,0.3);
    -ms-transform:
    scale(1.000768)
    rotateY(180deg);
  }

  20% {
    box-shadow: 0px 4.112960000000001px 4.112960000000001px rgba(0,0,0,0.3);
    -ms-transform:
    scale(1.024576)
    rotateY(180deg);
  }

  30% {
    box-shadow: 0px 16.88704px 16.88704px rgba(0,0,0,0.3);
    -ms-transform:
    scale(1.125424)
    rotateY(180.17135717260666deg);
  }

  40% {
    box-shadow: 0px 19.90272px 19.90272px rgba(0,0,0,0.3);
    -ms-transform:
    scale(1.149232)
    rotateY(185.48342952341287deg);
  }

  50% {
    box-shadow: 0px 20px 20px rgba(0,0,0,0.3);
    -ms-transform:
    scale(1.15)
    rotateY(221.6397929434164deg);
  }

  60% {
    box-shadow: 0px 19.90272px 19.90272px rgba(0,0,0,0.3);
    -ms-transform:
    scale(1.149232)
    rotateY(318.3602070565836deg);
  }

  70% {
    box-shadow: 0px 16.887040000000006px 16.887040000000006px rgba(0,0,0,0.3);
    -ms-transform:
    scale(1.125424)
    rotateY(354.51657047658716deg);
  }

  80% {
    box-shadow: 0px 4.112959999999997px 4.112959999999997px rgba(0,0,0,0.3);
    -ms-transform:
    scale(1.024576)
    rotateY(359.8286428273933deg);
  }

  90% {
    box-shadow: 0px 1.0972799999999998px 1.0972799999999998px rgba(0,0,0,0.3);
    -ms-transform:
    scale(1.000768)
    rotateY(360deg);
  }

  100% {
    box-shadow: 0px 1px 1px rgba(0,0,0,0.3);
    -ms-transform:
    scale(1)
    rotateY(360deg);
  }


}

@-o-keyframes back {
  0% {
    box-shadow: 0px 1px 1px rgba(0,0,0,0.3);
    -o-transform:
    scale(1)
    rotateY(180deg);
  }

  10% {
    box-shadow: 0px 1.0972799999999998px 1.0972799999999998px rgba(0,0,0,0.3);
    -o-transform:
    scale(1.000768)
    rotateY(180deg);
  }

  20% {
    box-shadow: 0px 4.112960000000001px 4.112960000000001px rgba(0,0,0,0.3);
    -o-transform:
    scale(1.024576)
    rotateY(180deg);
  }

  30% {
    box-shadow: 0px 16.88704px 16.88704px rgba(0,0,0,0.3);
    -o-transform:
    scale(1.125424)
    rotateY(180.17135717260666deg);
  }

  40% {
    box-shadow: 0px 19.90272px 19.90272px rgba(0,0,0,0.3);
    -o-transform:
    scale(1.149232)
    rotateY(185.48342952341287deg);
  }

  50% {
    box-shadow: 0px 20px 20px rgba(0,0,0,0.3);
    -o-transform:
    scale(1.15)
    rotateY(221.6397929434164deg);
  }

  60% {
    box-shadow: 0px 19.90272px 19.90272px rgba(0,0,0,0.3);
    -o-transform:
    scale(1.149232)
    rotateY(318.3602070565836deg);
  }

  70% {
    box-shadow: 0px 16.887040000000006px 16.887040000000006px rgba(0,0,0,0.3);
    -o-transform:
    scale(1.125424)
    rotateY(354.51657047658716deg);
  }

  80% {
    box-shadow: 0px 4.112959999999997px 4.112959999999997px rgba(0,0,0,0.3);
    -o-transform:
    scale(1.024576)
    rotateY(359.8286428273933deg);
  }

  90% {
    box-shadow: 0px 1.0972799999999998px 1.0972799999999998px rgba(0,0,0,0.3);
    -o-transform:
    scale(1.000768)
    rotateY(360deg);
  }

  100% {
    box-shadow: 0px 1px 1px rgba(0,0,0,0.3);
    -o-transform:
    scale(1)
    rotateY(360deg);
  }


}

@keyframes back {
  0% {
    box-shadow: 0px 1px 1px rgba(0,0,0,0.3);
    transform:
    scale(1)
    rotateY(180deg);
  }

  10% {
    box-shadow: 0px 1.0972799999999998px 1.0972799999999998px rgba(0,0,0,0.3);
    transform:
    scale(1.000768)
    rotateY(180deg);
  }

  20% {
    box-shadow: 0px 4.112960000000001px 4.112960000000001px rgba(0,0,0,0.3);
    transform:
    scale(1.024576)
    rotateY(180deg);
  }

  30% {
    box-shadow: 0px 16.88704px 16.88704px rgba(0,0,0,0.3);
    transform:
    scale(1.125424)
    rotateY(180.17135717260666deg);
  }

  40% {
    box-shadow: 0px 19.90272px 19.90272px rgba(0,0,0,0.3);
    transform:
    scale(1.149232)
    rotateY(185.48342952341287deg);
  }

  50% {
    box-shadow: 0px 20px 20px rgba(0,0,0,0.3);
    transform:
    scale(1.15)
    rotateY(221.6397929434164deg);
  }

  60% {
    box-shadow: 0px 19.90272px 19.90272px rgba(0,0,0,0.3);
    transform:
    scale(1.149232)
    rotateY(318.3602070565836deg);
  }

  70% {
    box-shadow: 0px 16.887040000000006px 16.887040000000006px rgba(0,0,0,0.3);
    transform:
    scale(1.125424)
    rotateY(354.51657047658716deg);
  }

  80% {
    box-shadow: 0px 4.112959999999997px 4.112959999999997px rgba(0,0,0,0.3);
    transform:
    scale(1.024576)
    rotateY(359.8286428273933deg);
  }

  90% {
    box-shadow: 0px 1.0972799999999998px 1.0972799999999998px rgba(0,0,0,0.3);
    transform:
    scale(1.000768)
    rotateY(360deg);
  }

  100% {
    box-shadow: 0px 1px 1px rgba(0,0,0,0.3);
    transform:
    scale(1)
    rotateY(360deg);
  }


}



@-webkit-keyframes front {
  0% {
    box-shadow: 0px 1px 1px rgba(0,0,0,0.3);
    -webkit-transform:
    scale(1)
    rotateY(0deg);
  }

  10% {
    box-shadow: 0px 1.0972799999999998px 1.0972799999999998px rgba(0,0,0,0.3);
    -webkit-transform:
    scale(1.000768)
    rotateY(0deg);
  }

  20% {
    box-shadow: 0px 4.112960000000001px 4.112960000000001px rgba(0,0,0,0.3);
    -webkit-transform:
    scale(1.024576)
    rotateY(0deg);
  }

  30% {
    box-shadow: 0px 16.88704px 16.88704px rgba(0,0,0,0.3);
    -webkit-transform:
    scale(1.125424)
    rotateY(0.17135717260665195deg);
  }

  40% {
    box-shadow: 0px 19.90272px 19.90272px rgba(0,0,0,0.3);
    -webkit-transform:
    scale(1.149232)
    rotateY(5.4834295234128625deg);
  }

  50% {
    box-shadow: 0px 20px 20px rgba(0,0,0,0.3);
    -webkit-transform:
    scale(1.15)
    rotateY(41.639792943416424deg);
  }

  60% {
    box-shadow: 0px 19.90272px 19.90272px rgba(0,0,0,0.3);
    -webkit-transform:
    scale(1.149232)
    rotateY(138.36020705658356deg);
  }

  70% {
    box-shadow: 0px 16.887040000000006px 16.887040000000006px rgba(0,0,0,0.3);
    -webkit-transform:
    scale(1.125424)
    rotateY(174.51657047658713deg);
  }

  80% {
    box-shadow: 0px 4.112959999999997px 4.112959999999997px rgba(0,0,0,0.3);
    -webkit-transform:
    scale(1.024576)
    rotateY(179.82864282739334deg);
  }

  90% {
    box-shadow: 0px 1.0972799999999998px 1.0972799999999998px rgba(0,0,0,0.3);
    -webkit-transform:
    scale(1.000768)
    rotateY(180deg);
  }

  100% {
    box-shadow: 0px 1px 1px rgba(0,0,0,0.3);
    -webkit-transform:
    scale(1)
    rotateY(180deg);
  }


}

@-moz-keyframes front {
  0% {
    box-shadow: 0px 1px 1px rgba(0,0,0,0.3);
    -moz-transform:
    scale(1)
    rotateY(0deg);
  }

  10% {
    box-shadow: 0px 1.0972799999999998px 1.0972799999999998px rgba(0,0,0,0.3);
    -moz-transform:
    scale(1.000768)
    rotateY(0deg);
  }

  20% {
    box-shadow: 0px 4.112960000000001px 4.112960000000001px rgba(0,0,0,0.3);
    -moz-transform:
    scale(1.024576)
    rotateY(0deg);
  }

  30% {
    box-shadow: 0px 16.88704px 16.88704px rgba(0,0,0,0.3);
    -moz-transform:
    scale(1.125424)
    rotateY(0.17135717260665195deg);
  }

  40% {
    box-shadow: 0px 19.90272px 19.90272px rgba(0,0,0,0.3);
    -moz-transform:
    scale(1.149232)
    rotateY(5.4834295234128625deg);
  }

  50% {
    box-shadow: 0px 20px 20px rgba(0,0,0,0.3);
    -moz-transform:
    scale(1.15)
    rotateY(41.639792943416424deg);
  }

  60% {
    box-shadow: 0px 19.90272px 19.90272px rgba(0,0,0,0.3);
    -moz-transform:
    scale(1.149232)
    rotateY(138.36020705658356deg);
  }

  70% {
    box-shadow: 0px 16.887040000000006px 16.887040000000006px rgba(0,0,0,0.3);
    -moz-transform:
    scale(1.125424)
    rotateY(174.51657047658713deg);
  }

  80% {
    box-shadow: 0px 4.112959999999997px 4.112959999999997px rgba(0,0,0,0.3);
    -moz-transform:
    scale(1.024576)
    rotateY(179.82864282739334deg);
  }

  90% {
    box-shadow: 0px 1.0972799999999998px 1.0972799999999998px rgba(0,0,0,0.3);
    -moz-transform:
    scale(1.000768)
    rotateY(180deg);
  }

  100% {
    box-shadow: 0px 1px 1px rgba(0,0,0,0.3);
    -moz-transform:
    scale(1)
    rotateY(180deg);
  }


}

@-ms-keyframes front {
  0% {
    box-shadow: 0px 1px 1px rgba(0,0,0,0.3);
    -ms-transform:
    scale(1)
    rotateY(0deg);
  }

  10% {
    box-shadow: 0px 1.0972799999999998px 1.0972799999999998px rgba(0,0,0,0.3);
    -ms-transform:
    scale(1.000768)
    rotateY(0deg);
  }

  20% {
    box-shadow: 0px 4.112960000000001px 4.112960000000001px rgba(0,0,0,0.3);
    -ms-transform:
    scale(1.024576)
    rotateY(0deg);
  }

  30% {
    box-shadow: 0px 16.88704px 16.88704px rgba(0,0,0,0.3);
    -ms-transform:
    scale(1.125424)
    rotateY(0.17135717260665195deg);
  }

  40% {
    box-shadow: 0px 19.90272px 19.90272px rgba(0,0,0,0.3);
    -ms-transform:
    scale(1.149232)
    rotateY(5.4834295234128625deg);
  }

  50% {
    box-shadow: 0px 20px 20px rgba(0,0,0,0.3);
    -ms-transform:
    scale(1.15)
    rotateY(41.639792943416424deg);
  }

  60% {
    box-shadow: 0px 19.90272px 19.90272px rgba(0,0,0,0.3);
    -ms-transform:
    scale(1.149232)
    rotateY(138.36020705658356deg);
  }

  70% {
    box-shadow: 0px 16.887040000000006px 16.887040000000006px rgba(0,0,0,0.3);
    -ms-transform:
    scale(1.125424)
    rotateY(174.51657047658713deg);
  }

  80% {
    box-shadow: 0px 4.112959999999997px 4.112959999999997px rgba(0,0,0,0.3);
    -ms-transform:
    scale(1.024576)
    rotateY(179.82864282739334deg);
  }

  90% {
    box-shadow: 0px 1.0972799999999998px 1.0972799999999998px rgba(0,0,0,0.3);
    -ms-transform:
    scale(1.000768)
    rotateY(180deg);
  }

  100% {
    box-shadow: 0px 1px 1px rgba(0,0,0,0.3);
    -ms-transform:
    scale(1)
    rotateY(180deg);
  }


}

@-o-keyframes front {
  0% {
    box-shadow: 0px 1px 1px rgba(0,0,0,0.3);
    -o-transform:
    scale(1)
    rotateY(0deg);
  }

  10% {
    box-shadow: 0px 1.0972799999999998px 1.0972799999999998px rgba(0,0,0,0.3);
    -o-transform:
    scale(1.000768)
    rotateY(0deg);
  }

  20% {
    box-shadow: 0px 4.112960000000001px 4.112960000000001px rgba(0,0,0,0.3);
    -o-transform:
    scale(1.024576)
    rotateY(0deg);
  }

  30% {
    box-shadow: 0px 16.88704px 16.88704px rgba(0,0,0,0.3);
    -o-transform:
    scale(1.125424)
    rotateY(0.17135717260665195deg);
  }

  40% {
    box-shadow: 0px 19.90272px 19.90272px rgba(0,0,0,0.3);
    -o-transform:
    scale(1.149232)
    rotateY(5.4834295234128625deg);
  }

  50% {
    box-shadow: 0px 20px 20px rgba(0,0,0,0.3);
    -o-transform:
    scale(1.15)
    rotateY(41.639792943416424deg);
  }

  60% {
    box-shadow: 0px 19.90272px 19.90272px rgba(0,0,0,0.3);
    -o-transform:
    scale(1.149232)
    rotateY(138.36020705658356deg);
  }

  70% {
    box-shadow: 0px 16.887040000000006px 16.887040000000006px rgba(0,0,0,0.3);
    -o-transform:
    scale(1.125424)
    rotateY(174.51657047658713deg);
  }

  80% {
    box-shadow: 0px 4.112959999999997px 4.112959999999997px rgba(0,0,0,0.3);
    -o-transform:
    scale(1.024576)
    rotateY(179.82864282739334deg);
  }

  90% {
    box-shadow: 0px 1.0972799999999998px 1.0972799999999998px rgba(0,0,0,0.3);
    -o-transform:
    scale(1.000768)
    rotateY(180deg);
  }

  100% {
    box-shadow: 0px 1px 1px rgba(0,0,0,0.3);
    -o-transform:
    scale(1)
    rotateY(180deg);
  }


}

@keyframes front {
  0% {
    box-shadow: 0px 1px 1px rgba(0,0,0,0.3);
    transform:
    scale(1)
    rotateY(0deg);
  }

  10% {
    box-shadow: 0px 1.0972799999999998px 1.0972799999999998px rgba(0,0,0,0.3);
    transform:
    scale(1.000768)
    rotateY(0deg);
  }

  20% {
    box-shadow: 0px 4.112960000000001px 4.112960000000001px rgba(0,0,0,0.3);
    transform:
    scale(1.024576)
    rotateY(0deg);
  }

  30% {
    box-shadow: 0px 16.88704px 16.88704px rgba(0,0,0,0.3);
    transform:
    scale(1.125424)
    rotateY(0.17135717260665195deg);
  }

  40% {
    box-shadow: 0px 19.90272px 19.90272px rgba(0,0,0,0.3);
    transform:
    scale(1.149232)
    rotateY(5.4834295234128625deg);
  }

  50% {
    box-shadow: 0px 20px 20px rgba(0,0,0,0.3);
    transform:
    scale(1.15)
    rotateY(41.639792943416424deg);
  }

  60% {
    box-shadow: 0px 19.90272px 19.90272px rgba(0,0,0,0.3);
    transform:
    scale(1.149232)
    rotateY(138.36020705658356deg);
  }

  70% {
    box-shadow: 0px 16.887040000000006px 16.887040000000006px rgba(0,0,0,0.3);
    transform:
    scale(1.125424)
    rotateY(174.51657047658713deg);
  }

  80% {
    box-shadow: 0px 4.112959999999997px 4.112959999999997px rgba(0,0,0,0.3);
    transform:
    scale(1.024576)
    rotateY(179.82864282739334deg);
  }

  90% {
    box-shadow: 0px 1.0972799999999998px 1.0972799999999998px rgba(0,0,0,0.3);
    transform:
    scale(1.000768)
    rotateY(180deg);
  }

  100% {
    box-shadow: 0px 1px 1px rgba(0,0,0,0.3);
    transform:
    scale(1)
    rotateY(180deg);
  }


}

index.html

<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="description" content="">
  <meta name="viewport" content="width=device-width">

  <title></title>

  <link rel="stylesheet" href="flip-animations-with-shadow.css">
  <style>

    html, body {
      width: 100%;
      height: 100%;
      margin: 0;
      background: #fcfcfc;
      font-family: Helvetica, Arial, sans-serif;
    }

    #container {
      -webkit-perspective: 1000px;
      -moz-perspective: 1000px;
      -ms-perspective: 1000px;
      -o-perspective: 1000px;
      perspective: 1000px;
      width: 100%;
      height: 100%;
    }

    .box,
    .box-back {

      background: url(flip-card-front.jpg) center center no-repeat;
      background-size: 200px 300px;

      width: 200px;
      height: 300px;
      border-radius: 3px;
      position: absolute;
      left: 50%;
      top: 50%;
      margin: -150px 0 0 -100px;

      -webkit-backface-visibility: hidden;
      -moz-backface-visibility: hidden;
      -ms-backface-visibility: hidden;
      -o-backface-visibility: hidden;
      backface-visibility: hidden;

    }

    .box-back {

      background: url(flip-card-back.jpg) center center no-repeat;
      background-size: 200px 300px;

      -webkit-transform: rotateY(180deg);
      -moz-transform: rotateY(180deg);
      -ms-transform: rotateY(180deg);
      -o-transform: rotateY(180deg);
      transform: rotateY(180deg);
    }

    .livedemo {
      width: 100px;
      background: #333;
      color: #FFF !important;
      font-size: 14px;
      padding: 7px 10px;
      border-radius: 4px;
      border: none;
      transition: background 0.3s ease-out;

      position: absolute;
      bottom: 10px;
      left: 50%;
      margin-left: -50px;
    }

    .livedemo:hover {
      background: #50C0FB;
    }

    #container.active .box,
    #container.active .box:after,
    #container.active .box-back:after {
      -webkit-animation: front 650ms 0s 1 linear forwards;
      -moz-animation:    front 650ms 0s 1 linear forwards;
      -o-animation:      front 650ms 0s 1 linear forwards;
      animation:         front 650ms 0s 1 linear forwards;
    }

    #container.active .box-back {

      -webkit-animation: back 650ms 0s 1 linear forwards;
      -moz-animation:    back 650ms 0s 1 linear forwards;
      -o-animation:      back 650ms 0s 1 linear forwards;
      animation:         back 650ms 0s 1 linear forwards;
    }

    #container.active .box:after,
    #container.active .box-back:after {
      -webkit-animation-name: shadow;
      -moz-animation-name:    shadow;
      -o-animation-name:      shadow;
      animation-name:         shadow;
    }

    #container.active .box,
    #container.active .box-back,
    #container.active .box:after,
    #container.active .box-back:after {
      -webkit-animation-play-state: running;
      -moz-animation-play-state:    running;
      -o-animation-play-state:      running;
      animation-play-state:         running;
    }

    #container.reverse .box {

      -webkit-transform: scale(1) rotateY(180deg);
      -moz-transform: scale(1) rotateY(180deg);
      -ms-transform: scale(1) rotateY(180deg);
      -o-transform: scale(1) rotateY(180deg);
      transform: scale(1) rotateY(180deg);

      -webkit-animation-direction: reverse;
      -moz-animation-direction:    reverse;
      -o-animation-direction:      reverse;
      animation-direction:         reverse;
    }

    #container.reverse .box-back {

      -webkit-transform: scale(1) rotateY(360deg);
      -moz-transform: scale(1) rotateY(360deg);
      -ms-transform: scale(1) rotateY(360deg);
      -o-transform: scale(1) rotateY(360deg);
      transform: scale(1) rotateY(360deg);

      -webkit-animation-direction: reverse;
      -moz-animation-direction:    reverse;
      -o-animation-direction:      reverse;
      animation-direction:         reverse;
    }

  </style>
</head>
<body>

  <div id="container">
    <div class="box"></div>
    <div class="box-back"></div>
  </div>

  <button id="animate" class="livedemo">Animate</button>

  <script>

    // shim layer with setTimeout fallback
    // always got hugz for Paul Irish
    window.requestAnimFrame = (function(){
      return  window.requestAnimationFrame       ||
              window.webkitRequestAnimationFrame ||
              window.mozRequestAnimationFrame    ||
              function( callback ){
                window.setTimeout(callback, 1000 / 60);
              };
    })();

    var goButton = document.getElementById("animate");
    var container = document.getElementById("container");
    var animating = false;

    goButton.addEventListener('click', function() {

      if (animating)
        return;

      container.classList.add('active');
      animating = true;

      setTimeout(function() {
        requestAnimFrame(function() {
          animating = false;
          container.classList.remove('active');
          container.classList.toggle('reverse');
        });
      }, 680);
    });
  </script>
</body>
</html>

По мотивам статьи: aerotwist.com/tutorials/protip-nobody-expects-3d

четверг, 13 марта 2014 г.

Вертикальное центрирование текста внутри DIV

A.) Если текст состоит только из одной строки:

HTML:

<div>vertically centered text</div>

CSS:

div {
  height: 20px;
  line-height: 20px; <-- это значение вы должны задать по высотке div
  vertical-align: middle;
}

B.) Если текст состоит только из нескольких строк:

HTML:

<div><span>vertically centered<br />text</span></div>

CSS:

div {
    height: 200px;
    width: 200px;
    line-height: 200px; <-- устанавливаем значение  line-height для центрирования текста по вертикали
    border: 1px solid black;
    text-align:center;
    margin: 10px;
}

span {
    display: inline-block;
    vertical-align: middle;
    line-height: 1em; <-- возвращаем значение line-height для текста к исходному
}

среда, 5 марта 2014 г.

Блок-схема на CSS



<!DOCTYPE html>
<html>
<style>

* {
    margin: 0;
    padding: 0;
}

.tree ul {
    position: relative;
    padding-top: 20px;
}

.tree li {
    position: relative;
    float: left;
    padding: 20px 5px 0 5px;
    list-style-type: none;
    text-align: center;
}

/*We will use ::before and ::after to draw the connectors*/
/*
.tree li::before,
.tree li::after {
    content: '';
    position: absolute;
    width: 50%;
    height: 20px;
    top: 0;
    right: 50%;
    border-top: 1px solid #ccc;
}

.tree li::after {
    left: 50%;
    right: auto;
    border-left: 1px solid #ccc;
}
*/
/*We need to remove left-right connectors from elements without any siblings*/
/*
.tree li:only-child::after,
.tree li:only-child::before {
    display: none;
}
*/
/*Remove space from the top of single children*/
/*
.tree li:only-child {
    padding-top: 0;
}
*/
/*Remove left connector from first child and right connector from last child*/
/*
.tree li:first-child::before,
.tree li:last-child::after {
    border: 0 none;
}
*/
/*Adding back the vertical connector to the last nodes*/
/*
.tree li:last-child::before {
    border-right: 1px solid #ccc;
}
*/
/*Time to add downward connectors from parents*/
/*
.tree ul ul::before {
    content: '';
    position: absolute;
    width: 0;
    height: 20px;
    top: 0;
    left: 50%;
    border-left: 1px solid #ccc;
}
*/
.tree li a {
    display: inline-block;
    padding: 5px 10px;
    border: 1px solid #ccc;
    text-decoration: none;
    color: #666;
    font-family: arial, verdana, tahoma;
    font-size: 11px;
}

/*Time for some hover effects*/
/*We will apply the hover effect the the lineage of the element also*/

.tree li a:hover,
.tree li a:hover+ul li a {
    background: #c8e4f8;
    border: 1px solid #94a0b4;
    color: #000;
}

/*Connector styles on hover*/
/*
.tree li a:hover+ul li::after,
.tree li a:hover+ul li::before,
.tree li a:hover+ul::before,
.tree li a:hover+ul ul::before {
    border-color:  #94a0b4;
}
*/
</style>
<head><title>Tree</title></head>
<body>


<div class="tree" style="width: 800px; height: 500px;  overflow: hidden; border: 1px solid black;">
 <ul>
  <li>
   <a href="#">Parent</a><div style="width: 1px; height: 20px; position: absolute; background-color: black; left: 50%;"></div><div style="height: 1px; position: absolute; background-color: black; left: 8.3%; right: 42.5%; top: 66px;"></div>
   <ul>
    <li><div style="width: 1px; height: 20px; position: absolute; background-color: black; left: 50%; top: 0;"></div>
     <a href="#">Child</a><div style="width: 1px; height: 20px; position: absolute; background-color: black; left: 50%;"></div>
     <ul>
      <li>
       <a href="#">Grand Child</a>
      </li><div style="width: 1px; height: 20px; position: absolute; background-color: black; left: 50%;"></div>
     </ul>
    </li>
    <li><div style="width: 1px; height: 20px; position: absolute; background-color: black; left: 50%; top: 0;"></div>
     <a href="#">Child</a><div style="width: 1px; height: 20px; position: absolute; background-color: black; left: 50%;"></div><div style="height: 1px; position: absolute; background-color: black; left: 9%; right: 8.9%; top: 66px;"></div>
     <ul>
      <li><div style="width: 1px; height: 20px; position: absolute; background-color: black; left: 50%; top: 0;"></div><a href="#">Grand Child</a></li><div style="width: 1px; height: 20px; position: absolute; background-color: black; left: 50%;"></div>
      <li>
       <a href="#">Grand Child</a><div style="width: 1px; height: 20px; position: absolute; background-color: black; left: 50%;"></div><div style="height: 1px; position: absolute; background-color: black; left: 16%; right: 16%; top: 66px;"></div>
       <ul>
        <li>
         <a href="#">Great Grand Child</a>
        </li><div style="width: 1px; height: 20px; position: absolute; background-color: black; left: 15%;"></div>
        <li>
         <a href="#">Great Grand Child</a>
        </li><div style="width: 1px; height: 20px; position: absolute; background-color: black; left: 50%;"></div>
        <li>
         <a href="#">Great Grand Child</a>
        </li><div style="width: 1px; height: 20px; position: absolute; background-color: black; left: 85%;"></div>
       </ul>
      </li>
      <li><div style="width: 1px; height: 20px; position: absolute; background-color: black; left: 50%; top: 0;"></div><a href="#">Grand Child</a></li>
     </ul>
    </li>
   </ul>
  </li>
 </ul>
</div>


</body>

вторник, 4 марта 2014 г.

Дерево на CSS 3



Файл index.html

<h2>Achievement Tree</h2>
<ul class="tree"><li>Taking Inventory
    <ul><li>Getting Wood
        <ul><li>Benchmarking
            <ul>
                <li>Time to Farm!
                    <ul>
                        <li>Bake Bread</li>
                        <li>The Lie</li>
                    </ul>
                </li>
                <li>Time to Strike!
                    <ul>
                        <li>Monster Hunter</li>
                        <li>Cow Tipper
                            <ul><li>When Pigs Fly</li></ul>
                        </li>
                    </ul>
                </li>
                <li>Time to Mine!
                    <ul>
                        <li>Getting an Upgrade</li>
                        <li>Hot Topic
                            <ul>
                                <li>Delicious Fish</li>
                                <li>Acquire Hardware
                                    <ul><li>On a Rail</li></ul>
                                </li>
                            </ul>
                        </li>
                    </ul>
                </li>
            </ul>
        </li></ul>
    </li></ul>
</li></ul>
<ul>
    <li>Doesn’t affect lists outside</li>
    <li>like this one</li>
</ul>

Файл index.css

ul.tree    {padding-left: 0}
ul.tree ul {padding-left:1em}
ul.tree li {list-style-type:none}

/* specify line style */
ul.tree li:not(:last-child),
ul.tree li::before {border: 0 solid black}

/* vertical line connecting siblings */
ul.tree li:not(:last-child) {border-left-width: 1px}
/* horizontal line connecting children to the stem */
ul.tree li::before {
    content: "";
    display: inline-block;
    position: relative;
    border-bottom-width: 1px;
    bottom: .3em; /*elevation*/
    min-width: 1ex; /*length*/
    margin-right: 2px;
}
/* vertical line connecting the last sibling
   to the sibling-connecting line */
ul.tree li:last-child::before {
    border-left-width: 1px;
    min-height: .7em; /*line-height - elevation of the horizontal line*/
}

воскресенье, 16 февраля 2014 г.

Современное использование Conditional Comments и CSS в Internet Explorer

<!DOCTYPE html>
<!--[if lt IE 7 ]> <html class="ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]>    <html class="ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]>    <html class="ie8" lang="en"> <![endif]-->
<!--[if IE 9 ]>    <html class="ie9" lang="en"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en"> <!--<![endif]-->

воскресенье, 2 февраля 2014 г.

New Reset CSS - Normalize CSS

/*! normalize.css v3.0.0 | MIT License | git.io/normalize */

/**
 * 1. Set default font family to sans-serif.
 * 2. Prevent iOS text size adjust after orientation change, without disabling
 *    user zoom.
 */

html {
  font-family: sans-serif; /* 1 */
  -ms-text-size-adjust: 100%; /* 2 */
  -webkit-text-size-adjust: 100%; /* 2 */
}

/**
 * Remove default margin.
 */

body {
  margin: 0;
}

/* HTML5 display definitions
   ========================================================================== */

/**
 * Correct `block` display not defined in IE 8/9.
 */

article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
main,
nav,
section,
summary {
  display: block;
}

/**
 * 1. Correct `inline-block` display not defined in IE 8/9.
 * 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera.
 */

audio,
canvas,
progress,
video {
  display: inline-block; /* 1 */
  vertical-align: baseline; /* 2 */
}

/**
 * Prevent modern browsers from displaying `audio` without controls.
 * Remove excess height in iOS 5 devices.
 */

audio:not([controls]) {
  display: none;
  height: 0;
}

/**
 * Address `[hidden]` styling not present in IE 8/9.
 * Hide the `template` element in IE, Safari, and Firefox < 22.
 */

[hidden],
template {
  display: none;
}

/* Links
   ========================================================================== */

/**
 * Remove the gray background color from active links in IE 10.
 */

a {
  background: transparent;
}

/**
 * Improve readability when focused and also mouse hovered in all browsers.
 */

a:active,
a:hover {
  outline: 0;
}

/* Text-level semantics
   ========================================================================== */

/**
 * Address styling not present in IE 8/9, Safari 5, and Chrome.
 */

abbr[title] {
  border-bottom: 1px dotted;
}

/**
 * Address style set to `bolder` in Firefox 4+, Safari 5, and Chrome.
 */

b,
strong {
  font-weight: bold;
}

/**
 * Address styling not present in Safari 5 and Chrome.
 */

dfn {
  font-style: italic;
}

/**
 * Address variable `h1` font-size and margin within `section` and `article`
 * contexts in Firefox 4+, Safari 5, and Chrome.
 */

h1 {
  font-size: 2em;
  margin: 0.67em 0;
}

/**
 * Address styling not present in IE 8/9.
 */

mark {
  background: #ff0;
  color: #000;
}

/**
 * Address inconsistent and variable font size in all browsers.
 */

small {
  font-size: 80%;
}

/**
 * Prevent `sub` and `sup` affecting `line-height` in all browsers.
 */

sub,
sup {
  font-size: 75%;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}

sup {
  top: -0.5em;
}

sub {
  bottom: -0.25em;
}

/* Embedded content
   ========================================================================== */

/**
 * Remove border when inside `a` element in IE 8/9.
 */

img {
  border: 0;
}

/**
 * Correct overflow displayed oddly in IE 9.
 */

svg:not(:root) {
  overflow: hidden;
}

/* Grouping content
   ========================================================================== */

/**
 * Address margin not present in IE 8/9 and Safari 5.
 */

figure {
  margin: 1em 40px;
}

/**
 * Address differences between Firefox and other browsers.
 */

hr {
  -moz-box-sizing: content-box;
  box-sizing: content-box;
  height: 0;
}

/**
 * Contain overflow in all browsers.
 */

pre {
  overflow: auto;
}

/**
 * Address odd `em`-unit font size rendering in all browsers.
 */

code,
kbd,
pre,
samp {
  font-family: monospace, monospace;
  font-size: 1em;
}

/* Forms
   ========================================================================== */

/**
 * Known limitation: by default, Chrome and Safari on OS X allow very limited
 * styling of `select`, unless a `border` property is set.
 */

/**
 * 1. Correct color not being inherited.
 *    Known issue: affects color of disabled elements.
 * 2. Correct font properties not being inherited.
 * 3. Address margins set differently in Firefox 4+, Safari 5, and Chrome.
 */

button,
input,
optgroup,
select,
textarea {
  color: inherit; /* 1 */
  font: inherit; /* 2 */
  margin: 0; /* 3 */
}

/**
 * Address `overflow` set to `hidden` in IE 8/9/10.
 */

button {
  overflow: visible;
}

/**
 * Address inconsistent `text-transform` inheritance for `button` and `select`.
 * All other form control elements do not inherit `text-transform` values.
 * Correct `button` style inheritance in Firefox, IE 8+, and Opera
 * Correct `select` style inheritance in Firefox.
 */

button,
select {
  text-transform: none;
}

/**
 * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`
 *    and `video` controls.
 * 2. Correct inability to style clickable `input` types in iOS.
 * 3. Improve usability and consistency of cursor style between image-type
 *    `input` and others.
 */

button,
html input[type="button"], /* 1 */
input[type="reset"],
input[type="submit"] {
  -webkit-appearance: button; /* 2 */
  cursor: pointer; /* 3 */
}

/**
 * Re-set default cursor for disabled elements.
 */

button[disabled],
html input[disabled] {
  cursor: default;
}

/**
 * Remove inner padding and border in Firefox 4+.
 */

button::-moz-focus-inner,
input::-moz-focus-inner {
  border: 0;
  padding: 0;
}

/**
 * Address Firefox 4+ setting `line-height` on `input` using `!important` in
 * the UA stylesheet.
 */

input {
  line-height: normal;
}

/**
 * It's recommended that you don't attempt to style these elements.
 * Firefox's implementation doesn't respect box-sizing, padding, or width.
 *
 * 1. Address box sizing set to `content-box` in IE 8/9/10.
 * 2. Remove excess padding in IE 8/9/10.
 */

input[type="checkbox"],
input[type="radio"] {
  box-sizing: border-box; /* 1 */
  padding: 0; /* 2 */
}

/**
 * Fix the cursor style for Chrome's increment/decrement buttons. For certain
 * `font-size` values of the `input`, it causes the cursor style of the
 * decrement button to change from `default` to `text`.
 */

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  height: auto;
}

/**
 * 1. Address `appearance` set to `searchfield` in Safari 5 and Chrome.
 * 2. Address `box-sizing` set to `border-box` in Safari 5 and Chrome
 *    (include `-moz` to future-proof).
 */

input[type="search"] {
  -webkit-appearance: textfield; /* 1 */
  -moz-box-sizing: content-box;
  -webkit-box-sizing: content-box; /* 2 */
  box-sizing: content-box;
}

/**
 * Remove inner padding and search cancel button in Safari and Chrome on OS X.
 * Safari (but not Chrome) clips the cancel button when the search input has
 * padding (and `textfield` appearance).
 */

input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
}

/**
 * Define consistent border, margin, and padding.
 */

fieldset {
  border: 1px solid #c0c0c0;
  margin: 0 2px;
  padding: 0.35em 0.625em 0.75em;
}

/**
 * 1. Correct `color` not being inherited in IE 8/9.
 * 2. Remove padding so people aren't caught out if they zero out fieldsets.
 */

legend {
  border: 0; /* 1 */
  padding: 0; /* 2 */
}

/**
 * Remove default vertical scrollbar in IE 8/9.
 */

textarea {
  overflow: auto;
}

/**
 * Don't inherit the `font-weight` (applied by a rule above).
 * NOTE: the default cannot safely be changed in Chrome and Safari on OS X.
 */

optgroup {
  font-weight: bold;
}

/* Tables
   ========================================================================== */

/**
 * Remove most spacing between table cells.
 */

table {
  border-collapse: collapse;
  border-spacing: 0;
}

td,
th {
  padding: 0;
}

вторник, 26 ноября 2013 г.

Создание дерева графов на CSS 3



Файл index.html

<div class="tree">
<ul>
<li>
<a href="#">Parent</a>
<ul>
<li>
<a href="#">Child</a>
<ul>
<li>
<a href="#">Grand Child</a>
</li>
</ul>
</li>
<li>
<a href="#">Child</a>
<ul>
<li><a href="#">Grand Child</a></li>
<li>
<a href="#">Grand Child</a>
<ul>
<li>
<a href="#">Great Grand Child</a>
</li>
<li>
<a href="#">Great Grand Child</a>
</li>
<li>
<a href="#">Great Grand Child</a>
</li>
</ul>
</li>
<li><a href="#">Grand Child</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>

Файл index.css

* {margin: 0; padding: 0;}

.tree ul {
padding-top: 20px; position: relative;

transition: all 0.5s;
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
}

.tree li {
float: left; text-align: center;
list-style-type: none;
position: relative;
padding: 20px 5px 0 5px;

transition: all 0.5s;
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
}

/*We will use ::before and ::after to draw the connectors*/

.tree li::before, .tree li::after{
content: '';
position: absolute; top: 0; right: 50%;
border-top: 1px solid #ccc;
width: 50%; height: 20px;
}

.tree li::after{
right: auto; left: 50%;
border-left: 1px solid #ccc;
}

/*We need to remove left-right connectors from elements without
any siblings*/
.tree li:only-child::after, .tree li:only-child::before {
display: none;
}

/*Remove space from the top of single children*/
.tree li:only-child{ padding-top: 0;}

/*Remove left connector from first child and
right connector from last child*/
.tree li:first-child::before, .tree li:last-child::after{
border: 0 none;
}

/*Adding back the vertical connector to the last nodes*/
.tree li:last-child::before{
border-right: 1px solid #ccc;
border-radius: 0 5px 0 0;
-webkit-border-radius: 0 5px 0 0;
-moz-border-radius: 0 5px 0 0;
}

.tree li:first-child::after{
border-radius: 5px 0 0 0;
-webkit-border-radius: 5px 0 0 0;
-moz-border-radius: 5px 0 0 0;
}

/*Time to add downward connectors from parents*/
.tree ul ul::before{
content: '';
position: absolute; top: 0; left: 50%;
border-left: 1px solid #ccc;
width: 0; height: 20px;
}

.tree li a{
border: 1px solid #ccc;
padding: 5px 10px;
text-decoration: none;
color: #666;
font-family: arial, verdana, tahoma;
font-size: 11px;
display: inline-block;

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

transition: all 0.5s;
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
}

/*Time for some hover effects*/
/*We will apply the hover effect the the lineage of the element also*/
.tree li a:hover, .tree li a:hover+ul li a {
background: #c8e4f8; color: #000; border: 1px solid #94a0b4;
}

/*Connector styles on hover*/
.tree li a:hover+ul li::after,
.tree li a:hover+ul li::before,
.tree li a:hover+ul::before,
.tree li a:hover+ul ul::before{
border-color:  #94a0b4;
}