Challenges with Html design

Hey there, I've got this HTML and CSS structure that I'm working on. My goal is to have all four divs in one line. Can someone please take a look and let me know what I might be doing wrong?

Here's an example: https://jsfiddle.net/0ynnfmo5/

<body>
    <div class="listItem">
        <div id="detailsName" class="detailsName">
        </div>
        <div class="detailsDate">
        </div>
        <div class="status">
        </div>
        <div class="button">
        </div>
    </div>
</body>

` .listItem{ position:absolute; display: table; padding:3px; width:70%; height:60px; background-color: #28b4ea; color:#ffffff; border-style: none; min-height:60px; }

.listItem .detailsName{
    position: relative;
    display: table-cell;
    left:0px;
    height:56px;
    min-height: 56px;
    width:100%;
    background-color: #000;
}

.listItem .detailsDate{
    position: relative;
    float:left;
    display: table-cell;
    height:56px;
    width:150px;
    background-color: #fff;
}

.listItem .status{
    position: relative;
    float:left;
    display: table-cell;
    height:56px;
    width:150px;
    background-color: #ddd;
}

.listItem .button{
    position: relative;
    float:left;
    display: table-cell;
    height:56px;
    width:150px;
    background-color: #aaa;
}`

Answer №1

Avoid using both display:table-cell and float

.listItem {
  position: absolute;
  display: table;
  table-layout: fixed;
  padding: 3px;
  width: 70%;
  height: 60px;
  background-color: #28b4ea;
  color: #ffffff;
  border-style: none;
  min-height: 60px;
}
.listItem .detailsName {
  position: relative;
  display: table-cell;
  height: 56px;
  min-height: 56px;
  background-color: #000;
}
.listItem .detailsDate {
  position: relative;
  display: table-cell;
  height: 56px;
  width: 150px;
  background-color: #fff;
}
.listItem .status {
  position: relative;
  display: table-cell;
  height: 56px;
  width: 150px;
  background-color: #ddd;
}
.listItem .button {
  position: relative;
  display: table-cell;
  height: 56px;
  width: 150px;
  background-color: #aaa;
}
<div class="listItem">
  <div id="detailsName" class="detailsName"></div>
  <div class="detailsDate"></div>
  <div class="status"></div>
  <div class="button"></div>
</div>

Note: It is advisable to use media queries for adjusting the layout when the wrapping div is not wide enough for all the divs (such as in the mini-view below).

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

Trigger the running of a python script by clicking a button

On my HTML page, there is a single button that is supposed to trigger the execution of a python script upon being clicked. The goal is to receive the result of the script and display it on the same HTML page. The process involves validating the return val ...

Looping CSS text animation with typing effect

I am struggling with a CSS code that types out text, but it only does so once and I need it to repeat infinitely. Despite adding animation-iteration-count: infinite;, it still doesn't work as intended. Another issue is that it slows down at the end. H ...

What's the trick to making a column that's 2/3 wide in a 34grid layout?

Is it possible to use the 34 Responsive Grid system to create a column that takes up two-thirds of the full width? Although the Grid System has equal columns settings, I'm curious how to combine or merge two columns together? <div class="containe ...

What are the reasons behind the issues encountered when enabling "Optimization" feature in Angular that affect the proper rendering of PrimeNg elements?

Angular Version : 9.x Primeng Version : 9.x We've encountered an issue with PrimeNg elements not rendering correctly in our dev/prod environments, although they work fine in the local environment. After some investigation, we found that the culprit ...

Simply upload a file and send it to a specific URL by using the drag and drop functionality in HTML

After successfully implementing the drag and drop functionality, my next challenge is figuring out how to upload and post the file to a URL with specific parameters. Usually, if I had a form available, I could do it like this: <form enctype="multipart ...

Pagination dropdown placement appears to be misplaced in the material design

