Skip to main content

Why This Post?

It seems the flip tile has made a resurgence in popularity of late and having been asked about how to rotate something and defaulting to the Z-axis which was not the desired effect but rather to rotate along the Y-axis - I decided to spend a little time playing with this and offer some code.

Also because a common question I have seen is how to get the code from the Docebo Inspire session a couple years ago. My hope is that this post will help make the process of implementing some flip tiles in your platforms a little bit easier by finding it here directly without downloading and digging it out of another document.

Lets start with the end result of my playing around. I made four tiles that were slightly different.

**NOTE**
These are tiles which are all placed inside of an HTML/WYSIWYG widget.
These are not widgets themselves that are flipping.

 

Tiles Explained

  1. The first tile (upper left) is an image for the front and an image for the back along with a button that links to somewhere else.
  2. The second tile (upper right) is an image for the front and text with a button that links to somewhere else.
  3. The third tile (lower left) is simply text on both sides - no links
  4. The fourth tile (lower right) is Text on the front with an image on the back. In this case, the entire image is a link to somewhere else.

The Code

Here is the CSS - again - I heavily commented this in an effort to help you make changes to your own  use case a little easier.

/** Flip Tiles **/

/** General style for the Tile **/
/** Adjust dimensions and padding as desired **/

.myTile {
background-color: transparent;
width: 150px;
height: 150px;
perspective: 500px;
display: inline-block;
padding-bottom: 15px;
padding-right: 10px;
}

/** This is a wrapper for the effect **/
/** The wrapper will contain both the front and back divs **/
/** Adjust the timing of the flip as desired - I liked 1.5 **/
/** I used the box shadow to provide a sort of thickness to the tile **/
/** Adjust the box shadow or remove as desired **/
/** I also added a little border-radius to round the corners **/
/** If you choose to adjust the radius - there are three spots **/

.myTileWrap {
position: relative;
width: 100%;
height: 100%;
text-align: center;
transition: transform 1.5s;
transform-style: preserve-3d;
box-shadow: 2px 4px 8px 2px rgba(255,255,255,0.8), 1px 5px 2px 0 rgba(0,0,0,0.8);
border-radius: 20px;
}

/** This block will rotate the tile half way **/
/** No real need to adjust this **/

.myTile:hover .myTileWrap {
transform: rotateY(180deg);
}

/** This block affects both front and back tiles **/
/** Adjust the border-radius as desired to match above **/

.myTileF, .myTileB {
position: absolute;
width: 100%;
height: 100%;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
border-radius: 20px;
}

/** This block affects the front face of the tile **/
/** Adjust background and text color as desired **/

.myTileF {
background-color: #bbb;
color: black;
}

/** These two blocks will affect the border-radius **/
/** Front and back settings are here separately **/

.myTileF img {
border-radius: 20px;
}

.myTileB img {
border-radius: 20px;
}

/** These two blocks will affect the underline of button link **/
/** Front and back settings are here separately **/

.myTileF a {
text-decoration: none;
}

.myTileB a {
text-decoration: none;
}

/** This block will affect the back of the tile **/
/** Adjust background and text color as desired **/

.myTileB {
background-color: #000000;
color: red;
transform: rotateY(180deg);
}

/** This block affects the look of the buttons **/
/** Adjust these settings as desired for your call to action **/

.actionBtn {
width: 80%;
padding: 5px;
text-align: center;
background-color: teal;
color:white;
border-radius: 15px;
margin-top: 5px;
display:inline-block;
}


/** End Flip Tiles **/

Next we have the HTML component

These are setup so that they will line up horizontally until you use a break tag to drop in another row.

Each block for a tile is essentially the same but for some minor differences. For additional tiles, Copy the desired type of tile and paste it in the desired location for your row. Then modify it as needed.

<!-- For all tiles, change out your image paths and URLs as desired -->

<!-- This is the first tile in the first row -->

<div class="myTile">
<div class="myTileWrap">
<div class="myTileF">
<img src="https://path/to/image.jpg" style="width:150px;height:150px;">
</div>
<div class="myTileB">
<img src="https://path/to/image.jpg" style="width:100px;height:100px; padding-top: 10px;">
<a class="actionBtn" href="http://community.docebo.com">Profile</a>
</div>
</div>
</div>

<!-- This is the second tile in the first row -->

<div class="myTile">
<div class="myTileWrap">
<div class="myTileF">
<img src="https://path/to/image.jpg" style="width:150px;height:150px;">
</div>
<div class="myTileB">
<h1>Need<br>Help?</h1>
<a class="actionBtn" href="https://help.docebo.com">Ask</a>
</div>
</div>
</div>

<!-- This effectively creates the second row -->
<!-- For more tiles in the first row, copy a block -->
<!-- and add it above these comments -->

<br>

<!-- This is the first tile in the second row -->

<div class="myTile">
<div class="myTileWrap">
<div class="myTileF">
<h2>Thanks<br>for<br>being<br>a...</h2>
</div>
<div class="myTileB">
<h2>Life<br>Long<br>Learner!</h2>
</div>
</div>
</div>

<!-- This is the second tile in the second row -->

<div class="myTile">
<div class="myTileWrap">
<div class="myTileF">
<h1>Time<br>to<br>Learn</h1>
</div>
<div class="myTileB">
<a href="https://inspire2022.docebo.com/"><img src="https://path/to/image.jpg" style="width:150px;height:150px;"></a>
</div>
</div>
</div>

