Nik Nik - 3 months ago 6
CSS Question

Flipping animation is not working

Im trying to create a flipping animation. However when I hover over the element, the backside does not appear, and the frontside which should disappear remains visible and is just a reflected version of itself. Heres what it looks like when it is flipped.
Here is the jsfiddle https://jsfiddle.net/gepp007p/

thad

Here is the part of the HTML with the flippable element

<div class="main-panel">
<div class="front">
<h3>Please rate the overall experience of your visit</h3>
<fieldset class="rating">
<input type="radio" id="star5" name="rating" value="5" /><label class = "full" for="star5" title="Awesome - 5 stars"></label>
<input type="radio" id="star4half" name="rating" value="4.5" /><label class="half" for="star4half" title="Pretty good - 4.5 stars"></label>
<input type="radio" id="star4" name="rating" value="4" /><label class = "full" for="star4" title="Pretty good - 4 stars"></label>
<input type="radio" id="star3half" name="rating" value="3.5" /><label class="half" for="star3half" title="Meh - 3.5 stars"></label>
<input type="radio" id="star3" name="rating" value="3" /><label class = "full" for="star3" title="Meh - 3 stars"></label>
<input type="radio" id="star2half" name="rating" value="2.5" /><label class="half" for="star2half" title="Kinda bad - 2.5 stars"></label>
<input type="radio" id="star2" name="rating" value="2" /><label class = "full" for="star2" title="Kinda bad - 2 stars"></label>
<input type="radio" id="star1half" name="rating" value="1.5" /><label class="half" for="star1half" title="Meh - 1.5 stars"></label>
<input type="radio" id="star1" name="rating" value="1" /><label class = "full" for="star1" title="Sucks big time - 1 star"></label>
<input type="radio" id="starhalf" name="rating" value="0.5" /><label class="half" for="starhalf" title="Sucks big time - 0.5 stars"></label>

</fieldset>
<p class="display"></p>


<h3>Please rate your experience with Dr. Singh</h3>
<fieldset class="rating2">
<input type="radio" id="Star5" name="rating2" value="5" /><label class = "full" for="Star5" title="Awesome - 5 stars"></label>
<input type="radio" id="Star4half" name="rating2" value="4.5" /><label class="half" for="Star4half" title="Pretty good - 4.5 stars"></label>
<input type="radio" id="Star4" name="rating2" value="4" /><label class = "full" for="Star4" title="Pretty good - 4 stars"></label>
<input type="radio" id="Star3half" name="rating2" value="3.5" /><label class="half" for="Star3half" title="Meh - 3.5 stars"></label>
<input type="radio" id="Star3" name="rating2" value="3" /><label class = "full" for="Star3" title="Meh - 3 stars"></label>
<input type="radio" id="Star2half" name="rating2" value="2.5" /><label class="half" for="Star2half" title="Kinda bad - 2.5 stars"></label>
<input type="radio" id="Star2" name="rating2" value="2" /><label class = "full" for="Star2" title="Kinda bad - 2 stars"></label>
<input type="radio" id="Star1half" name="rating2" value="1.5" /><label class="half" for="Star1half" title="Meh - 1.5 stars"></label>
<input type="radio" id="star1" name="rating2" value="1" /><label class = "full" for="Star1" title="Sucks big time - 1 star"></label>
<input type="radio" id="Starhalf" name="rating2" value="0.5" /><label class="half" for="Starhalf" title="Sucks big time - 0.5 stars"></label>


</fieldset>

<p class="display2"></p>

<h3>Please provide any additional comments</h3>
<textarea rows="4" cols="50" class="comments"></textarea>
</div>

<div class="back">
<div class="content">
<div class="container-fluid">
<div class="row">
<p>THIS IS THE BACKSIDE</p>



</div>
</div>
</div>
</div>
</div>


Here is the CSS

.front, .back{

backface-visibility:hidden;
}

.back{

transform: rotateY(-180deg);
}
.main-panel{

transition: all 0.6s ease;
transform-style: preserve-3d;
}
.main-panel:hover {

transform: rotateY(180deg);
}


.comments{
position: relative;
float: bottom;
}
.display,.display2 {
position: relative;
left: -40%;
border-style: solid;

line-height: 30px;
border: solid 1px black;
height: 30px;
width: 30px;
float: right;
right: 50%;

}

/****** Style Star Rating Widget *****/

.rating {
border: none;

float: middle;
/* margin-bottom: 20px;*/
}

.rating > input { display: none; }
.rating > label:before {
margin: 5px;
font-size: 1.25em;
font-family: FontAwesome;
display: inline-block;
content: "\f005";
}

