I can't get my <td> to span multiple rows using Razor syntax. Can anyone help me with this issue?

Check out this code snippet (focus on rowspan="6" - it's causing an issue:

<table>
                <thead>
                    <tr>
                        <td>Ingredient</td>
                        <td>Qty (gm)</td>
                        <td>% of Capsule</td>
                    </tr>
                </thead>
                @foreach (var i in Model)
                {
                    if (Convert.ToDecimal(i.Qty) < 0)
                    {
                        <tr>
                            <td style="border: 1px solid red; color: red;">@i.Ingredient</td>
                            <td style="border: 1px solid red; color: red;">@i.Qty</td>
                        </tr>
                    }

                    else if (Convert.ToDecimal(i.Qty) == 0m)
                    {
                        continue;
                    }

                    else
                    {
                        if (i.Ingredient.Contains("Active"))
                        {
                        <tr>
                            <td>@i.Ingredient<br />
                                <input type="text" name="@i.Ingredient" id="@i.Ingredient" /></td>
                            <td>@i.Qty</td>
                            @if (i.Percent != 0m)
                            {
                                <td rowspan="6" style="text-align: center;">@i.Percent.ToString("#.##")</td>
                            }
                        </tr>
                        }
                        else
                        {
                        <tr>
                            <td>@i.Ingredient</td>
                            <td>@i.Qty</td>
                            @if (i.Percent != 0m)
                            {
                                <td style="text-align: center;">@i.Percent.ToString("#.##")</td>
                            }
                            else
                            {
                                <td></td>
                            }
                        </tr>
                        }
                    }
                }
                <tr>
                    <td></td>
                    <td>Total %:</td>
                    <td style="text-align: center;">@Model.Sum(j => j.Percent).ToString("#.##")</td>
                </tr>
            </table>

Here's what the above code generates:

I'm trying to center align the cell with the value 9.74 within the 6 rows, as shown in the screenshot with the red arrows. What am I missing here?

Answer №1

The rowspan functionality is functioning correctly. However, the value may require vertical alignment adjustment,

<td rowspan="6" style="vertical-align:center; text-align:center;">

Please inform me if this resolves the issue.

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

When I trigger a function by clicking, I also set a timeout of 1 second. Is it possible to deactivate this timeout from within the function itself?

One button triggers a function with a timeout that repeats itself upon clicking. Here's the code snippet: function chooseNum() { let timeout = setTimeout(chooseNum, 1000); } To disable this repeating function, I attempted another function like so ...

What causes the misplacement of my @section with parameters in Laravel?

I have two PHP files named home.blade.php and customer.blade.php. My goal is to create an HTML table page with 20 rows of customer data. The table data will be fetched from the Customer model. The layout should resemble the following structure: <body> ...

Using JavaScript values retrieved from a database to dynamically adjust the options in the second dropdown menu based on the selection made in the

I am currently working on a feature that involves populating two dropdown menus with values from a database. The idea is that when an option is selected in the first dropdown, the second dropdown should dynamically display relevant values based on that s ...

Applying box-shadow to tables and collapsing borders with border-collapse property in IE!

The box-shadow property does not function properly in Internet Explorer when the table has a border-collapse: collapse style applied to it. ...

Assistance needed for Internet Explorer

When I designed a webpage in Firefox, everything looked great. However, when I opened it in Internet Explorer and resized the window to less than maximum size, half of the main div disappeared under the footer. If you want to see the issue for yourself, v ...

Using Jquery to utilize next() function along with removeClass()

https://i.sstatic.net/6xlR6.png The image above demonstrates what I am trying to achieve - when a row is clicked, it should hide, the next row turns red and clicking on that hides it too, moving on to the next available row in the sequence. $(document).r ...

Interactive bar chart that updates in real-time using a combination of javascript, html, and

Current Situation: I am currently in the process of iterating through a machine learning model and dynamically updating my "divs" as text labels. My goal is to transform these values into individual bars that visually represent the values instead of just d ...

As the page is resized or zoomed in and out, the div elements start shifting in different directions

When I apply position:absolute to prevent the elements from moving when zooming in and out of the page, they all end up congregating in one place. Can anyone help me with this issue? None of the solutions I've found have worked so far. I'm develo ...

Issues with Internet Explorer causing headaches with CSS :first-child selector malfunctioning, experiencing strange behavior when utilizing Google Web Fonts

Having some trouble with the layout of a website, particularly in IE. The issue can be observed at . When comparing the page in IE to Firefox, there are noticeable differences. Firstly, the top module on the right side is not displaying correctly in IE. I ...

Tips for implementing version control for css, js, and jsp files

I've created a single-page web application with multiple views, utilizing ng-if for rendering. These views lack headers or body sections and consist only of HTML code. Each view is managed by a separate controller, with many click functionalities han ...

The overlay menu in Jquery version 1.10.1

In a nutshell, my issue is this: I am looking to create split-buttons with a menu inside (achieved using jquery-ui as shown here: jqueryui-demo). However, I want these buttons to not impact the positioning of other elements. The second button should remain ...

Is it possible to directly add a child in HTML from nodejs?

I'm in the process of developing a chat application that requires users to select a room from a list of available rooms stored in <datalist> options, which are fetched from a SQL table on the server. Within my login.html file, users are prompte ...

What is the best way to make content stretch to 100% width when there is no content in the sidebar?

As I work on developing my custom theme for Drupal, I am seeking a solution that will allow the content width to adjust depending on the presence of a sidebar. When there is no sidebar, I want the content width to be 100%, and when a sidebar is present, I ...

Steps for adjusting the matMenuTriggerFor area so it only triggers when hovering over the arrow

Hello there! I'm currently working on adjusting the trigger area for opening the next menu panel. Right now, the next menu panel opens whenever I hover over either the title or the arrow. However, my goal is to have the menu open only when I hover ove ...

Empty Button error still occurring on button featuring an icon and labeled with aria-label

Looking for a solution: <button type="button" class="btn btn-default dropdown-toggle" aria-expanded="false" aria-label="Sort"> <i class="fa fa-arrows"></i> </button> Despite having an aria-label, this button is still flagged ...

What is the term for the visual display of a product through a photo gallery or slideshow?

Can someone help me identify what the item I'm looking for? You can click on the link to see an example of the product: sephora product example What is the technical term for the section that contains product pictures and slides? Are there any librar ...

Uncovering concealed data in job listings by utilizing BeautifulSoup

Hey there! Currently, I am enrolled in a python course and our assignment for today involves extracting job listings from this website: I have attached a screenshot of the HTML related to this task here: python jobs f12 This is what I have managed to com ...

Tips for choosing the initial paragraph within a div that has a designated class (CSS 2)

I have a <div> that contains multiple <p> elements, and I want to apply specific styling only to the first <p> within each <div> with a unique class called cnt. Please take note that this question may seem similar to others on SO, ...

Is there a way to extract a list of words from a designated element using selenium?

I have been trying to scrape the content of this webpage 10 Fast Fingers in order to extract the words that need to be typed into a list. My intention is to then input these words into a text box for typing practice. The code seems to be running fine, but ...

How to assign multiple selection values in Bootstrap's select picker

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.7.5/css/bootstrap-select ...