Safari CSS issue: Relative parent and child with pseudo selector not producing consistent output across different browsers

I'm not seeking a specific fix for the code, but rather an explanation as to why it behaves this way.

In Safari, children elements with a relative parent appear in a different position compared to other browsers. Changing the child to absolute positioning can bring some consistency.

Edit: Checking Safari & Chrome on iPhone 8+, both display incorrectly. This might be an issue at the OS level.

Figure 1: Inconsistent Design (focus on caret with red background)

https://codepen.io/treckstar_/pen/eYVYyjK

.c-anchor-explore--toggle {
    font-size: 16px;
    font-weight: 700;
    padding: 7px 0px;
    position: relative;
}

.c-anchor-explore--caret {
    position: relative;
    right: -70px;
}

Safari 14 Output https://i.sstatic.net/84sn0.png

Chrome Output https://i.sstatic.net/0ZmH3.png

Figure 2: Consistent Design (same caret with red background)

https://codepen.io/treckstar_/pen/xxYxpBe

I also adjusted the element's position and centered visually, yet the issue persisted.

.c-anchor-explore--toggle {
  font-size: 16px;
  font-weight: 700;
  padding: 7px 0px;
  position: relative;
  -webkit-appearance: none; /* remove border around safari */
  margin-right: 40px; /* match the right: -40px; to make sure it looks centered */
}

.c-anchor-explore--caret {
  position: absolute; /* cannot be relative as Safari will not render correctly */
  right: -40px;
  top: 3px;
}

https://i.sstatic.net/5UwXk.png

Answer №1

If you want to improve performance, consider using the CSS property

-webkit-transform: translateZ(0);
. This property is optimized for HTML5 content specifically on iOS devices.

.c-link--expand {
    font-size: 14px;
    font-weight: 600;
    padding: 5px 0px;
    position: relative;
    -webkit-transform: translateZ(0);
    margin-right: 30px;
}

.c-link--arrow {
    position: relative;
    right: -50px;
    top: 3px;
}

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

Having trouble getting the CSS footer from cssstickyfooter.com to function properly

I tried implementing some basic CSS from to create a sticky footer that remains at the bottom of the page regardless of content length. However, I am encountering a problem with the footer not behaving as expected. There are actually two issues with the f ...

Click here for a hyperlink with an underline that is the same width

As we work on our website, we want a unique feature where links are underlined when hovered over, with the underline staying the same width regardless of the length of the link text. How can we achieve this using CSS/jQuery/Javascript? ...

How come my gifs appear tiny even though I've adjusted their width to 32% each?

I am trying to display three gifs in a row, each taking up one-third of the width of the page. However, when I preview the page, the gifs appear tiny. I have set the divs to 32% each and the gifs should fill 100% of their respective div. Here is the code s ...

In search of a comprehensive AJAX-enabled content management system

Is there a Content Management System (CMS) available that can create a fully ajax-driven website, allowing for a persistent Flash component without the need to reload it with each page navigation? ...

Retrieve input value from a jQuery template

I've created a template <div id="template" style="display: none;"> <strong>Name</strong>: <span class="name"></span><br/> <input type="number" id="amount"> <button type="button" onclick="App.submit ...

"I am facing an issue where the button does not appear centered after using jQuery

I can't help but notice that when applying CSS directly, my buttons end up centered horizontally. Yet, when I insert the same code using append(), the buttons seem to align towards one side instead. Here is the HTML/CSS code snippet: <div style=" ...

Create a dynamic design with Angular Material's mat-drawer at full height using flexbox, allowing content

Yesterday, I encountered an interesting CSS problem involving the mat-drawer and Angular's router-outlet. My layout consists of a full-page flexbox with two children: a mat-toolbar at the top, and a custom component called app-sidenav at the bottom. T ...

Trouble displaying complete image (ReactJS, CSS)

I am looking to create a visually stunning landing page that covers the entire screen, showcasing a captivating image. However, I have encountered an issue where only a portion of the image is visible due to additional divs being created. Here is what my ...

CSS might not always work properly on all web browsers, but it functions perfectly on Eclipse

When developing JSF pages with stylesheets, everything seems to be working fine in the Eclipse preview function. However, when I test the pages on IE8, the styles do not seem to have any effect. I am utilizing composite views to define a general layout fo ...

Verifying if a div in jQuery holds a specific element

I am currently developing drag and drop widgets using jQuery. After dropping them, I need to verify if my draggable and droppable widget is located inside another div. <div id="droptarget"> <div class="widget">I'm a widget!</div> ...

what methods do you use to recall codes?

Hey there! I've recently started diving into the world of HTML, CSS, and Php. I'm curious, how exactly do experienced coders manage to remember so many functions? Is it something that comes with time and practice? As a beginner myself, this quest ...

Customizing Paths in Express Handlebars

I have a query regarding setting up custom folders in Express.js Here's my situation: I need to implement logic where if a specific name is present in my database, the paths for CSS and JS files should be altered before rendering. By default, my pat ...

Styling CSS variables uniquely

I have limited knowledge of HTML and CSS, so I am unsure how to search for a similar post on StackOverflow. My apologies if this is a duplicate question. I am looking to achieve the following: margin-horizontal { margin-left: value; margin-right: va ...

Difficulties arise when retrieving the value of a radio input in PHP using the model-view-controller framework

My attempt to retrieve the value of a group of radio inputs in a form is not successful. VIEW: <form class="form-horizontal" method="post" action="Index.php?opt=filter"> stuff... . . . <div class="form-group"> <label class="col-md-4 ...

What is the best way to "re-upload" drop-down selection using javascript?

I am attempting to automate a drop-down selection process on a website using a headless browser called Firefox Marionette. The website is not under my control, and the process involves: A primary drop-down menu where I can choose an option. A secondary dr ...

Manipulating an HTML <div> element to display its value as a suffix in another <div> within the HTML code

I'm attempting to combine and show text along with content from another <div> as the modal-header, but it's not displaying correctly. When I give an ID to the modal-header, the *&times;* symbol disappears. This is how my modal-header l ...

Trigger the opening of a bootstrap modal from an external source on the current page

One common question is how to load a modal from another page onto the current page, or how to open a modal on the current page when it loads. My idea is a little different: I want to click on an image hotspot (like a person in a team photo) on the /home p ...

What is the best method for resizing an SVG according to the size of my website's window?

I am attempting to implement a scalable settings icon SVG file that adjusts based on the window width. My approach involved creating a JavaScript function that alters the element's dimensions according to the window size, but unfortunately, this metho ...

Why isn't Bootstrap validation functioning properly in my Modal?

I am attempting to implement client-side validation using bootstrap, as outlined here: https://getbootstrap.com/docs/4.0/components/forms/#custom-styles The challenge I'm facing is that my form is within a modal. When I click the submit button, nothi ...

Create a stylish slide-in menu using CSS, triggered by an onclick event. No JavaScript required!

I implemented a hamburger menu that slides in when clicked. However, I'm facing an issue where the slide-in menu disappears after a second. How can I make sure the menu stays visible? #navigationWrap { position: fixed; top: 0; ...