Bootstrap 4 с вращающимися карточками - PullRequest
0 голосов
/ 04 июня 2018

Я создаю свою собственную карту с помощью Bootstrap v4 (только со строками и столбцами).Проблема в том, когда я пытаюсь положить две стороны карты друг на друга.Я использую position: absolute; Они исчезают полностью

.thecard {
  perspective: 150rem;
  -moz-perspective: 150rem;
  position: relative;
}

.thecard__side {
  background-color: orangered;
  color: #fff;
  font-size: 2rem;
  height: 50rem;
  transition: all .8s;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  backface-visibility: hidden;
}

.thecard__side--front {
  background-color: orangered;
}

.thecard__side--back {
  background-color: green;
  -webkit-transform: rotateY(180deg);
  transform: rotateY(180deg);
}

.thecard:hover .thecard__side--front {
  -webkit-transform: rotateY(180deg);
  transform: rotateY(180deg);
}

.thecard:hover .thecard__side--back {
  -webkit-transform: rotateY(0);
  transform: rotateY(0);
}
<div class="row mt-5">
  <div class="mt-5 mt-lg-0 col-md-6 col-lg-4">
    <div class="thecard">
      <div class="thecard__side thecard__side--front">
        Front
      </div>
      <div class="thecard__side thecard__side--back">
        Back
      </div>
    </div>
  </div>
  <div class="mt-5 mt-lg-0 col-md-6 col-lg-4">
    <div class="thecard">
      <div class="thecard__side thecard__side--front">
        Front
      </div>
      <div class="thecard__side thecard__side--back">
        Back
      </div>
    </div>
  </div>
  <div class=" offset-md-3 mt-5 mt-lg-0 offset-lg-0 col-md-6 col-lg-4">
    <div class="thecard">
      <div class="thecard__side thecard__side--front">
        Front
      </div>
      <div class="thecard__side thecard__side--back">
        Back
      </div>
    </div>
  </div>
</div>

Любое решение, ребята?

Ответы [ 2 ]

0 голосов
/ 04 июня 2018

Вы можете попробовать этот код

.thecard {
  perspective: 150rem;
  -moz-perspective: 150rem;
  position: relative;
  height: 350px;
}

.thecard__side {
  background-color: orangered;
  color: #fff;
  font-size: 2rem;
  height: 50rem;
  transition: all .8s;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  backface-visibility: hidden;
}

.thecard__side--front {
  background-color: orangered;
}

.thecard__side--back {
  background-color: green;
  -webkit-transform: rotateY(180deg);
  transform: rotateY(180deg);
}

.thecard:hover .thecard__side--front {
  -webkit-transform: rotateY(180deg);
  transform: rotateY(180deg);
}

.thecard:hover .thecard__side--back {
  -webkit-transform: rotateY(0);
  transform: rotateY(0);
}
<div class="row mt-5">
  <div class="mt-5 mt-lg-0 col-md-6 col-lg-4">
    <div class="thecard">
      <div class="thecard__side thecard__side--front">
        Front
      </div>
      <div class="thecard__side thecard__side--back">
        Back
      </div>
    </div>
  </div>
  <div class="mt-5 mt-lg-0 col-md-6 col-lg-4">
    <div class="thecard">
      <div class="thecard__side thecard__side--front">
        Front
      </div>
      <div class="thecard__side thecard__side--back">
        Back
      </div>
    </div>
  </div>
  <div class=" offset-md-3 mt-5 mt-lg-0 offset-lg-0 col-md-6 col-lg-4">
    <div class="thecard">
      <div class="thecard__side thecard__side--front">
        Front
      </div>
      <div class="thecard__side thecard__side--back">
        Back
      </div>
    </div>
  </div>
</div>
0 голосов
/ 04 июня 2018

После многократного тестирования одна и та же высота в обоих классах исправила проблему для меня:

 .thecard {
      perspective: 150rem;
      -moz-perspective: 150rem;
      position: relative;
      height: 50rem; 
    }

    .thecard__side {
      background-color: orangered;
      color: #fff;
      font-size: 2rem;
      height: 50rem;
      transition: all .8s;
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      backface-visibility: hidden;
    }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...