Bug Alert: Fieldset Overflow Issue in Google Chrome

It appears that Google Chrome is experiencing a bug with overflowing content inside of a fieldset element.

For a visual demonstration of the issue, you can visit this jsfiddle link: http://jsfiddle.net/Dismissile/Lnm42/

Upon inspecting the page, it becomes evident that when a container is nested within a fieldset and has the CSS property overflow: auto applied to it, causing its contents to overflow horizontally, the fieldset itself expands rather than displaying a scrollbar:

<fieldset class="parent">
    <div class="child">
        <div class="grandchild">
            asdf
        </div>
     </div>
</fieldset>

<div class="parent">
    <div class="child">
        <div class="grandchild">
            asdf
        </div>
    </div>
</div>

CSS styles being used:

.parent {
    border: 1px solid green;
    padding: 20px;
    margin: 20px;
}

.child {
    border: 1px solid red;
    padding: 20px;
    overflow: auto;
}

.grandchild {
    border: 1px solid #ccc;
    width: 2000px;
    padding: 10px;
}

If you are looking for a CSS workaround or fix that will allow content to overflow correctly when nested inside a fieldset in Chrome, please let me know!

Answer №1

Important Update:

Following a recent update to Chrome for MS Windows (possibly version 28, exact details pending), the value auto is no longer accepted for min-width. Therefore, the previous solution provided in this post is no longer effective!

Here's a New Solution:

I have found that using inherit instead of auto resolves the issue across all instances I have tested. You can find more information and details on the updated fix in the revised fiddle: new fiddle fix.

The corrected code snippet is as follows: FIELDSET {min-width: inherit; }

Previous Response:

In Chrome, the default user agent style for fieldset includes min-width: -webkit-min-content.

When the visible area (or "screen") is smaller than a div with a specified width, the -webkit-min-content property causes the fieldset to expand to accommodate the content size, along with padding and other factors.

To address this issue, you can use the following CSS fix: FIELDSET { min-width: auto; }

I have adjusted your fiddle accordingly, feel free to test it out here: try it out!

Answer №2

If you use a pseudo fieldset (also known as

<div class="fieldset"></div>
), you can achieve a similar layout. Check out this example on jsfiddle.

Here is the CSS styling to try:

fieldset, .fieldset {
   margin: 10px;
   border: solid 1px black;
   position: relative;
   padding: .5em;
}

.legend {
   left: 0.5em;
   top: -0.6em;
   color: black;
   position: absolute;
   background-color: white;
   padding: 0 0.25em 0 0.25em;
}

Although it's not perfect and requires duplicating fieldset styling, this workaround was the best solution I could find for dealing with this issue. You may be able to adapt your existing fieldset styles to the pseudo fieldset in a similar manner.

Answer №3

Give it a shot:

section {
 display: table-cell;
 min-width: 0;
 box-sizing: border-box;
}

Here's the corrected version: http://jsfiddle.net/5tc8npqz/

Answer №4

Adjusting the viewport width with JavaScript:

I included a new class called fieldset-width to the fieldset element:

<fieldset class="parent fieldset-width">

Then, I implemented the following jQuery code:

$(document).ready(function() {
  $(".fieldset-width").css("width", $(window).width() - 82);
});

$(window).resize(function() {
  $(".fieldset-width").css("width", $(window).width() - 82);
});

One thing to note is that altering the default behavior of fieldsets may not always be beneficial. It's important to consider the user experience and avoid causing unnecessary scrolling within input fields.

Answer №5

A possible solution is to include style="display:table-column;" within the fieldset element.

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

Create a Javascript list by using the append method

I am working on creating a list using Javascript and the Append function. In my project, I have an index.php file, script.js file, and a search.php file that executes the mysql query. Although everything is functioning properly, I am not satisfied with t ...

Disable the resizing function for the text area

I have a form in Rails that includes a text area. The issue is that the text area can be resized by the user, which I do not want. How can I prevent the user from resizing it? <%= form_tag "doit", :id => "doit_form" do -%> Names <br/& ...

Horizontalize your lists

Is there a way to make the li elements horizontal in this pagination setup? I've attempted display: inline and display: float, but neither seem to be working for me. <ul class="pagination" style="display:inline; text-align: center; margin:0;">& ...

I tried to upload a unique theme on my WordPress website, but unfortunately, the design is not displaying correctly. I am having

