Text in HTML/CSS is refusing to indent properly within boxes

I am working on a web page that animates boxes and displays text details. However, I am facing an issue where the text does not align properly inside the flipped box.

I would like to decrease the font size of the text in the flipped box. Despite trying to adjust the alignment, the text remains unaffected. My goal is to keep all the text neatly contained within the box boundaries.

Check out the code here

flexbox{
margin: 0;
padding: 0;
list-style-type: none;
display: flex;
flex-flow: row wrap;
justify-content: center;
}
.panels{
  list-style-type: none;
  padding: 0;
   width: 100%;
  margin: 2% auto;
}

.panels li{
  position: relative;
  width: 20%;
  margin: 5px;
  display: block;
  box-sizing: border-box;
  float: left
}

.panels li div{
  width: 100%;
  padding: 50% 0;
  text-align: center;
  line-height: 0;
  cursor: pointer;
    -moz-box-shadow: 0px 2px 7px rgba(0, 0, 0,0.2);
    -webkit-box-shadow: 0px 2px 7px rgba(0, 0, 0, .2);
    box-shadow: 0px 2px 7px rgba(0, 0, 0, .2);
}

.panels div.back{
  background: linear-gradient(to bottom, #e40000, #f07611);
transform: rotateY(90deg);

  font-family: Cabin;
  font-size: 1.4707843137254901vw;
  color: #3d4250;
position: absolute;
    left: 0;
    top:0;
}
.panel div.front{
  background: white;  
  font-family: Cabin;
  font-size: 1.9607843137254901vw;
  color: #3d4250;
  position: relative;
}

/*// ANIMATION STYLES //*/

.panels li:hover div.front{
  animation: twirl 0.2s ease-in forwards;
}

.panels li:hover div.back{
  animation: twirl 0.2s 0.2s ease-in forwards reverse;  
}
@keyframes twirl{
  0%{
    transform: rotateY(0deg);
  }
  100%{
    transform: rotateY(90deg);
  }
}
<ul class="panels flexbox">
      <li>
        <div class="front">Sense of Purpose</div>
        <div class="back"><h6>Sense of purpose</h6>
        "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </div>
      </li>
      <li>
        <div class="front" style="background: #9126f4">Get to</div>
        <div class="back">The chopper</div>
      </li>
      <li>
        <div class="front" style="background: #21bf3b">foo</div>
        <div class="back">bar</div>
      </li>
      <li>
        <div class="front" style="background: #c3333d">tempus</div>
        <div class="back" >fugit</div>
      </li>
      <li>
        <div class="front" style="background: #c3333d">html</div>
        <div class="back">rocks</div>
      </li>
      <li>
        <div class="front" style="background: #21bf3b">A</div>
        <div class="back">B</div>
      </li>
      <li>
        <div class="front" style="background: #9126f4">Super</div>
        <div class="back" >Mariokart</div>
      </li>
      <li>
        <div class="front" style="background: #267df4">j</div>
        <div class="back">Query</div>
      </li>
    </ul>

Answer №1

Solving the issue of text overlapping can be done by removing the line height.

.panels li div{
  width: 100%;
  padding: 50% 0;
  text-align: center;
  /*line-height: 0;*/
  cursor: pointer;
    -moz-box-shadow: 0px 2px 7px rgba(0, 0, 0,0.2);
    -webkit-box-shadow: 0px 2px 7px rgba(0, 0, 0, .2);
    box-shadow: 0px 2px 7px rgba(0, 0, 0, .2);
}

Additionally, make sure to include a height property on the div elements.

.panels div.back{
        background: linear-gradient(to bottom, #e40000, #f07611);
        transform: rotateY(90deg);
        height: 18px;
        font-family: Cabin;
        /* font-size: 1.4707843137254901vw;*/
        color: #3d4250;
          position: absolute;
          left: 0;
          top:0;
      }
      .panel div.front{
        background: white;  
        font-family: Cabin;
        /*font-size: 1.9607843137254901vw;*/
         color: #3d4250;
          position: relative;
      }

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

Utilize the CSS exclusively for the specific element

nav ul { } nav ul li { margin-left: 7px; } nav.ul li a, a:link, a:visited { float: left; padding: 7px; margin-left: 15px; color: #ffffff; text-decoration: none; font-weight: bold; } nav ul li a:hover { } The styling above is ...

Implement a dynamic table in real-time with jQuery AJAX by fetching data from JSON or HTML files

Hey @SOF, I'm trying to add an auto-update feature to my school grades webpage using jquery and ajax to refresh the data when new information is available. I also want to create a "single view" for classes. The challenge I'm facing is getting t ...

Verification of user input upon clicking the submit button within a form

I am encountering an issue with validating my form, as no errors are displayed in the console. I have followed the instructions provided by Bootstrap documentation but to no avail. My aim is to implement a feature where clicking on the button triggers an a ...

Choosing pseudo-elements with CSS styling rules

I have been utilizing the Brave browser to block online ads. However, certain websites have found a way to insert ads into their HTML on the server-side, bypassing my ad-blocking efforts in Brave. Currently, Brave only offers the ability to block elements ...

How to incorporate an image as a background in a Bootstrap 4 card

I'm working on achieving a specific design, as shown in the image https://i.sstatic.net/GRjwo.jpg In Bootstrap 4, it's simply a group of cards with the "card-img-overlay" class. The issue arises when the height of the card is dependent on the im ...

What is the method for creating a hovering triangle on a particular element?

My navigation bar consists of two parts. On the left side, there is a logo image, and on the right side, there are 4 list elements. I am attempting to make a triangle appear at the bottom of the element when hovered. I have floated the list to the right an ...

Determining the existence of a file on a different domain using JavaScript

One of the key tasks I need to achieve from JavaScript on my HTML page is checking for the existence of specific files: http://www.example.com/media/files/file1.mp3 // exists http://www.example.com/media/files/file2.mp3 // doesn't exist Keep in mi ...

Use the CSS class

To create tables with 3 rows and 2 columns using divs, I have utilized the ng-repeat directive. Within this setup, there are two CSS classes - red and green, that need to be applied in the following manner: - Red class for the 1st column of the 1st row - ...

Encountering difficulties linking to a stylesheet or a script in an HTML file delivered by Express server

Currently, I'm facing the challenge of breaking down my Express app code into multiple files. Unfortunately, I am unable to utilize <link href> or <script src> for linking stylesheets or scripts. Below is the relevant snippet from my inde ...

Getting the text value from a table in JavaScript is a straightforward process. By using

I am working with a table displaying available hotel rooms and want to change the text color to green if the room is marked as "available." Is there a way to check the innerHTML of a td element to see if it contains the word "available"? var status = do ...

Having four videos displayed on one webpage can cause the browser to function at a slower

I have videos that are around 30 seconds long and 15mbs. I'm wondering if it's feasible to include them on a page or if I should opt for cover images instead. I would like to use the video as a separator similar to the design showcased at Does a ...

Set border-image to have rounded corners

I am attempting to create a circular button with a unique border effect. Here is the code I have implemented so far: body { display: flex; height: 100vh; overflow: hidden; justify-content: center; align-items: center; } button { height: 80px ...

CSS font-face is not functioning as expected

I'm experiencing issues with importing a CSS font, and I'm puzzled as to why it's not working. The specific font in question is 'deadjim.ttf' and it is located within my main public_html directory. I have confirmed that the file p ...

Vertical Alignment Challenge in Bootstrap Container

I'm struggling with formatting my simple website. I have a navbar, footer, and a centered container where I want to display text and buttons. However, I can't seem to get the elements to appear on separate lines - I want the text on one line and ...

What is the highest value that AutoCompleteExtender can reach?

I am currently using an AutoCompleteExtender in my code with the following configuration: <ajaxToolkit:AutoCompleteExtender runat="server" ID="autoCompleteOrigem" TargetControlID="txtClienteOrigem" ServicePath="~/Cliente/Au ...

Trouble organizing a collection of destinations based on their geolocation and proximity

To address this issue, my approach has been to feed variables into the value attributes of an option list and then sort it based on these values. When manually assigning values, everything works smoothly, for example: <option id="link1" value="1">A& ...

Incorporating Keyboard Features into Buttons

How can I toggle the page selectors in #pageList using a keyboard shortcut instead of clicking on the .togglePL button? I've tried looking up solutions online and asking questions here, but haven't found a working solution yet. Below is the code ...

Is there a way to enhance the height of Bootstrap combobox items? Can this be achieved?

Is it possible to improve the height of Bootstrap combobox item? How can I achieve that?https://i.sstatic.net/MkGFd.jpg 1 2 3 4 ...

An empty space separating the header and the navigation bar

As a beginner in HTML and CSS, I decided to create a basic website. However, I encountered an issue with the layout - there seems to be a gap between my header image and navigation bar, but I can't figure out what's causing it. HTML <!DOCTYPE ...

What is the best way to incorporate multiple Bootstrap templates into an Angular project without causing conflicts between them?

When incorporating a bootstrap template into the admin interface, it is important to consider that its design may vary from the template used for visitors. Mixing multiple styles based on different templates can lead to conflicting styles and can potenti ...