``There is a misalignment issue in the CSS Flip Animation that needs to be fixed

I am currently working on implementing a CSS flip animation that I found here into my website. The animation itself is functioning properly, but I am facing an issue with aligning the text I want to include in the center of both the front and back sides. While I could adjust padding, font size, or text size individually, I am curious if there is another method to achieve proper center alignment for everything.

Once I can get the text centered, I plan on resizing the larger portions of text on the back side separately.

To better understand the problem I am facing, please refer to the following jsfiddle link:

Examples: https://jsfiddle.net/glueckskind/kfhy7fh3/

  /* entire container, keeps perspective */
  .flip-container {
    perspective: 1000px;
  /* ADDED */
    margin: auto;
    padding: 0;
  }
  /* flip the panel when hovered */
  .flip-container:hover .flipper, .flip-container.hover .flipper {
    transform: rotateY(180deg);
  }

  .flip-container, .front, .back {
    width: 340px;
    height: 100px;
    display: inline-block;

  }

  /* flip speed goes here */
  .flipper {
    transition: 0.6s;
    transform-style: preserve-3d;

    position: relative;
  /* ADDED */
    text-align: center;
  }

  /* hide back of panel during swap */
  .front, .back {
    backface-visibility: hidden;

    position: absolute;
    top: 0;
    left: 0;
  /* ADDED */
    font-family: 'Raleway', sans-serif; 
    font-size: 22px;

  }

  /* front panel, placed above back */
  .front {
    z-index: 2;
  /* for firefox 31 */
    transform: rotateY(0deg);
  /* ADDED */
  /* padding: 10px; makes one line ok */
    font-weight: 500;
    border: 1px solid rgba(0, 0, 0, 0.5)
  }

  /* back, initially hidden panel */
  .back {
    transform: rotateY(180deg);
  /* ADDED */
  /* padding: 10px; makes one line ok */
    border: 1px solid rgba(0, 0, 0, 0.9);
  }

Answer №2

Several browsers come with predefined margin or padding settings, so it's a good idea to reset the margin of an element to 0 if you encounter this issue. I have faced this situation numerous times.

`<pre>
.box p {
padding: 0;
margin: 0;
}
</pre>
`

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

caption sliding into the incorrect div box

As I continue my journey of learning CSS, I've encountered a puzzling issue involving slide-in captions within a different div element. The problem arises when I try to customize the appearance of the caption to better fit the overall design of my web ...

Enhance your picture links with a:hover box-shadow styling

I've been struggling to add a box shadow on hover to a Facebook icon image. I assumed it would be straightforward, but as always, I was wrong. I'm working with a child theme in WordPress because I recently started, thinking it would be an easy wa ...

Pseudo-class for clicking a button on Mobile WebKit

Currently, I am in the process of developing a private framework to replicate the iOS UI using CSS 3 and HTML 5. Most of the widgets have been created, including various colored gradient buttons, but faced with challenges when attempting to incorporate a b ...

Siblings are equipped with the advanced selector feature to

I'm struggling to understand this setup I have: <div class="container"> for n = 0 to ... <a href="some url">Link n</a> endfor for each link in ".container" <div class="poptip"></div> ...

How to retrieve the width of a document using jQuery?

Having a strange issue with determining the document width using $(document).width() during $(window).load and $(window).resize. The problem arises when the browser is initially full screen and then resized to a narrower width, causing content to require ...

Using PHP, JavaScript is unable to hide <div> elements

I'm encountering an issue where the div I want to show when an error occurs is not hiding and showing properly using JavaScript. Here is a snippet of my code: <script> function hideerror() { var catdiv = document.getElementById(error); ...

Excessive gap beneath the footer in Wordpress

I have come across many solutions for this issue, but none of them seem to work for me. On my main page, when I scroll to the bottom, the footer appears to have extra space beneath it, which actually seems to be the background of the page. This problem onl ...

Is the custom CSS being overridden by the bootstrap.css.map file?

I am currently working with Bootstrap 4 and I am attempting to adjust the padding for the navigation links within the navbar using my own custom CSS file: .nav-link { padding: 0.15rem; } However, the styling that is being applied comes from the followin ...

Tips for preventing labels from overlapping in JavaScript

After texturing an image to a sphere in 3D (as shown below), I encountered an issue where the planegeometry labels were overlapping. I am looking for a way to separate these labels using the three.js library. 2 labelBox.prototype.update = function() { ca ...

What is the simplest way to shift an icon to the right in the header of an Expansion panel using Vuetify

After implementing the template from this example: https://vuetifyjs.com/en/components/expansion-panels/#usage I am facing an issue where the header icon is stuck to the title Even applying "float: right;" does not seem to resolve it Has anyone els ...

Ways to customize the background color of selected items in ion-list on Ionic

I am working on an Ionic project and I have a list of items. I am trying to change the background color of the pressed item. Can someone help me with this? index.html <ion-list> <ion-item ng-repeat="item in familleItems"> <div ng- ...

What is the best way to hide only the rows in a table when it is clicked using JavaScript?

Is there a way to hide rows in these tables by clicking on the table head? I'm currently using bootstrap 5 so JQuery is not an option. <table class="table table-info table-bordered"> <thead id="tablea"> ...

Tips on avoiding tags from causing line breaks?

My dilemma involves a collection of tags that I prefer not to be subject to word-wrap, but I do want the list of tags to wrap appropriately. For instance: [first] [second thing] [yet another thing] What I definitely do not want is: [first] [second thi ...

How to make divs occupy the entire space of a parent div?

I've been scouring the website for a solution, but nothing I've found has been helpful. I'm attempting to create a grid within a containing div where a default (and eventually user-specified) number of divs will fill up the space. I'm t ...

How can I change the padding that is being inherited from "@ .MuiAlert-icon"?

Is there a method to override the padding inherited from "@ .MuiAlert-icon"? The Chrome inspector indicates that the current padding is set to 7px. .MuiAlert-icon { display: flex; opacity: 0.9; padding: 7px 0; font-size: 22px; ...

When attempting to print a Bootstrap 4 HTML page in Chrome, the browser headers and footers are being clipped

Currently experiencing an issue with printing an HTML page styled using Bootstrap 4 (Bootstrap 3.3.7 works fine) on Chrome where the header and footer are partly covered up. Take a look at this screenshot to see what I mean - the date, title, and file/url ...

"The space between the header-main section and the main-footer section is pure white

I'm facing an issue with the white space between the header-main and main-footer sections. I would like to either match their color to the rest of the website or completely remove the space. The color I want to use is #fefcf5. I hope this edited versi ...

Command field in Javascript

I've crafted an exquisite search box for my website, but I'm struggling to make it functional and display search results. Below are the Html and CSS files pertaining to this section of my site: .searchbox{ /*setting width of the form eleme ...

Creating Consistent Button Padding in Material UI

I am working with a series of Material UI buttons that are defined as follows: <Button className={classes.button}>Edit</Button> <Button className={classes.button}>Duplicate</Button> <hr /> <Button c ...

Having trouble saving text in a textbox?

Is there a way to store text in a text box for future use? Every time I reload the page, the text in the box disappears. I have attempted the following solution: <td align='left' bgcolor='#cfcfcf'><input type="text" name="tx ...