Is it a Chrome glitch or a deliberate feature?

I recently encountered an issue while troubleshooting some HTML code. I needed to provide form data that customers could easily copy and paste. Normally, customers would double-click on the identifier and press CTRL-C. Here is how I initially formatted my code:

<label>Identifier</label><div>ABCD1234</div>
<label>Description</label><div>Some descriptive words</div>

Everything was fine until the Description needed to wrap and not below the label. To address this, I incorporated some CSS inline styling.

<style>
.fixform label { min-width: 76px; }
.fixform div { display: inline-block; width: 210px; padding-bottom: 3px; }
</style>
<div class="fixform">
    <label>Identifier</label><div>ABCD1234</div>
    <label>Description</label><div>Some descriptive words</div>
</div>

However, this caused an issue where double-clicking the identifier selected both the identifier and the preceding word "Identifier". Similarly, clicking "Description" highlighted both "Description" and "Some". It seems that using "inline-block" treats the last word of the label and the first word of the div as a single unit.

To resolve this, I added a space at the end of the text inside the label. But I feel like this solution is somewhat makeshift. Is there a better way to present labeled content with word-wrapping in columns without encountering the peculiar double-click behavior in Chrome?

Answer №1

If you're looking for a solution, I suggest implementing display:table;

.optimal{
  display: table;
}
.optimal label {
  min-width: 76px;
  display: table-cell;
}
.optimal div {
  display: table-cell;
  width: 210px;
  padding-bottom: 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

Utilize a script on a div that is dynamically loaded via AJAX

Can anyone assist me with loading external content into a div? I attempted to use a code for this purpose, but now my scripts are not functioning correctly. Any help would be greatly appreciated - I'm new to this type of work. Thank you function aja ...

Steps for eliminating an element upon the second click:

I am faced with a challenge where I need to dynamically add elements to a container on the first click and delete them on the second click. I feel like I am complicating things unnecessarily and there must be a simpler and more elegant solution available. ...

Tips for modifying the color of selected text

Is there a way to change the color of the dropdown text? Currently, it is set to red but initially appears as black. When clicked on, it changes to red. How can I make it so that the color is initially displayed as red? <select> <option style ...

Is the background image unable to fill up the entire screen?

I'm currently facing an issue with my webpage's background not covering the entire vertical space. Despite trying different solutions and referring to previous posts, I haven't been able to resolve it yet. Here is the relevant code: <div ...

The React Component in Next.js does not come equipped with CSS Module functionality

I have been attempting to incorporate and apply CSS styles from a module to a React component, but the styles are not being applied, and the CSS is not being included at all. Here is the current code snippet: ./components/Toolbar.tsx import styles from & ...

Looking for a skilled JavaScript expert to help create a script that will automatically redirect the page if the anchor is changed. Any t

Seeking a Javascript expert, In my custom templates, I have used a link as shown below: <a href='http://www.allbloggertricks.com'>Blogging Tips</a> I would like the page to redirect to example.com if the anchor text is changed from ...

How to make the parent div adjust its height to fit the children [CSS]

I am facing an issue with my parent div's height when adding more children. Despite setting the height of the parent to auto or not specifying a height at all, it ends up with a random height that does not seem to match the sum of its children. Even i ...

Unable to access the suggestion list within the modal

I incorporate the PrimeNG AutoComplete feature within a PrimeNG Dialog, displaying a list of elements below the AutoComplete in the dialog. My objectives are: To set the max-height of the modal dialog to 300, and have a visible scrollbar if the total ...

Adjusting Screen Size for Lottie Animation in React.js

I need assistance with resizing a lottie animation component on my website's landing page to set its display to none on mobile devices. How can I achieve this? See the lottie component code below: import React from "react"; import Lottie fr ...

two sections lined up beside each other

Currently, I have two sections positioned on separate lines. Each section consists of multiple lines of text, and I am looking to align them next to each other with a 10px margin between them. Would appreciate any assistance in achieving this setup. Thank ...

Is there a way to divide extensive CSS files using Python?

The issue I am facing is due to the limitations of IE 8 on CSS files. Within my Flask project, some of my CSS files exceed these limits, causing them not to render correctly. Is there a way to split CSS files using Python in order to ensure that they meet ...

What is causing all font-faces (such as glyphicon icons) to load correctly only when utilizing Bootstrap's online CDN source file?

I recently encountered an issue with my Plunker code (https://embed.plnkr.co/KpVqaiblOKGk5K6VWmi4/), where everything worked perfectly in Microsoft Visual Studio Code. However, when I tried to use the Bootstrap source file offline by setting the link' ...

Child element matching Parent's dimensions causes overflow

I've been searching extensively on Google, but I couldn't find an answer to why children of a parent with the same size are overflowing. For instance, <div style="background:blue;width:500px;height:40px"> <div style="border:1px ...

Ways to effectively go through local storage using a loop

I'm currently working on enhancing my navbar by adding links based on searches made by users and their favorite selections. My goal is to avoid duplicate entries in the "past searched" section if the current search already exists in the list. I'm ...

Delete the HREF attribute after accessing the LINK

I am looking to achieve a specific effect... <div id="content"><a href="#MyForm">some text</a></div> After Clicking/Accessing the Link once, I want "some text" to appear as ordinary text... like <div id="content"><a>s ...

Adjust the horizontal position of a span element from left to right based on its class

Welcome to my first question here, with many more to come in the future. I have an issue with positioning that I'm not sure is possible to solve. The problem arises with an unordered list (<ul>) containing floated <li> elements. For the m ...

Inquiring about the usage of div elements in constructing an HTML webpage

When designing my own web pages, I consistently encounter issues with using divs for a multi-column layout. Despite utilizing the float attribute to align columns left or right, resizing the browser window often causes them to stack on top of each other an ...

Extract the td elements from a table with specific class using the DataTable plugin

I stumbled upon this snippet of code while browsing through the DataTable website. var table = $('#example').DataTable(); table.column(0).data().each(function(value, index) { console.log('Data in index: ' + index + ' is: &apos ...

Verify if uploading a photo is necessary

Here is my approach to ensuring that a file is added before it can be uploaded: <script type="text/javascript> function check(){ var elm = document.getElementById("hello-world"); if (elm.value.length > 0){ alert("Hey"); re ...

What could be causing my tabs to shift to the vertical side when using large, larger, and wide screens?

In my previous research, I came across a question similar to mine: Pure CSS accordion not working within CSS tabs. The solution mentioned works perfectly on monitors of any size, but the difference lies in the use of the a element. In their code, setting t ...