What is the best way to have every other row in a table expand to fill all of the cells?

My database log table contains information, and clicking a button reveals additional details about a specific log item. However, when the "info" button is clicked (refer to the image below), the displayed information only occupies the width of the "message" column rather than the entire table.

The issue here is that the loaded content does not expand to cover all the cells in the row.

To summarize: How can I make my row span across all the cells' widths?

https://i.sstatic.net/yEnB4.png

_LogPartialLayout.cshtml

<div class="table" id="logtable">
    <div class="row">
        <div class="cell" id="tableth">
            message
        </div>
        <div class="cell" id="tableth">
            timestamp
        </div>
        <div class="cell" id="tableth">
            level
        </div>
        <div class="cell" id="tableth">
            customerName
        </div>
        <div class="cell" id="tableth">

        </div>
    </div>

    @foreach (var item in Model.Logs)
    {
        <div class="row">
            <div class="cell" id="tabletd">
                @Html.DisplayFor(modelItem => item.message)
            </div>
            <div class="cell" id="tabletd">
                @Html.DisplayFor(modelItem => item.timeStamp)
            </div>
            <div class="cell" id="tabletd">
                @Html.DisplayFor(modelItem => item.level)
            </div>
            <div class="cell" id="tabletd">
                @Html.DisplayFor(modelItem => item.Name)
            </div>
            <div class="cell" id="tabletd">
                <input type="button" id="extra-info-button" name="answer" value="Info" onclick="showDiv(@item.id.ToString())" />
            </div>
        </div>
        <div class="row">
                <div id="@item.id.ToString()" style="display:none;" class="answer_list">
                    <strong>Uri:</strong><br /> @item.Uri <br /><br />
                    <strong>Method:</strong><br /> @item.Method <br /><br />
                    <strong>HttpStatus:</strong><br /> @item.HttpStatus <br /><br />
                    <strong>RequestHeaders:</strong><br /> @item.RequestHeaders <br /><br />
                    <strong>RequestContent:</strong><br /> @item.RequestContent <br /><br />
                    <strong>ResponseHeaders:</strong><br /> @item.ResponseHeaders <br /><br />
                    <strong>ResponseContent:</strong><br /> @item.ResponseContent <br /><br />
                </div>
        </div>
    }
</div>

StyleSheet.css

.table { display: table; }
.row { display: table-row; }
.cell { display: table-cell; }

.answer_list{
    font-family: monospace;
    text-align:left;
    -ms-word-break: break-all; /* Warning: Needed for oldIE support, but words are broken up letter-by-letter */
    word-break: break-all;
    word-break: break-word; /* Non standard for webkit */
    -webkit-hyphens: auto;
    -moz-hyphens: auto;
    -ms-hyphens: auto;
    hyphens: auto;
    border-left: solid 1px black; 
}

Answer №1

To make a table cell span multiple columns, use the colspan attribute.

UPDATE: It appears that instead of using a <table>, you are misusing the <div> element as if it were a table.

I urge you to update your HTML and utilize <table> for data tables, which is how it is designed:

<table id="logtable">
    <thead>
        <tr>
            <th>message</th>
            <th>timestamp</th>
            <th>level</th>
            <th>customerName</th>
            <th></th>
         </tr>
     </thead>
     <tbody>
 @foreach (var item in Model.Logs)
 {
        <tr>
            <td>@Html.DisplayFor(modelItem => item.message)</td>
            <td>@Html.DisplayFor(modelItem => item.timeStamp)</td>
            <td>@Html.DisplayFor(modelItem => item.level)</td>
            <td>@Html.DisplayFor(modelItem => item.Name)</td>
            <td><input type="button" id="extra-info-button" name="answer" value="Info" onclick="showDiv(@item.id.ToString())" /></td>
        </tr>
        <tr>
            <td id="@item.id.ToString()" style="display:none;" class="answer_list" colspan="5">
                    <strong>Uri:</strong><br /> @item.Uri <br /><br />
                    <strong>Method:</strong><br /> @item.Method <br /><br />
                    <strong>HttpStatus:</strong><br /> @item.HttpStatus <br /><br />
                    <strong>RequestHeaders:</strong><br /> @item.RequestHeaders <br /><br />
                    <strong>RequestContent:</strong><br /> @item.RequestContent <br /><br />
                    <strong>ResponseHeaders:</strong><br /> @item.ResponseHeaders <br /><br />
                    <strong>ResponseContent:</strong><br /> @item.ResponseContent <br /><br />
                </td>
        </tr>
    }
    </tbody>
</table>

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

How can I stretch Button width to 100% when the bootstrap navbar is toggled?

I am looking for a way to toggle navigation buttons in order to occupy the entire width. Currently, the buttons do not fill all available space as shown in this example on jsfiddle: example in jsfiddle Here is the code I am using: <div class="coll ...

Phonegap Application: Page design gets distorted following keyboard input

