js实现纸牌类扑克游戏单人纸牌游戏

代码语言:html

所属分类:游戏

代码描述:js实现纸牌类扑克游戏单人纸牌游戏

代码标签: 牌类 扑克 游戏 单人 纸牌游戏

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


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

<head>

  <meta charset="UTF-8">
  

  
<style>


html, body {
   width: 100%;
   height: 100%;
}
body {
   position: relative;
   color: #f3f5f7;
   background: #0e8b44 ;
   background-size: cover;
   background-position: center;
}
.navbar {
   background: rgba(8,8,8,.75);
}
.navbar a {
   color: #fff;
}
.navbar li[data-active="false"] {
   opacity: 0.5;
   pointer-events: none;
}
.navbar li[data-active="true"] {
   opacity: 1;
   pointer-events: auto;
}
.template {
   display: none;
}
#score {
   position: relative;
   background: rgba(0,0,0,.15);
   margin-top: 1.5em;
   margin-bottom: 0.5em;
   padding: 1em;
   line-height: 1;
}
#score > * {
   display: inline-block;
   min-width: 100px;
}
#score > *:last-child {
   float: right;
   text-align: right;
}
#score label {
   margin-bottom: 0;
}
#score .timer button {
   display: none;
   position: absolute;
   -webkit-appearance: none;
   background: transparent;
   outline: none;
   border: 0;
   padding: 0;
   top: 0;
   left: 0;
   width: 3em;
   height: 100%;
}
#score .timer button i {
   position: absolute;
   top: 0;
   left: 0;
   width: 100%;
   height: 100%;
   font-size: 0;
}
#score .timer button i::before {
   position: absolute;
   top: 50%;
   left: 50%;
   width: 0.75em;
   height: 1em;
   margin-left: -0.375em;
   margin-top: -0.5em;
   font-size: 1.5rem;
   content: none;
}
#score .timer button i#play::before {
   border-top: 8px solid transparent;
   border-left: 12px solid #fff;
   border-bottom: 8px solid transparent;
}
#score .timer button i#pause::before {
   border-right: 4px solid #fff;
   border-left: 4px solid #fff;
}
[data-gameplay="active"] #score .timer button,
[data-gameplay="paused"] #score .timer button {
   display: inline-block;
}
[data-gameplay="active"] #score .timer button i#pause::before,
[data-gameplay="paused"] #score .timer button i#play::before {
   content: '';
}
[data-gameplay="active"] #score,
[data-gameplay="paused"] #score {
   padding-left: 3em;
}
#auto-win {
   display: none;
   -webkit-appearance: none;
   outline: none;
   border: 0;
   position: absolute;
   z-index: 1;
   bottom: 0;
   width: 100%;
   background: rgba(0,0,0,.8);
   padding: 1em;
   line-height: 1;
}
#table {
   opacity: 0;
   width: 100%;
   padding: 15px 0;
}
#table > div {
   position: relative;
   margin-bottom: 10px;
}
#table > div:last-child {
   margin-bottom: 0;
}
#table > div::after {
   content: '';
   display: table-cell;
   clear: both;
}
#table ul {
   display: inline-block;
   padding: 0;
}
#table > div > ul {
   position: absolute;
   top: 0;
   left: 0;
   width: 100%;
   height: 100%;
}
.pile {
   display: block;
   position: relative;
   float: left;
   width: 13%;
   margin-right: 1.5%;
   margin-bottom: 10px;
   padding: 5px;
}
.pile:last-child {
   margin-right: 0;
}
.pile::after {
   content: '';
   position: absolute;
   top: 0;
   left: 0;
   width: 100%;
   height: 100%;
   border: 2px dotted rgba(0,0,0,.25);
   border-radius: 5px;
}
.card {
   display: block;
   position: absolute;
   top: 0;
   left: 0;
   background-color: #ddd;
   background-image: url('//repo.bfw.wiki/bfwrepo/image/5fc2de23d0663.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_100,h_152,/quality,q_90');
   background-size: contain;
   background-repeat: no-repeat;
   width: 100%;
   height: 100%;
   font-family: 'Suit-Regular', sans-serif;
   font-size: 0.6vw;
   border-radius: 5px;
   z-index: -1;
}
.card * {
   pointer-events: none;
}
@media screen and (min-width: 768px) {
   .card {
      font-size: 0.325em;
   }
   .pile::after, .card {
      border-radius: 10px;
   }
}
@media screen and (min-width: 992px) {
   .card {
      font-size: 0.425em;
   }
}
@media screen and (min-width: 1200px) {
   .card {
      font-size: 0.525em;
   }
}
.card > div {
   display: none;
}
.card.up {
   background-image: url('https://bfa.github.io/solitaire-js/img/card_face_bg.png');
   background-repeat: repeat;
   color: #111;
}
.card.up > div {
   display: block;
}
.card::before {
   content: '';
   display: block;
   position: absolute;
   width: 100%;
   height: 100%;
   border-radius: 5px;
}
.card[data-selected="true"]::before {
   box-shadow: 0 0 6px 3px #FCDB1A;
}
@media screen and (min-width: 768px) {
   .card::before {
      border-radius: 10px;
   }
}
.card .suit {
   font-size: 5.8em;
   font-weight: normal;
   width: 0.6896551724137931em;
   height: 0.786206896551724em;
   line-height: 0.786206896551724em;
   position: absolute;
   text-align: center;
}
@media screen and (max-width: 767px) {
   .card > div > .suit {
      display: none;
   }
}
.card .heart,
.card .diamond {
   color: #cc0000;
}
.card .spade .suit::before { content: '♠' }
.card .heart .suit::before { content: '♥' }
.card .diamond .suit::before { content: '♦' }
.card .club .suit::before { content: '♣' }
.card .corner {
   line-height: 1;
   position: absolute;
   text-align: center;
}
.card .corner span {
   display: block;
   font-size: 9em;
   font-weight: bold;
   width: 1em;
   text-align: center;
}
@media screen and (min-width: 768px) {
   .card .corner span {
      font-size: 3em;
   }
}
.card .corner .suit {
   margin-top: 0;
   margin-left: 0;
}
.card .corner.top {
   left: 0.64em;
   top: 0.96em;
}
.card .corner.bottom {
   bottom: 0.96em;
   right: 0.64em;
   -ms-transform: rotate(180deg);
   -moz-transform: rotate(180deg);
   -webkit-transform: rotate(180deg);
   transform: rotate(180deg);
}
.card .ace span.suit.middle_center {
   font-size: 10.24em;
   left: 50%;
   top: 50%;
   margin-top: -0.5em;
   margin-left: -0.35em;
}
.card .face::before {
   display: none;
   content: '';
   position: absolute;
   top: 15.25%;
   left: 19%;
   width: 62%;
   height: 70.5%;
   background-repeat: no-repeat;
   background-size: contain;
}
@media screen and (min-width: 768px) {
   .card .face::before {
      display: block;
   }
}
.card .spade.king .face::before {
   background-image: url('//repo.bfw.wiki/bfwrepo/image/5fc2def379aa4.png');
}
.card .spade.queen .face::before {
   background-image: url('//repo.bfw.wiki/bfwrepo/image/5fc2df11c30f8.png');
}
.card .spade.jack .face::before {
   background-image: url('//repo.bfw.wiki/bfwrepo/image/5fc2df4ebe496.png');
}
.card .heart.king .face::before {
   background-image: url('//repo.bfw.wiki/bfwrepo/image/5fc2df6abac76.png');
}
.card .heart.queen .face::before {
   background-image: url('//repo.bfw.wiki/bfwrepo/image/5fc2df9764cc4.png');
}
.card .heart.jack .face::before {
   background-image: url('//repo.bfw.wiki/bfwrepo/image/5fc2e17329e20.png');
}
.card .diamond.king .face::before {
   background-image: url('//repo.bfw.wiki/bfwrepo/image/5fc2dfb9bd3eb.png');
}
.card .diamond.queen .face::before {
   background-image: url('//repo.bfw.wiki/bfwrepo/image/5fc2dfd6e8186.png');
}
.card .diamond.jack .face::before {
   background-image: url('//repo.bfw.wiki/bfwrepo/image/5fc2e011a2856.png');
}
.card .club.king .face::before {
   background-image: url('//repo.bfw.wiki/bfwrepo/image/5fc2e20f848c9.png');
}
.card .club.queen .face::before {
   background-image: url('//repo.bfw.wiki/bfwrepo/image/5fc2e05a11684.png');
}
.card .club.jack .face::before {
   background-image: url('//repo.bfw.wiki/bfwrepo/image/5fc2e07617fb3.png');
}
.card .suit.top_center {
   left: 50%;
   top: 0;
   margin-left: -0.35em;
   margin-top: 0.65em;
}
.card .suit.top_left {
   left: 0;
   top: 0;
   margin-left: 0.65em;
   margin-top: 0.65em;
}
.card .suit.top_right {
   right: 0;
   .........完整代码请登录后点击上方下载按钮下载查看

网友评论0