Safari miscalculating % widths for floated inline-block elements

I am currently utilizing the JQDateRangeSlider for its intended purpose. However, I have encountered an issue with the Ruler component, specifically in displaying new months/years, similar to the example showcased here:

During testing on Safari, I noticed a gap at the end where additional ticks should have been displayed. This is not stemming from a JavaScript or plugin problem, as the widths are calculated using percentages. It seems to be purely a display glitch. The problem can be seen in the image below:

The issue arises when there are multiple inline-block floated elements with their widths and margin-left properties specified as percentages. For instance:

<div class="ui-ruler-scale ui-ruler-scale1">

<div class="ui-ruler-tick" style="display: inline-block; width: 1%;"></div>
**[remaining code omitted for brevity]**
</div>

The CSS involved does not need to be overly complex since most of the styling is done through inline styles. In the provided example, the elements are floated left and contain a set margin-left property.

I have created a JSFiddle that showcases the issue based on just the HTML + CSS components. It's worth noting that this problem persists even with basic widths like 1%, not exclusively with more intricate multi-decimal point measurements found in my example.

http://jsfiddle.net/uLLMe/14/

Regrettably, formatting the HTML in a user-friendly manner results in added whitespace, making it less legible.

Thank you

Answer №1

It appears there are too many elements with 1% widths in this code snippet. This could potentially cause layout discrepancies between browsers, especially Safari. To resolve this issue, it is recommended to define a specific width such as "20px" instead of using percentages. If percentage-based widths are necessary, adjusting the size of the containing div may help. It is advisable to use pixel values that are divisible evenly by the number of percentage-based elements.

Additionally, consider adding some placeholder content within the divs for better visualization.

<div class="ui-ruler-tick" style="display: inline-block; width: 1%;"> &nbsp; </div>

Experiment with changing the display property and float attributes for improved rendering:

<div class="ui-ruler-tick" style=" display:block; float:left; width: 1%;"></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

Switching the color of the nav-link in Bootstrap

Struggling to change the color of my Bootstrap's nav-link to white with no success. Here is my code snippet: <nav class="navbar navbar-light" style="background-color: #5E9DFE;"> <a class="navbar-brand" href=& ...

Discrepancy in image dimensions between Android and iOS

Currently, I am in the process of building a website and have encountered an issue with the display of images on Android and iOS phones. The image appears differently on an Android Galaxy J-5 compared to an iOS iPhone 6s screen. My goal is to make it look ...

What is the process for adding a download link to my canvas once I have updated the image?

Is it possible to create a download link for an image that rotates when clicked, and then allows the user to download the updated image? Any help would be appreciated.////////////////////////////////////////////////////////////////////// <!DOCTYPE ht ...

Unexpected issue on AngularJS application

Encountering issues with incorporating a controller into my page - each time I add it to a DOM element, an error is thrown. Here's the structure of my HTML page: <html data-ng-app="sportsStore"> <head> <title>Sports Sto ...

Struggles arise when the Flexbox container fails to accurately calculate its width and causing overflow

My goal is to create a reusable React library that can take a list of components and display them in a flex container. One key feature is that the library recalculates the component's width when it mounts or when the window is resized. If the total wi ...

Limit a user from inputting certain characters into a textbox

Is there a way to prevent a specific character from being typed into a text box? ...

Creating a dynamic navbar with Python (Django), HTML, CSS, and Javascript for a fully responsive

I am currently utilizing a guideline to develop a responsive navbar that adapts its layout based on the screen size. It will display elements in a dropdown list for smaller screens, as opposed to an inline layout used for larger screens. Here is a snippet ...

Using PHP to save a row of data and display it on the same page

Having some trouble with my html table that is populated using php and mysql. There's a 'update' button in one of the columns, but I'm not getting the desired result when clicking it. print("<input type='submit' value=&apo ...

What is the best way to transfer data from a div tag to an li tag using JavaScript?

https://i.stack.imgur.com/se2qk.pngI am attempting to change the div tag content to li tag. Here is a snippet of the code from inspect for reference. I need to remove the div tag with the "domTitle" class. <li style="display: inline;" id="list_name"> ...

I'm having trouble with the appearance of my table and I can't seem to pinpoint where I went wrong with the

I'm having trouble with my table - it looks wonky and unfinished. I can't seem to figure out what went wrong, and I'm completely stuck. Can someone please assist me? ...

Unable to scroll horizontally beyond 200 viewport widths

I'm facing an issue with my code that switches between vertical and horizontal scrolling but seems to have a width limit of 200vw. When I set the min-width to 50vw, only 4 sections are visible, whereas setting it to 100vw (as shown in the example) dis ...

Maximizing the potential of Angular forms through native FormData

Currently, I am revisiting an older project that still uses traditional methods for form submission. The HTML includes a form element with defined method and action. My goal is to submit the form in the old-fashioned way using the action attribute to post ...

How can I access the DOM element within my render function in React on the same component?

I'm curious about the best approach for accessing DOM elements within my render function from the same component. It's important to keep in mind that this component will be rendered multiple times on a single page. For example: var ToDoItem = R ...

Comparing Strict CSS with Hacky CSS - Which is the Better Choice?

When working with CSS, it becomes evident fairly quickly that certain styles are not universally compatible across different browsers. For instance, achieving a semi-transparent PNG required a convoluted solution for Internet Explorer like: filter: pro ...

Numerous categories housed within various div containers

I am working with an HTML code that contains 6 different div elements: <div class="hisclass1 hisclass2 myclass hisclass3"> <div class="herclass1 herclass2"> <!-- 2nd div --> </div> </di ...

Ways to avoid the browser from storing a JSON file in its cache

Hey there, I'm working on a project and running into some issues with caching. The problem I'm facing is that the browser keeps holding onto the json file containing save data even after I update it elsewhere. This means that the browser is readi ...

Incorporating a classList.toggle into a snippet of code

button, p, h1, h2, h3, h4, h5, a{ /* Define specific elements to use "fantasy" font */ font-family: Tahoma; } #main_body{ margin: 0px auto; background-color: #dedede; } #top_body{ /* Remove margin for simplicity */ } #t ...

Loading images based on specified search parameters in PHP

As I work on my project, I am faced with the task of loading a specific image from a local folder after the user clicks the search button. The current code that I have in place is: <!-- [SEARCH FORM] --> <form method="post"> <h1> S ...

Retrieve a website's favicon.ico using JavaScript

After attempting Ajax: $.ajax({ type : "GET", url : "http://getfavicon.appspot.com/http://www.google.com", success : function(result) { // use the .ico result somewhere } }); I encountered this error message: XMLHttpRequest cannot load htt ...

Ensure that the div is set to start on a new line without causing any sudden jumps to the

I have 3 divs that I want to display side by side. If the text inside each div gets too long, I would like it to break to a new line and have the next div stay beside it. <div style="float: left;">This is some text</div> <div style="flo ...