Uniformly allocate space to all table cells

I am facing an issue with the CSS property display: table-cell; and the space between the cells. I want all cells to have dynamically the same width.

You can view the code on JSFiddle.

As you can see, the cell titled "Ausstattung & Skizze" is wider than the others. Is there a method to dynamically assign the same width to all cells?

Answer №1

To ensure consistent cell width in a table, apply table-layout:fixed; to the parent element containing display:table;

ul{
  display: table;
  width: 700px;
  table-layout: fixed;
}

This method guarantees equal widths for all cells within a row, even without specifying individual widths.

(Updated: for an example, refer to this JSfiddle http://jsfiddle.net/y7t4ujfw/)

Answer №2

ul {
  display: grid;
  grid-template-columns: auto auto auto;
}

update: remove grid-template-columns, using grid-auto-columns: 25%

Answer №3

When setting the width of an unordered list to be fixed:

li
{
    width: 25%;
}

The best practice is to use classes for li elements and then style the class accordingly.

To make a table responsive, it's recommended to use table markups. This method will ensure your table adjusts perfectly on different screen sizes.

Fiddle Example:- http://jsfiddle.net/4wsmx8t0/3/

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

Looking to implement an underline effect using CSS for the active tab that mimics the hover effect already applied

How can I ensure that the underline on active tabs (Domov) matches the hover effect on other tabs? The border-bottom currently creates a border that is lower than the hover effect, resulting in inconsistent underlines as seen on this page - (try moving ...

Leverage the geocode callback function results from Google Maps in NodeJS to render a map on the AngularJS 2 component template

Hey there, I'm currently utilizing the Google Maps Node.js client web API and want to showcase a map on my HTML views using AngularJS 2. I have a server export that sends an object to my AngularJS2 client service const googleMapsClient = require(&ap ...

Using Special Fonts in Visual Studio 2013

Encountering a small issue with Visual Studio 2013. My application, developed using html and javascript, utilizes a custom font. When attempting to run the application on a different computer that does not have the font installed, it fails to display corr ...

What are some alternative ways to arrange this main navigation bar?

Check out the website, below the map you'll find an unordered list: HTML code: <ul class="play_navigation"> <li class="active"><a href="#" class="barino_story_bottom">The Story</a></li> <li><a href="#" ...

Animated image inside clickable element (HTML, CSS)

Is there a method to embed a gif within a button and have it activate on hover? ...

I am looking to build an array that can store five numbers inputted by the user. Following that, I want to utilize a for loop to display the contents of the array. How can I accomplish this task?

Looking for help to store 5 unknown numbers in an array and then display them after the user has entered all 5 numbers. Can anyone assist me in creating an array of size 5 and using a for loop to show the numbers? Here is the code I currently have: ...

Prevent the border from shrinking upon being clicked

I'm currently working on customizing an accordion using jQuery for the animation effects. However, I am facing an issue where clicking on the accordion header causes the border around the plus sign to shrink in size as well. My goal is to only have th ...

Trouble with the mobile layout - styling with CSS

Having an issue with the mobile view CSS. Visit: Looking to shift the navigation button to the right and widen the logo without changing its height. Any assistance would be appreciated. Thank you, ...

tips on locating the next immediate downloadable cell in a table

My table includes cells with colspan and rowspan attributes. <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> <table border=1 id="mytable" > <tr><td>A1</td> <td> A2 < ...

Adjusting color schemes for Twitter Bootstrap Tooltips according to their placement

I have been attempting to customize the colors of tooltips (specifically from Twitter Bootstrap), but I am encountering some difficulties. While changing the default color was straightforward, altering the colors for .tooltip and its related definitions ha ...

Preselecting items in PrimeNG Checkbox: A step-by-step guide

How can I ensure that the already selected item is displayed upon loading this div? The code in `rp` consists of an array of type Permission with one element, which should be automatically selected. What could be causing the issue? Here is the HTML snippe ...

Issues arise when attempting to initiate a FastAPI Post Request from an HTML form action located in a separate directory

I'm trying to trigger a FastApi post method from a form submission, but I'm having trouble figuring out how to make it work across different folders. Here is the structure of my project: ├── index.html ├── assets └── backend ...

Resolving issues with a countdown timer coming to a halt

After creating a countdown timer to show 45 seconds on the screen, I attempted to control it using two buttons with JavaScript's onclick function. One button is meant to start the timer while the other stops it. While I was successful in starting the ...

The page's dimensions exceed the size of the device screen

I created this basic HTML content using React <!doctype html> <html><head><title data-react-helmet="true"></title><style type="text/css" data-styled-components="" data-styled-components-is-local="true"></style>< ...

Session availability extends to subdomains, even though it may not be visible in a physical

Currently in the process of building a website Red Sec using a single account for all subdomains: Latest Updates Community Forum Personal Blog News Feed Support Us All pages share the same layout with different content by linking them to . Below i ...

The dropdown menu appears when the user clicks on an empty area

How can I ensure that the drop-down menu is only activated when the arrow or the name is clicked? I've tried looking at similar questions but haven't found a solution. Currently, clicking anywhere next to "shop" activates the drop-down. Here&apo ...

Recreate body content with JQuery Mobile

I've been attempting to duplicate the entire HTML content within the tags. However, even though the appearance on screen is correct, none of the links are functioning.</p> <p>To view the fiddle, click here: [Here is a fiddle][1]</p> ...

Incorporating FaceBook into a PhoneGap Application

Currently, I am working on integrating Facebook into my phonegap/cordova application. To guide me through the process, I am using the resources provided in this link: https://github.com/davejohnson/phonegap-plugin-facebook-connect/ Even though I have bee ...

Placing additional text beside a nicely aligned box

I am struggling to figure out how to position text in the center left of a box that is located in the top right corner of my HTML template. <table class="label"> <tr> <td class="sign">F</td> ...

Is there a way to disable the feature of saving input values?

I am dealing with an input field that looks like this: <input name="username" placeholder="Email" type="email" autocomplete="off" /> Even though I have set the autocomplete attribute to off, the previous value still appears when I open the page: h ...