After uploading a custom theme on WordPress as a parent theme, I encountered an issue where only simple text appeared on the screen without any styling, images, or sliders. Being new to PHP, I struggled to understand how to enqueue the styles in the functi ...

Utilizing PHP to create header and footer with .htaccess

Instead of placing the header and footer before/after the <html> and <body> tags in every single page using the .htaccess file, is it possible to include the header right after the <body> tag and the footer right before the </body> ...

React Vertical Scroll Carousel

Looking to create a website section that remains fixed while scrolling through a carousel vertically. Once the last slide is reached, scrolling will continue navigating the page rather than changing carousel slides. Unsure how to achieve this. Desiring a ...

Error encountered during file upload - file field :input not found

I'm dealing with some HTML that looks like this: <div id="promocodesUpload"> <div class="qq-uploader"> <div class="qq-upload-drop-area" style="display: none;"> <span>Drop </span> </div> <a class=" ...

I'm currently reviewing a CSS stylesheet for a React webpage, and I've noticed that several classes are utilizing content to dynamically create images. However, the display of content in VSCode appears as a bullet point

Exploring an existing ReactJS website, I've noticed that many images are rendered using the CSS content property. While examining the CSS file in VSCode, I've come across classes where the content is displayed as "". I'm uncertain whether ...

Steps for implementing a Material-UI transition effect with hover using pseudo classes

My useStyles hook code is meant to create a full-page background that changes on hover, but for some reason it isn't working. I came across a similar solution in CSS which works perfectly. Can you help me figure out the issue? Code snippet that' ...

Turn off the ability to click on images, but allow users to access the right

https://i.stack.imgur.com/jriaP.png Example image sourced from reddit.com Illustration represents the desired effect using CSS and possibly JS. In essence: I aim to make an image on a website unclickable to its imageURL There should be a context menu ...

I'm currently working on setting up a gallery on the lower part of my webpage, but for some reason, the lightbox2 images are not aligning next to each other in rows. Can anyone

Struggling to align images in a gallery at the bottom of my webpage. They keep appearing on separate lines instead of next to each other. HTML: <section id="galleries"> <h2>Galleries</h2> <article class="img- ...

JQuery is having trouble with playing multiple sound files or causing delays with events

I've been working on a project that involves playing sounds for each letter in a list of text. However, I'm encountering an issue where only the last sound file is played instead of looping through every element. I've attempted to delay the ...

"Encountered an issue when attempting to initiate an Appium session, receiving the error message: "Error: spawn ENOENT" during the process of launching a Google Chrome browser on an Android

I have created a basic code snippet to launch Google Chrome browser on an Android device, navigate to a specific URL, and then close the browser. Here is the code: package com.roofandfloor.initial; import java.net.MalformedURLException; import java.net ...

What is the process for altering fonts in a Chrome OS application?

After extensive research on the Internet, I have been unable to find clear instructions on how to modify the text font in a Chrome OS application. Most search results pertain to adjusting the font for the OS user rather than the developer of the app. My i ...

Is it possible to refresh resources in Node.js without the need to restart the server?

Is there a middleware or library that allows access to files added after the server starts without requiring a restart? I currently use koa-static-folder, but it seems unable to handle this functionality. ...

Pug conditional elements not styling with CSS

Currently immersed in the world of Pug, node.js, and express as I build a web application. Facing hurdles when trying to style elements within Pug conditionals using CSS. For instance, consider this Pug snippet: div(id='outside') if authoris ...

Navigating vertically in an AngularJS application

When viewing the data in a single line, I am able to scroll horizontally. However, I would like the content to wrap so that when it reaches the end of the page border, it continues on the next line. Could you please assist with this? ...

What is the best way to make img-fluid function properly within Bootstrap Carousel?

I've been struggling to make my carousel images responsive by using the img-fluid tag, but I haven't had any success. I've attempted using !important and display: block, but nothing seems to work. I'm not sure what's causing the is ...

Launch a modal from a separate webpage

I've been trying to implement a modal using Bootstrap 4, and after referring to the documentation, it seems to be working smoothly. <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/> <scri ...

What could be causing this code to malfunction on jsfiddle?

Why doesn't this code from W3schools work on jsfiddle? I tried to implement it here: https://jsfiddle.net/u6qdfw5f/ <!DOCTYPE html> <html> <title>W3.CSS</title> <meta name="viewport" content="width=device-width, initial ...