.rating > .half:before {
content: "\f089";
position: absolute;
}

.rating > label {
color: #ddd;
float: right;
}

/***** CSS Magic to Highlight Stars on Hover *****/

.rating > input:checked ~ label, /* show gold star when clicked */
.rating:not(:checked) > label:hover, /* hover current star */
.rating:not(:checked) > label:hover ~ label { color: #FFD700; } /* hover previous stars in list */

.rating > input:checked + label:hover, /* hover current star when changing rating */
.rating > input:checked ~ label:hover,
.rating > label:hover ~ input:checked ~ label, /* lighten current selection */
.rating > input:checked ~ label:hover ~ label { color: #FFED85; }


/****** Style Star Rating Widget *****/

.rating2 {
border: none;

float: middle;
/* margin-bottom: 20px;*/
}

.rating2 > input { display: none; }
.rating2 > label:before {
margin: 5px;
font-size: 1.25em;
font-family: FontAwesome;
display: inline-block;
content: "\f005";
}

.rating2 > .half:before {
content: "\f089";
position: absolute;
}

.rating2 > label {
color: #ddd;
float: right;
}

/***** CSS Magic to Highlight Stars on Hover *****/

.rating2 > input:checked ~ label, /* show gold star when clicked */
.rating2:not(:checked) > label:hover, /* hover current star */
.rating2:not(:checked) > label:hover ~ label { color: #FFD700; } /* hover previous stars in list */

.rating2 > input:checked + label:hover, /* hover current star when changing rating */
.rating2 > input:checked ~ label:hover,
.rating2 > label:hover ~ input:checked ~ label, /* lighten current selection */
.rating2 > input:checked ~ label:hover ~ label { color: #FFED85; }

Answer

Alright then, I have added an extra wrapper .panel-wrap with positioning absolute and you have to give the backside an background-color so it won't show the flipped form:

HTML & CSS:

@import url(//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css);
fieldset,
label {
  margin: 0;
  padding: 0;
  display: inline-block;
}

body {
  text-align: center
}

h1 {
  font-size: 1.5em;
  margin: 10px;
}

h3 {
  position: relative;
  float: top;
}

.front,
.back {
  display: block;
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
}

.back {
  transform: rotateY( 180deg );
  background-color: white;
}

.panel-wrap {
  width: 100%;
  height: 100%;
  position: absolute;
  perspective: 800px;
}

.main-panel {
  width: 100%;
  height: 100%;
  position: relative;
  transition: all 0.6s ease;
  transform-style: preserve-3d;
}

.main-panel:hover {
  transform: rotateY(180deg);
}

.comments {
  position: relative;
  float: bottom;
}

.display,
.display2 {
  position: relative;
  left: -40%;
  border-style: solid;
  line-height: 30px;
  border: solid 1px black;
  height: 30px;
  width: 30px;
  float: right;
  right: 50%;
}


/****** Style Star Rating Widget *****/

.rating {
  border: none;
  float: middle;
  /* margin-bottom: 20px;*/
}

.rating > input {
  display: none;
}

.rating > label:before {
  margin: 5px;
  font-size: 1.25em;
  font-family: FontAwesome;
  display: inline-block;
  content: "\f005";
}

.rating > .half:before {
  content: "\f089";
  position: absolute;
}

.rating > label {
  color: #ddd;
  float: right;
}


/***** CSS Magic to Highlight Stars on Hover *****/

.rating > input:checked ~ label,

/* show gold star when clicked */

.rating:not(:checked) > label:hover,

/* hover current star */

.rating:not(:checked) > label:hover ~ label {
  color: #FFD700;
}


/* hover previous stars in list */

.rating > input:checked + label:hover,

/* hover current star when changing rating */

.rating > input:checked ~ label:hover,
.rating > label:hover ~ input:checked ~ label,

/* lighten current selection */

.rating > input:checked ~ label:hover ~ label {
  color: #FFED85;
}


/****** Style Star Rating Widget *****/

.rating2 {
  border: none;
  float: middle;
  /* margin-bottom: 20px;*/
}

.rating2 > input {
  display: none;
}

.rating2 > label:before {
  margin: 5px;
  font-size: 1.25em;
  font-family: FontAwesome;
  display: inline-block;
  content: "\f005";
}

.rating2 > .half:before {
  content: "\f089";
  position: absolute;
}

.rating2 > label {
  color: #ddd;
  float: right;
}


/***** CSS Magic to Highlight Stars on Hover *****/

.rating2 > input:checked ~ label,

/* show gold star when clicked */

.rating2:not(:checked) > label:hover,

/* hover current star */

.rating2:not(:checked) > label:hover ~ label {
  color: #FFD700;
}


/* hover previous stars in list */

.rating2 > input:checked + label:hover,

/* hover current star when changing rating */

.rating2 > input:checked ~ label:hover,
.rating2 > label:hover ~ input:checked ~ label,

/* lighten current selection */

.rating2 > input:checked ~ label:hover ~ label {
  color: #FFED85;
}
<!doctype HTML>

<body>

  <div class="wrapper">
    <div class="sidebar" data-color="blue" data-image="../Public/assets/img/sidebar-4.jpg">

      <!--   you can change the color of the sidebar using: data-color="blue | azure | green | orange | red | purple" -->



    </div>
  </div>
  <div class="panel-wrap">
    <div class="main-panel">
      <div class="front">
        <h3>Please rate the overall experience of your visit</h3>
        <fieldset class="rating">
          <input type="radio" id="star5" name="rating" value="5" />
          <label class="full" for="star5" title="Awesome - 5 stars"></label>
          <input type="radio" id="star4half" name="rating" value="4.5" />
          <label class="half" for="star4half" title="Pretty good - 4.5 stars"></label>
          <input type="radio" id="star4" name="rating" value="4" />
          <label class="full" for="star4" title="Pretty good - 4 stars"></label>
          <input type="radio" id="star3half" name="rating" value="3.5" />
          <label class="half" for="star3half" title="Meh - 3.5 stars"></label>
          <input type="radio" id="star3" name="rating" value="3" />
          <label class="full" for="star3" title="Meh - 3 stars"></label>
          <input type="radio" id="star2half" name="rating" value="2.5" />
          <label class="half" for="star2half" title="Kinda bad - 2.5 stars"></label>
          <input type="radio" id="star2" name="rating" value="2" />
          <label class="full" for="star2" title="Kinda bad - 2 stars"></label>
          <input type="radio" id="star1half" name="rating" value="1.5" />
          <label class="half" for="star1half" title="Meh - 1.5 stars"></label>
          <input type="radio" id="star1" name="rating" value="1" />
          <label class="full" for="star1" title="Sucks big time - 1 star"></label>
          <input type="radio" id="starhalf" name="rating" value="0.5" />
          <label class="half" for="starhalf" title="Sucks big time - 0.5 stars"></label>

        </fieldset>
        <p class="display"></p>


        <h3>Please rate your experience with Dr. Singh</h3>
        <fieldset class="rating2">
          <input type="radio" id="Star5" name="rating2" value="5" />
          <label class="full" for="Star5" title="Awesome - 5 stars"></label>
          <input type="radio" id="Star4half" name="rating2" value="4.5" />
          <label class="half" for="Star4half" title="Pretty good - 4.5 stars"></label>
          <input type="radio" id="Star4" name="rating2" value="4" />
          <label class="full" for="Star4" title="Pretty good - 4 stars"></label>
          <input type="radio" id="Star3half" name="rating2" value="3.5" />
          <label class="half" for="Star3half" title="Meh - 3.5 stars"></label>
          <input type="radio" id="Star3" name="rating2" value="3" />
          <label class="full" for="Star3" title="Meh - 3 stars"></label>
          <input type="radio" id="Star2half" name="rating2" value="2.5" />
          <label class="half" for="Star2half" title="Kinda bad - 2.5 stars"></label>
          <input type="radio" id="Star2" name="rating2" value="2" />
          <label class="full" for="Star2" title="Kinda bad - 2 stars"></label>
          <input type="radio" id="Star1half" name="rating2" value="1.5" />
          <label class="half" for="Star1half" title="Meh - 1.5 stars"></label>
          <input type="radio" id="star1" name="rating2" value="1" />
          <label class="full" for="Star1" title="Sucks big time - 1 star"></label>
          <input type="radio" id="Starhalf" name="rating2" value="0.5" />
          <label class="half" for="Starhalf" title="Sucks big time - 0.5 stars"></label>


        </fieldset>

        <p class="display2"></p>

        <h3>Please provide any additional comments</h3>
        <textarea rows="4" cols="50" class="comments"></textarea>
      </div>

      <div class="back">
        <div class="content">
          <div class="container-fluid">
            <div class="row">
              <p>THIS IS THE BACKSIDE</p>



            </div>
          </div>
        </div>
      </div>
    </div>
  </div>


</body>

Hope it helped!

Cheers!

Evoc :)