Issue with Firefox when combining text-transform and text-overflow properties

Hope everything is going well.

I encountered a challenging issue that I need help with (please run the snippet using firefox on Windows or Linux) :

<html>
    <head>
        <style>
            .content {
                background-color: red;
                width: 200px;
                display: flex;
                flex-direction: row;
            }

            .content .text {
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
            }

            .content .text:first-letter {
                text-transform: capitalize;
            }
        </style>
    </head>
    <body>
        <div class="content">
            <div class="text">code mapping</div>
            <div>(i)</div>
        </div>
        <div class="content">
            <div class="text">code postal</div>
            <div>(i)</div>
        </div>
        <div class="content">
            <div class="text">zipe codigo</div>
            <div>(i)</div>
        </div>
        <div class="content">
            <div class="text">some div</div>
            <div>(i)</div>
        </div>
        <div class="content">
            <div class="text">foo bar zoo</div>
            <div>(i)</div>
        </div>
        <div class="content">
            <div class="text">The expected behavior for the ellipsis</div>
            <div>(i)</div>
        </div>
    </body>
</html>

The problem arises when I apply capitalization to the first letter, causing unexpected text-overflow behavior.

Here is a screenshot of the displayed result (as it may vary depending on browser settings) : https://i.sstatic.net/OzsY3.png

Interestingly, the behavior differs based on the specific string content.

If you can help me by :

  1. Explaining why the behavior changes based on the text input (for example, only "code postal" displays ellipses in my case)
  2. Suggesting how to prevent ellipses when the parent element's width is not reached?

Wishing you a great day!

Edit 1: I found that replacing capitalize with uppercase resolves the issue. However, this workaround does not fully address the original question and creates unexpected spacing between elements.

Answer №1

The script is functioning properly in Firefox. However, I am using a Mac. You may want to consider including a max-width: calc(100% - 15px) property in the .text section. For reference, you can view the code on JS Fiddle

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

Identify the XML variable within the XSL file and confirm its existence by responding with a res

I am facing issues with the Xpath expression test="$roles/roles/role='HOBSCS1GB'" . Is there anyone who can assist me in resolving this problem? Thank you. <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl ...

generating dynamically evolving controls within the MVC framework

I am looking to dynamically create controls in a view based on the source. For example, if the type is a text box, I want to generate a text box; if it is a check box, I want to create a check box dynamically in MVC. Below is the snippet of my current code ...

Rotating images with React

I am encountering an issue with implementing an image carousel in React. Previously, it worked perfectly when I was not using React, but now that I am migrating the page, I am facing an error. ** The carousel is located on the home page: ** const Home = ( ...

Center-aligned video text overlay that adapts to different screen sizes for a responsive design

I am looking to showcase a full-width video with overlay text that is perfectly centered both vertically and horizontally on the video. The centering should adapt to changes in viewport width so that it remains centered at all times. Additionally, I would ...

Show specific modal or image depending on various criteria

Seeking guidance on how to achieve the following tasks in a simple manner as my understanding of HTML, Bootstrap, and CSS is basic: 'When radio button #1, radio button #4, and button #2 are clicked, upon submission display modal 1 with an image at a ...

Tips for effectively deleting a flash object from an HTML page

I recently created a website with AJAX (using jquery) for navigation purposes. The pages on the site slide smoothly, and I have been using remove() to get rid of the old page. Everything was working fine until I encountered an issue where the browser cras ...

Guide on displaying JSON information upon clicking using JavaScript

I'm having difficulty writing the logic for this code. I have extracted data from a vast API. The current code fetches all program titles (some may be repeated) and compares them with an array of late night shows, then displays them once in their own ...

Issues with implementing a Bootstrap dropdown list in a Django HTML template

I'm having trouble implementing Bootstrap in my Django project's shared HTML file. The dropdown list isn't functioning properly despite trying various approaches, including using CDN and local Bootstrap files. When I click on the dropdown li ...

Tips for obtaining user input to place markers on a video timeline with JavaScript

I am new to Java script and I am trying to create a video player where users can click on the progress bar to place markers. Can you please review my code below and let me know if there are any errors? index.html <!doctype html> <html> <he ...

What methods can I use to stop Meta and Title tags from injecting when I import PHP files into an HTML document?

In my PHP document, I took out the Title and Meta tags from the header section, leaving it empty: <!doctype html> <html> <head> </head> <body> <?php require '/DBConnect.php'; //More code here that generates my ou ...

The image remains contained within the boundaries of the container without overflowing

Working on a vue Project utilizing tailwind for styling, I have a flexbox layout that includes two custom components. The second component is an image that should maintain its size and not shrink or distort when the screen size is reduced. Instead, it shou ...

How can you leverage Beautiful Soup to extract data from a specific CSS class on a webpage?

In the process of scraping this html with code, my main objective is to extract the link from it using Selenium driver. html = driver.page_source soup = BeautifulSoup(html) file_link = soup.select(".inpfilelink") return file_link print file_upload("/hom ...

What is the reason behind the inconsistency of calling a function on click not always functioning properly in Chrome and FF, while working seamlessly in IE?

Consider a scenario where the code below is being used: <HTML> <HEAD> <SCRIPT> function myFunction(atlasTrackingURL) { var atlasURL = atlasTrackingURL; if (!atlasURL) return; //Creating a cache busting mechanism ...

Arranging Pictures Beside Text Using CSS

I have a puzzling issue that I cannot seem to find an answer for despite the countless times it has been asked. In my footer, there is aligned copyright text, and I am attempting to add 3 logos to the right of it without any line breaks. However, when the ...

The drag-and-drop feature for uploading files is not functioning properly

After following the JavaScript drag and drop script tutorial mentioned here and using the PHP upload script provided here, I made modifications to the XHR request to upload.php in the JS code. The progress now reaches 100%, but the uploaded image does not ...

The middle toggle line stubbornly refuses to properly disappear

I'm facing an issue with the toggle button on my practice site. When clicked, it undergoes a transition and displays a cross or X symbol. I've used CSS to create a cross shape by hiding the middle line. However, after the transition, the middle l ...

Looking to create cascading dropdown options

I am working on a form that includes 3 dropdowns with the same options listed below: <select id="one"> <option value="1">Select</option> <option value="1">One</option> <option value="2">Two</option> <option val ...

Newbie inquiry regarding the setup and utilization of Bootstrap

I'm currently working on building a website and I decided to incorporate a bootstrap carousel. Initially, I had a dropdown button in the navbar along with a collapsible menu for smaller viewports which were functioning properly. However, when I added ...

Can JQuery be used to specifically target attributes with vendor prefixes?

Is there a way to change the Thumb color for my slider without needing to select the thumb with a vendor prefix? I want to be able to dynamically pick the color without simply appending a class. $('.button').on('click', function (e) { ...

What are some creative ways to enhance closePath() in canvas styling?

Currently, I am faced with the challenge of styling the closePath() function on my canvas. Specifically, I would like to apply different stroke styles to each line segment. For now, let's focus on changing colors for each line. In the example below, y ...