After a user enters login details and the next page loads, the layout shifts as shown in the image below. The entire app layout breaks and the view moves down to accommodate the size of the onscreen keyboard. This issue persists unless the orientation is ...

Using jQuery to validate texts that are created dynamically

In my current code, I have a functionality that displays all invoices under a specific catalogue. When the user changes the selection in the dropdown menu for catalogues, the table should update to show only the invoices related to the selected catalogue. ...

Switch the dropdown icon in ng-bootstrap when clicked

Click me to switch icon from fa-angle-up to fa-angle-down. Initially displaying the fa-angle-up icon, clicking it will change it to fa-angle-down. <div class="col text-right"> <div ngbDropdown placement="top-right" class="d-inline-block"> ...

Update the styling for the second list item within a specified unordered list class instantaneously

Looking to emphasize the second list item (li) within a selected dropdown list with a designated unordered list class of "chosen-results". <div class="chosen-container chosen-container-single select-or-other-select form-select required chosen-proc ...

What is the best way to eliminate the space between the website's border and the image?

Is there a way to eliminate the space between the left and right borders? I want the picture to fill 100% of the browser window. https://i.stack.imgur.com/gqgOs.png img.test { display: block; outline: 0px; padding: 0px; margin: 0px; } <img c ...

Is there a way to narrow down the font choices using HTMLPurifier?

- Currently in my project, I have incorporated an HTML-WYSIWYG Editor that allows users to utilize various Webfonts for styling their texts. The editor I am utilizing can be found at NiceEdit. It generates code snippets such as: <font face="c ...

Button outline appears upon clicking the link and remains until another area of the page

I have always been curious about a particular situation: Imagine you have a one-page website with a navigation menu. When a user clicks on a navigation link, it scrolls to that section of the website. However, after clicking, the navigation link remains v ...

Adjust Font Size inside Circular Shape using CSS/jQuery

I have been searching for different libraries that can resize text based on the size of a container. However, my container is circular and I am facing difficulty in preventing the text from overflowing beyond the border. Below you will find a Fiddle conta ...

Get Code Now Button

I operate a website dedicated to Amazon reviews, and I am in need of a button that can request a code from a text file uploaded by the seller. My question is how can this be achieved using HTML? I have been experimenting with this sample: <!-- Butt ...

How can I turn off automatic ellipsis on my IOS device?

Currently, I am working on a web application that involves displaying location descriptions retrieved from an API. The issue I am encountering is that the description is being cut off with an ellipsis after a certain number of lines when viewed on an iPhon ...

Slow and choppy animations with jQuery

I've been struggling with a slow and choppy jQuery animation despite trying various techniques to improve its speed. I've attempted stopping existing animations before starting new ones, ensuring animations are only performed when necessary, and ...

Extracting JSON data in PHP and presenting it in a tabular format

Below is a snippet of my HTML code, <html> <head> <script src="js/jquery.js"></script> </head> <body> <input type="text" name="query" id="queryBox"> <button id="load_basic" value = "button">search</but ...

`Is it possible to remove an empty frame using javascript?`

I have this script that generates a "layer" resembling a frame and I need to remove it. Here is the code for creating the layer: function disableLayer() { var layer = document.getElementsByTagName('div')[0]; d = document.createElement(& ...

Large nav-stack that transitions to a horizontal layout when below 768px wide

I'm currently utilizing TBS and have configured my layout with three columns: a vertically stacked navigation on the left, main content in the center, and a Twitter feed on the right. My goal is to have the navigation display as stacked on larger scre ...

Modifying data-* attributes with jQuery through contenteditable

I am currently developing basic rich text editing functionality for a client by utilizing contenteditable. One specific feature involves changing the values of data-* attributes within a button, like this example: <button data-type="telephone">Text&l ...

"Duration parameter in jQuery animate() function not working as expected in Firefox

Just starting out with jQuery and I have a class for absolute centering (it's working as intended): .Absolute-Center { margin: auto; position: absolute; top: 0; left: 0; bottom: 0; right: 0; } #logo { background: url(logo.png) no-rep ...

"Implementing a fixed header and footer with a scrolling content area within a parent div that has a fixed position for

I'm seeking assistance with some CSS tasks. Specifically, I need to maintain the same functionality in responsive view when utilizing a fixed position in the parent div (Bootstrap 5 is in use). (the main focus of this project is on fullscreen view of ...

Creating a layout of <video> components in vue.js, complete with the ability to rearrange and resize them through drag and drop functionality

Despite trying numerous libraries and Vue.js plugins, I have yet to find one that meets all of my requirements. I am in need of creating a grid of video HTML elements that are draggable and resizable with a consistent aspect ratio of 16:9. Additionally, I ...

Creating a dual-row HTML table heading

Looking to create a table with a two-row header - the first row containing a search input box and the second row containing column names. Here's what I have so far: <thead> <tr class="bg-primary"> <th colspan="5"> ...