angularjs指令中的flipcard,范围有限

时间:2014-09-01 06:32:48

标签: css angularjs angularjs-directive angularjs-scope

我有这个带CSS的HTML代码。我想把它放在一个指令模板中并重用指令,将范围限制在每​​个元素中。

<div ng-controller="flipCtrl">
      <div class="flip"> <div class="card" ng-class="{'flipped':isFlipped}" ng-click="isFlipped=!isFlipped"> 
          <div class="face front">Project</div> 
            <div class="face back">TechLead</div> 
          </div>
      </div>
</div>      

当我将html中的整个文本复制到指令模板中时,我无法使其工作。

这个想法是每个翻转卡在点击它时都会翻转。

CSS

<style>
body {
 background: #ccc;   
}
.flip {
  -webkit-perspective: 800;
   width: 400px;
   height: 200px;
   position: relative;
   margin: 50px auto;
}
.flip .card.flipped {
  -webkit-transform: rotatex(-180deg);
}
.flip .card {
  width: 100%;
  height: 100%;
  -webkit-transform-style: preserve-3d;
  -webkit-transition: 0.5s;
}
.flip .card .face {
  width: 100%;
  height: 100%;
  position: absolute;
  -webkit-backface-visibility: hidden ;
  z-index: 2;
  font-family: Georgia;
  font-size: 3em;
  text-align: center;
  line-height: 200px;
}
.flip .card .front {
  position: absolute;
  z-index: 1;
  background: black;
  color: white;
  cursor: pointer;
}
.flip .card .back {
  -webkit-transform: rotatex(-180deg);
    background: blue;
    background: white;
    color: black;
    cursor: pointer;
}
</style>

0 个答案:

没有答案