vue实现扑克牌小游戏试试你的眼力如何

代码语言:html

所属分类:游戏

代码描述:vue实现扑克牌小游戏试试你的眼力如何,经过洗牌后,找出我们想要的牌

代码标签: 小游戏 试试 你的 眼力 如何

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开


<!DOCTYPE html>
<html lang="en" >

<head>

  <meta charset="UTF-8">
  

  
  
  
<style>
html, body {
  background-color: #102438;
  color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
}

.cards {
  width: 100%;
  height: 40vh;
}
.cards .card {
  width: 15vw;
  height: 21vw;
  background-color: #fff;
  position: absolute;
  top: 35%;
  left: calc(30% - 7.5vw);
  transform: rotateY(0deg);
  transform-style: preserve-3d;
  border-radius: 5px;
  transition: transform 1s, left 0.5s, top 0.5s;
  box-shadow: 0px 10px 30px rgba(0, 0, 0, 0.2);
}
.cards .card .face {
  backface-visibility: hidden;
  background-color: #fff;
  color: #000;
  width: 100%;
  height: 100%;
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 5px;
}
.cards .card .face.front {
  background-color: #fff;
  transform: rotateY(180deg);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 60px;
}
.cards .card .face.back {
  padding: 10px;
  box-sizing: border-box;
}
.cards .card .face.back:before {
  box-sizing: border-box;
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  background-color: #ddd;
  border: 3px solid #ed4747;
  background-image: linear-gradient(-60deg, transparent 40%, #ed4747 40%, #ed4747 60%, transparent 60%), linear-gradient(60deg, transparent 40%, #ed4747 40%, #ed4747 60%, transparent 60%);
  background-size: 8px 8px;
}
.cards .card.open {
  transform: rotate(0deg) rotateY(180deg);
}
.cards .card[data-order="1"] {
  left: calc(20% - 7.5vw);
}
.cards .card[data-order="2"] {
  left: calc(40% - 7.5vw);
}
.cards .card[data-order="3"] {
  left: calc(60% - 7.5vw);
}
.cards .card[data-order="4"] {
  left: calc(80% - 7.5vw);
}
.cards .card:hover {
  top: 30%;
}
.cards.gather {
  cursor: pointer;
}
.cards.gather .card {
  top: 20%;
  left: calc(50% - 7.5vw);
  transform: rotate(360deg);
}
.cards.gather:hover .card[data-order="1"] {
  transform: rotate(355deg);
}
.cards.gather:hover .card[data-order="2"] {
  transform: rotate(360deg);
}
.cards.gather:hover .card[data-order="3"] {
  transform: rotate(365deg);
}
.cards.gather:hover .card[data-order="4"] {
  transform: rotate(370deg);
}
</style>




</head>

<body>
  <div id="app">
  <div class="control">
    <input type="checkbox" v-model="gather"/>
    <input type="checkbox" v-for="card in cards" v-model="card.open"/>
    <button @click="shuffle">Shuffle</button>
    <h1>{{state}}</h1>
  </div>
  <div class="cards" :class="{gather: gather}">
    <div class="card" v-for="card in cards" :class="{open: card.open}" :data-order="card.id" @click="openCard(card)">
      <div class="face back"> </div>
      <div class="face front">{{ getSymbol(card.label) }}</div>
    </div>
  </div>
</div>
.........完整代码请登录后点击上方下载按钮下载查看

网友评论0