Issue I am currently facing a challenge while incorporating a <mat-table> with a <mat-paginator> in my project. The issue lies in the positioning of the items per page dropdown, which appears to be offset to the left and seemingly outside the ...

Can file input be saved using only JQuery?

I'm currently developing a Chrome Extension which requires the user to upload an audio file on the options.html page. Due to restrictions, I am unable to utilize PHP in writing this extension. Hence, I am seeking advice on how to save the uploaded aud ...

ng-bind-html is having trouble parsing the HTML correctly and binding it

Here is the code for my controller: myApp.controller('actionEditController', ['$scope', '$stateParams', '$sce',function ($scope, $stateParams, $sce) { $scope.table="<p>OOPSY</p>"; $sc ...

Learn how to display a web page in a tab view similar to the toggle device toolbar option

Is it possible to simulate the toggle device toolbar of a web page using JavaScript? https://i.stack.imgur.com/M9oB0.png For example, can we set up a webpage to always display in tab or mobile view like on YouTube? ...

How can I give an HTML form input button the appearance of glowing or lighting up like the default OS style?

Is it possible to make the <li><FORM><INPUT class="eButton" type="button" value="Ole"></FORM></li> class glow or light up to notify the user about something, while maintaining the default OS look on Linux, Mac, and Windows? F ...

Is there a way to adjust the image dimensions when clicked and then revert it to its original size using JavaScript?

Is there a way to make an image in an HTML file change size by 50% and then toggle back to its normal size on a second click using JavaScript? I've attempted to do it similar to the onmouseover function, but it doesn't seem to be working. Any sug ...

jQuery Failing to Work

I'm experimenting with creating a falling effect for a DIV element when a piece of text is hovered over. The original effect can be seen here. var $dropDiv = $('#dropDiv'); $('#holder p').on('hover', function () { // ...

What is the best way to split a single column into two using blocks?

I am working with a container that currently has all its blocks lined up in a column. I need to divide them into two columns, with 5 blocks in each. Unfortunately, the plugin I am using generates the code for me and does not allow me to insert my own div e ...

Trouble with jQuery addClass function when trying to add to a specific object variable

I'm attempting to give an error class to an input textbox to inform the user that their input is invalid. Within the change event, I am referencing what seems to be the input field and storing it in a variable. However, calling addClass on the var ...

Troubleshooting a navigation problem with DNN and Bootstrap-3 specifically for mobile devices

Here are the steps to demonstrate this issue: 1. Visit the following page of the website: 2. Resize your browser window to mobile size and close the menu using the icon. After the animation finishes, the navigation items reappear. I have been struggling ...

How can I retrieve information from an HTML or JavaScript object?

Imagine a scenario where you have an HTML table consisting of 5,000 rows and 50 columns, all generated from a JavaScript object. Now, suppose you want to send 50 checked rows (checkbox) from the client to the server using HTTP in JSON format. The question ...

The jQuery menu is malfunctioning in Internet Explorer due to the Document Mode being set to Quirks

I am encountering an issue where the below code is not functioning properly in Internet Explorer's document mode quirks. Each time I hover over the submenu, its length doubles unexpectedly. Can someone please provide assistance with this matter? < ...

What is the best way to add a unique style to a third-party component within a React component without impacting the styles of other components?

While working with a dropdown component from react-bootstrap, I encountered a situation where I needed to change the font size of the context menu in just one specific component. To achieve this, I decided to create a separate css file named panel.css and ...

best method for embedding javascript code within html (within a script tag)

In my quest to create dynamic HTML using jQuery and insert it into a specific div on my website, I encountered an issue. Specifically, I am attempting to generate an anchor element where both the href and label are determined by JavaScript variables. Here ...

Utilize JavaScript to iterate through a JSON object and retrieve the indices that meet the specified criteria

While I found a previous answer that somewhat addresses my issue, I am seeking guidance on how to return an array of the indexes where a specific value appears. For example, if **18A38** is the target value, it should return the positions [1,3]. The sampl ...