Issues with incorrect sizing in Safari when using rem units alongside animations

UPDATE: After further testing, it appears that the code functions correctly within the SO snippet view. To replicate the issue, please copy the code and save it locally.

UPDATE 2: Odd behavior detected. Refer to this gist and video for more information.

I'm attempting to create a logo with a pulsating animation, but I've encountered a strange issue while testing it on Safari 11.1.1. The animation works correctly on Firefox 60.0.2 and Chrome 67.0. If possible, please test it on Edge and IE and share your results.

Below is a minified snippet that showcases the problem.

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css">
    <style>
    .foo-logo {
        height: 10rem;
        width: 10rem;
        margin: 2.5rem;
        background-color: red;
    }

    .foo-logo > p {
        color: white;
        font-size: 1.5rem;
        text-align: center;
    }

    .foo-animation {
        animation: pulse-animation 5s infinite;
    }

    @keyframes pulse-animation {
        0% {
            height: 10rem;
            width: 10rem;
            margin: 2.5rem;
        }
        50% {
            height: 15rem;
            width: 15rem;
            margin: 0rem;
        }
        100% {
            height: 10rem;
            width: 10rem;
            margin: 2.5rem;
        }
    }
    </style>
</head>
<body>
    <div class="foo-logo"><p>No animation</p></div>
    <div class="foo-logo foo-animation"><p>Animation</p></div>
</body>
</html>

If you cannot access Safari, refer to this screenshot: https://i.sstatic.net/OLXOT.png

Answer №1

After testing in Safari, it appears to be a bug specific to that browser. Consider submitting a bug report and waiting for a fix to be implemented.
Alternatively, you can try a workaround by adjusting your CSS as shown below:

.foo-logo {
    font-size: 1rem; 
    /* 1em is equivalent to font-size, so 1em is equal to 1rem in this case */
    height: 10em;
    width: 10em;
    margin: 2.5em;
    background-color: red;
}

@keyframes pulse-animation {
    /* It is possible to exclude 0% and 100% in this case */

    50% {
        width: 15em;  /* 1em equals 1rem */
        height: 15em;
        margin: 0;
    }
}

.foo-logo > p {
    color: white;
    font-size: 1.5rem;
    text-align: center;
}

.foo-animation {
    animation: pulse-animation 5s infinite;
}

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

The onClick functionality of a button may not work properly when nested within a DIV element in an ASP.NET project

Here is a snippet of code that includes a <div> element: <div id="specific"> <table cellpadding="2" border="0"> <tr><td>Choose category</td><td><select id="list_categories" runat="server"></select>< ...

What is the best way to eliminate leading zeros in PHP when echoing SQL statements?

Being a front-end programmer on a team of three, my PHP/MySQL skills are fairly basic. However, our back-end programmer is going on vacation and we have a deadline to address a minor visual detail. Currently, we are working on a page that displays multiple ...

The HTML attribute "hasbox" specifies the presence of a box within the element

I am currently working on resolving some rendering issues specifically in IE9 and have encountered a tag attribute that I am not familiar with - hasbox. Upon further investigation, it seems like IE is injecting this attribute at runtime as it does not app ...

Utilize Google Autofill to easily populate address fields in a form

I've come across several autofill address codes, but I'm looking to integrate a Post function that would allow me to post the obtained data to a PHP page. Is there anyone who can assist with the javascript or HTML code to achieve this? HTML Cod ...

Challenges arising from updating the size and position of a div element during a mouse move event

As I work on creating a basic horizontal split pane using HTML, CSS, and JavaScript, I have drawn inspiration from this post. While the vertical split pane functions smoothly, the horizontal version seems to be glitchy. The sizes and positions of the div ...

IE11 Experiencing Overflow Issue with List Item Pseudo Element Numbers

Having a simple unordered list of links and using pseudo elements to generate numbers for the list, I encountered an issue with centering the number vertically within its circle background in Internet Explorer 11. Here is the HTML code: <ul> < ...

Assistance requested with Javascript for an HTML dropdown menu

My question involves utilizing two HTML drop down menus. <select> <option value="">Please Select</option> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option ...

Troubleshooting problem with Z-Index conflict in Flash animation

I am facing an issue with two HTML divs - one containing a flash movie and the other simple text. I want to place the textual div on top of the flash movie div, but no matter how I set their positions in CSS or adjust their Z-Index values, the text keeps ...

Using Flutter to return an HTML response rather than JSON

Experiencing an issue and seeking assistance with this Flutter code as a newcomer to the platform. I am able to successfully retrieve data using https://jsonplaceholder.typicode.com/posts, but encountering errors when trying to access my company's URL ...

Utilizing Knockout to Render JSON List Items

Utilizing Knockout.js to dynamically update a view from JSON response has been my current focus. The structure of the JSON is as follows: var data = { "Properties": { "Engine Capacity": "1499cc", "Doors": 3, "Extras": [ "LED lights", ...

What is the best way to line up elements in a horizontal position

Encountering a strange bug in my code Here's what I have: <div class='test'> <button class='btn'></button> <div class='nest'> more... </div> </div> My CSS .test{ ...

Guide to ensuring the navbar remains at the top of the webpage following an image

I am attempting to create a sticky navbar that stays at the top of the page once the header has been scrolled past. It should have a similar effect as shown in this example on codepen.io, but with the addition of an image that stretches across most of the ...

Utilizing a CSS/HTML div grid to mirror a 2D array in JavaScript

Currently, I am working on a personal project that involves creating a grid of divs in HTML corresponding to a 2D array in JavaScript. However, I am uncertain about the most effective way to accomplish this task. Specifically, what I aim to achieve is tha ...

Attempting to implement a b-table that can manage multiple arrays within an array

This is the b-table, designed to display a column of food items <b-table :fields="Fields" :items="ITEMS"> <template #cell(food)="data"> {{data.item.food}} </template> </b-table> //Column ...

The directive in Angular compels the webpage to carry out the added HTML attribute

There is a custom directive in my code that applies the spellcheck attribute to two div elements as shown below: (function(){ 'use strict'; app.directive('spellchecker', spellchecker); spellchecker.$inject = ['$timeout&a ...

Utilizing the text field feature within Twitter Bootstrap 3.0 in-line styling

I am attempting to create a horizontal form with an inline text field split into two sections: one on the left and one on the right. The left side will contain horizontal text fields, some of which are inline, while the right side will have a mix of inline ...

Is there a way to locate a child div using the mouse within a parent div that only has a class name assigned to it?

Hey there, I've been searching for a solution to my issue but haven't found exactly what I need. I'm new to jquery and currently working on creating a newspaper layout form. Adding new divs within the layout canvas is easy with this code: ...

Utilizing CSS to create a zoom effect on hover for an image while preserving its original size was successful, however, the issue arises as only a corner of the image is visible

On my webpage, I have implemented an image that zooms in slightly when hovered over. Unfortunately, this animation has caused the image to only display one part regardless of whether hover is activated or not. I've attempted to troubleshoot by adjusti ...

What are the steps to create a "gooey glide" animation using React and MUI?

I am looking to create a unique animation for my list of items on a web page. My goal is to have the items slide in one by one with rapid succession and then slightly shrink once they reach their final position, similar to how pillows might fall or like a ...

Replacing Bootstrap CSS with a custom stylesheet

Within my bootstrap.css file, the following styling is defined: .form-control { display: block; width: 100%; height: 34px; padding: 6px 12px; font-size: 14px; line-height: 1.428571429; color: #555555; ve ...