Troubleshooting Border Width Problem in Safari Version 9.1.3

It seems like there is an issue in Safari 9.1.3 where the border width on elements with a specific combination of styles is causing unexpected outcomes. Essentially, I am using a transform on an absolutely positioned element to achieve horizontal centering on an element with variable width.

HTML:

<div class="border">
    <div class="border__text">
        test
    </div>
</div>

CSS

.border {
  position: absolute;
  left: 50%;
  padding: 50px;
  border: 1px solid #666666;
  transform: translateX(-50%);
}

.border__text {
  font-size: 12px;
  font-style: italic;
  font-family: "Times New Roman", Times, serif;
}

Screenshot

https://i.sstatic.net/xD3Xg.png

Codepen

Give it a try in Safari 9.3.1

I have been able to make it work by adjusting the font size to either 11 or 13 pixels, but my preference is for it to be at 12 pixels. Additionally, removing the transform allows it to work, but I'm struggling to find another simple way to horizontally center an absolutely positioned element.

Answer №1

Instead of using the transform property, you can achieve the desired effect by following this approach:

.border {
  position: absolute;
  left: 0;
  right: 0;
  text-align: center;
}

.border__text {
  display: inline-block;
  font-size: 12px;
  padding: 10px 50px;
  border: 1px solid #666666;
}
<div class='border'>
  <div class='border__text'>test</div>
</div>

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

What is the best way to handle media queries when determining the validity of both statements?

I'm trying to figure out how to apply CSS based on whether one of two statements is true. For instance: @media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape) OR and (max-device-width : 1024 ...

Is there a way to substitute the bootstrap in order to accomplish the same goal?

<!DOCTYPE html> <html> <head> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"> <title> Home - Hasan's Website </title> <style> body, ...

Achieving consistent height for Grid items in Material-UI

I'm looking to achieve equal heights for these grid items without distorting them. Here's the current layout: https://i.sstatic.net/6dPed.jpg This is how I would like it to look: https://i.sstatic.net/BJZuf.jpg My challenge is that adjusting ...

Efficiently Fill JQUERY Mobile Multi-Pages with Dynamic Content

A Question for JQUERY Mobile Beginners: In my basic JQUERY Mobile application, I have a simple setup with two pages. When the user navigates to PAGE2, I need to make an AJAX call to retrieve a JSON object that contains a list of people along with their DB ...

Website Responsiveness - inquiries for all needs

My first responsive website project has hit a roadblock, as I struggle to understand how to implement media queries effectively. Here's a snippet of my code... <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/x ...

Using the jQuery plugin multiple times within one website

I have a decent understanding of jQuery and I'm in the process of developing a plugin. Specifically, it's a dropdown element that I'm working on. Everything functions correctly when there's only one dropdown on the site. However, when ...

To link circles vertically with a line and fill them with color when clicked, follow these steps:

I am looking to create a design similar to the image below using unordered list items. When a user clicks on a list item, I want the circle to fill with color. I have structured it by creating a div with nested list items and span elements. If a user click ...

What is the best way to implement an IF THEN ELSE statement using ngStyle in Angular?

How can I make rows in a table highlight based on the STATUS value? Currently, I have it set up to show yellow if the STATUS is 1 using the following code: [ngStyle]="{'background-color': cnresult.STATUS === 1 ? 'yellow' : '&a ...

Identifying broken links within a table through the onerror function

I am currently working with a table that includes links, and my goal is to hide any items from the list that have 404 URLs. In the example below, there are two lists in the table. The first one is for Steve, with a link to apple.com, and the second one i ...

Guide to adding a theme switcher feature to your current React website

Currently, I am faced with a challenge involving two theme files, theme.js and theme-dark.js, within the context of a complex React-based website. Despite having already set up the site, I am struggling to find a way to allow users to seamlessly switch bet ...

Optimizing web development: Employing HTML templates to dynamically enhance website performance

My task involves the redesigning of an existing website (foo.com) using .NET and C#. The website caters to multiple companies such as abc.com, def.com, ghi.com, etc. Currently, the website utilizes html templates specific to each company's website in ...

Changing the background color dynamically of a table header in Angular Material

I have utilized the angular material table following this example. https://stackblitz.com/angular/jejeknenmgr?file=src%2Fapp%2Ftable-basic-example.ts In this case, I modified the heading color with the following CSS code. .mat-header-cell { backgrou ...

Using Javascript to upload an image and show it in a small display

Hey there, I have a functioning JavaScript code that loads an image uploaded by the user onto the HTML page. However, the issue is that the image doesn't have a set maximum height or width, causing buttons on the page to move out of view and become in ...

When you click on the text, it vanishes, but when you enter new text,

As I create my very first landing page, I aim for a simple and not too professional design to familiarize myself with building web pages independently. However, I am facing an issue where the text disappears when a user clicks on the textbox. The problem ...

How come I can click on both radio buttons simultaneously?

How come I can select both radio buttons simultaneously? <form #form="ngForm"> {{ poll.counter1 }} votes <input type="radio" id="{{ poll.choice1 }}" value="{{ poll.choice1 }}" (click)="onChoice1(form)">{{ poll.choice1 }} <br> ...

Align the radio buttons vertically

My goal is to align all my buttons vertically, similar to the first question. However, I'm struggling to get the second question to align correctly. Despite trying different methods like using the vertical-align: middle property, nothing seems to be w ...

Footer that sticks in a vuejs application

I am facing a challenge in implementing a sticky footer in my vuejs application. Vuejs and similar frameworks require the presence of a root element in the template. This requirement is causing complications when trying to use Flex to create a sticky foo ...

Sliding views in CSS using ui-router

I want to create a sliding in/out effect for my views similar to what is demonstrated here: Here is the Plunker I have created: http://plnkr.co/edit/ST49iozWWtYRYRdcGGQL?p=preview However, when I copy the CSS from the link above, my entire ui-view disapp ...

Load subtitles into your video in real-time

Let's discuss the scenario: The server is receiving a stream of SRT file. This stream is then converted into VTT format by the server, which is further buffered and sent to the client through an io.socket connection. Below is the server-side code: s ...

Dynamic Loading of CSS Styles

My style-sheet is saved in this unique location: /opt/lampp/htdocs/project/core/styles/Style.css To load the CSS file using the full directory, considering that the files utilizing it are situated here: /opt/lampp/htdocs/project/client/ The ultimate ob ...