As always, test in your environment and let me know if there are any bugs or questions.

Hopefully this is helpful for someone today.

As a small addendum…

If you wanted the tiles to appear as though it was the actual widget flipping, you could adjust the color of the widget background to match the rest of your page.

I believe the default is  background-color: #f5f5f5;

Then you can set the  box-shadow: none;  and the tiles will look like they are native to the page.


This is fantastic! I used it and got some flip cards setup and they worked great. Now they look all wonky and I can’t figure out why. When I hover over them, they flip and are blank. It’s like both B and F tiles are showing rather than one when flipped.

 This is the code I am using:

.myTile {

  background-color: transparent;

  width: 150px;

  height: 150px;

  perspective: 500px;

  display: inline-block;

  padding-bottom: 15px;

  padding-right: 10px;

}

.myTileWrap {

  position: relative;

  width: 100%;

  height: 100%;

  text-align: center;

  transition: transform 1s;

  transform-style: preserve-3d;

  box-shadow: 2px 4px 8px 2px rgba(255,255,255,0.8), 1px 5px 2px 0 rgba(0,0,0,0.8);

  border-radius: 0px;

}

.myTile:hover .myTileWrap {

  transform: rotateY(180deg);

}

.myTileF, .myTileB {

  position: absolute;

  width: 100%;

  height: 100%;

  -webkit-backface-visibility: hidden;

  backface-visibility: hidden;

  border-radius: 0px;

}

.myTileF {

  background-color: #bbb;

  color: black;

}

.myTileF img {

  border-radius: 0px;

}

.myTileB img {

  border-radius: 0px;

}

.myTileF a {

  text-decoration: none;

}

.myTileB a {

  text-decoration: none;

}

.myTileB {

  background-color: #156082;

  color: #ffffff;

  transform: rotateY(180);

}

.actionBtn {

  width: 80%;

  padding: 5px;

  text-align: center;

  background-color: #03A7C2;

  color:white;

  border-radius: 15px;

  margin-top: 5px;

  display:inline-block;

}


Can you share your HTML as well?


OK - I found the issue.

This should be 

transform: rotateY(180deg);


Ah thanks! I edited that and it’s still not working. Here’s my html:

<div class="myTile">
<div class="myTileWrap">
<div class="myTileF">
<img src="https://cdn5.dcbstatic.com/files/c/e/ced_learn_docebosaas_com/userfiles/13046/Catalog%20Cards/pc_mgmt_ns.png" alt="Pc mgmt dev" style="width:150px;height:150px;" /></div>
<div class="myTileB">
<h4> </h4>
<h4>Courses to keep you build your management skills.</h4>
<a class="actionBtn" href="https://ced-learn.docebosaas.com/pages/50/pc-management-development-courses-test">View</a></div>
</div>
</div>


Ah thanks! I edited that and it’s still not working. Here’s my html:

Hmm…

I used your CSS and HTML.

The only thing I changed was to add the deg to 180 and the path to one of my images.

It worked fine in my platform.

Maybe a hard refresh of your browser?


I wonder if there’s something else in my CSS that’s interfering. I’ll dig through it to see if I can find it. It would have to be something that references the same elements, is that right?


If I don’t find anything there, should I try deleting the CSS, saving and then adding it back in again?

(I’m new to HTML/CSS so troubleshooting is extra new for me)


You might delete what you have related to the tiles and paste in my original CSS.

Then make only one change at a time until you arrive at your desired look.

If you test between each change and something stops working you’ll know it was the most recent adjustment that broke it.


Ah, that makes a lot of sense. Thanks!

 


That totally worked, thank you!

A follow up question: I’m trying to make similar flip cards that are different dimension and I’m getting stuck. I created a myTile3, as well as a myTileG and myTileJ (using mytileF and myTileB as templates) but I can’t get it to look quite right, nor will they flip. I tried starting with your code and changing one thing at a time (the image, the myTile elements). I changed just the image first, and it looked like this and the flip still works. 

I need it to be different dimensions than myTile so I created a myTile3 with 300x50. When I change it to myTile3, the size adjusts but the flip functionality disappears. 

The CSS for myTile3 is:

.myTile3 {

  background-color: transparent;

  width: 300px;

  height: 50px;

  perspective: 500px;

  display: inline-block;

  padding-bottom: 15px;

  padding-right: 10px;

 

This is my html. What am I missing to get the flip functionality?

<div class="myTile3">
<div class="myTileWrap">
<div class="myTileF"><img src="https://cdn5.dcbstatic.com/files/c/e/ced_learn_docebosaas_com/userfiles/13046/PC%20Mgr%20Shortcuts/my_team___image_only.jpg" alt="my_team___image_only.jpg" /></div>
<div class="myTileB"><a class="actionBtn" href="https://ced-learn.docebosaas.com/pages/50/pc-management-development-courses-test">Manage My Team</a></div>
</div>
</div>


You will also need to create one more block to go with your myTile3

 

.myTile3:hover .myTileWrap {
transform: rotateY(180deg);
}

 


Ahhhh, that makes sense! Thank you so much! I’m learning as I go, and this has been incredibly helpful.


@gstager I got it to work! Then I was asked if I can have it flip on the X axis rather than Y. I changed the code to transform: rotateY(180deg) which worked but the back side was upside down. ;(


Reply