want to show the thickness of an element while it rotate

Viewed 10236

I am rotating a coin along Y axis by 90deg through CSS. Is there a way so that I can show the thickness of the coin after it have rotated, I thought I can scaleY after the coin have rotated along Y axis but this doesn't seem to work. Please suggest some way to do the same if it is possible. link_on_js fiddle for the same. Please use webkit browsers to open the link.

css

.coin {
    display: block;
    background: url("url-to-image-of-coin.jpg");
    background-size: 100% 100%;
    width: 100px;
    height: 100px;
    margin: auto;
    border-radius: 100%;
    transition: all 500ms linear;
}

.flip {
    transform: rotateY(180deg);
}

html

<div class="coin"></div>

jquery

$('.coin').click(function() {
    $(this).toggleClass('flip');
});

fiddle

http://jsfiddle.net/7EtLu/22/

2 Answers

@joshnh Thanks for the inspiration provided, here is a little modification to make it look more like:

  <div class="flip-card">
    <div class="flip-card-inner">
      <div class="flip-card-front"></div>
      <div class="flip-card-thick"></div>
      <div class="flip-card-back"></div>
    </div>
  </div>
.flip-card {
  background-color: transparent;
  width: 300px;
  height: 300px;
  perspective: 1000px;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  background: transparent url(https://i.imgur.com/GPCt3mC.jpg) no-repeat;
  background-size: 100% 100%;
  border-radius: 100%;
  transition: transform 4s;
  transform-style: preserve-3d;
}


.flip-card-front, .flip-card-back, .flip-card-inner:before, .flip-card-inner:after  {
  background-color: #a37131;
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 100%;
  overflow: hidden;
  z-index: 1;
}

.flip-card-inner:before {
  content: '';
  top: 0;
  left: 0;
  transform: rotateY(180deg) translateZ(1px);
  background-image: -webkit-linear-gradient(hsla(0,0%,100%,.25), hsla(0,0%,0%,.25));
}

.flip-card-inner:after {
  content: '';
  top: 0;
  left: 0;
  transform: rotateY(180deg) translateZ(10px);
  background-image: -webkit-linear-gradient(hsla(0,0%,100%,.25), hsla(0,0%,0%,.25));
}

.flip-card-front {
  background-color: #bbb;
  color: black;
}

.flip-card-back {
  background-color: #a37131;
  color: white;
  transform: rotateY(180deg) translateZ(11px);
}

.flip-card-thick {
  background-color: #a37131;
  background-image: -webkit-linear-gradient(hsla(0,0%,100%,.25), hsla(0,0%,0%,.25));
  bottom: 0;
  left: 130px;
  position: absolute;
  top: 0px;
  width: 10px;
  z-index: -10;
  transform: rotateY(-90deg);
  transform-origin: 100% 50%;
}

.flip-card:hover .flip-card-inner {
  transform: rotateY(180deg);
}

codepen

Related