Arrange the elements on a website using a Bootstrap 4 grid layout, first with a row containing three columns, followed by a single column filling the

I am working on implementing a bootstrap layout for my razor page that should look like this:

row

.col-8

.col-3 [nested]

.col-9 [nested]

.col-4

row

.col

|---|-----|----|

| ------------ |

Here is what I have currently:

https://i.sstatic.net/28l91.png

The green background represents row 1, while the orange color represents row 2.

I believe the issue with row one's display is due to this code:

<div class="row" style="height:100vh;background:green">

Changing row to this resulted in an undesired layout:

<div class="row" style="background:green">

My goal is to make the third column (large content) match the height of the left-hand column without hard coding it. Using vh-100 solved it but created a gap between the rows.

I want to adhere to best practices and not set a specific max-height constraint on the column.

Any advice or suggestions would be appreciated.

Here is the complete cshtml code I'm working with:

<div class="row" style="height:100vh;background:green">

    <div class="col-8 h-50">

        <div class="row h-100">

            <div class="card col-3 border-right-0 rounded-0">

                <img <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="aad9d8c997ead9ded8c3c4cd84ecc5d8c7cbde">[email protected]</a>("URI/{0}?height=250", Model.UserDisc.EmployeeId0) style="object-fit:cover;width:100%">

            </div>

            <div class="card col-9 rounded-0">

                <ul class="list-group list-group-flush">

                    <li class="list-group-item">@assocname</li>

                    <li class="list-group-item">@Model.UserDisc.Title0</li>

                    <li class="list-group-item">@Model.UserDisc.TelephoneNumber0</li>

                    <li class="list-group-item">@Model.UserDisc.EmployeeId0</li>

                    <li class="list-group-item">@Model.UserDisc.Sid0</li>

                    <li class="list-group-item">@Model.UserDisc.PhysicalDeliveryOfficeNam0</li>

                    <li class="list-group-item">@Model.UserDisc.HomeDirectory0</li>

                    <li class="list-group-item">

                        @if (!(Model.UserDisc.UserAccountControl0 == 512))

                        {

                            <a href="#" class="badge badge-danger">AD ACCOUNT: LOCKED</a>

                        }

                        else

                        {

                            <a href="#" class="badge badge-info">AD ACCOUNT: GOOD</a>

                        }

                    </li>

                    <li class="list-group-item">

                        Manager: @mg

                        <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModalLong">

                            View Direct Reports

                        </button>

                    </li>

                </ul>

            </div>

        </div>

    </div>

 

 

    <div class="col-4 h-50" style="overflow-y:auto">

        @{

            String isSearching = "visible";

            if (Model.CurrentFilter?.Length > 1)

                isSearching = "disabled";

            else

                isSearching = "visible";

        }

 

 

        <input class="form-control" id="myInput" type="text" placeholder="Search..">

        <div>

            Total Groups: @Model.UserGroupMembership?.Count

        </div>

        <table id="myTable" class="table table-bordered table-striped mb-0">

            <thead>

                <tr>

                    <th>Groups</th>

...

<td>

                        @Html.DisplayFor(modelItem => item.CNIsOnline)

                    </td>

                    <td>

                        @Html.DisplayFor(modelItem => item.CNLastOnlineTime)

                    </td>

                </tr>

            }

        </tbody>

    </table>

</div>

UPDATE:

I adjusted the right column table div as follows:

<div class="wub" style="overflow-y:auto;max-height:50vh;overflow-x:hidden">

Realized using anything other than 100vh works for that property.

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

Answer №1

When working on your table in HTML, pay attention to the quotes:

<table id="myTable" class="table table-bordered table-striped mb-0" ">

If you copy and paste this into a jsfiddle, you'll see the issue highlighted.

(problem) https://jsfiddle.net/tive/gya9zu2k/1/ (ln: 103)


I recommend keeping the column structure separate from the content.

  1. Remove the 100vh from the first row.
  2. The h-50 or h-100 classes should be applied to the content inside a column.
  3. Utilize a wrapper for dynamic height within groups.
  4. For the card layout, the card should be placed inside a column instead of making the column a card. It's important to avoid mixing structure and content.

<div class="your-wrapper" style="overflow-y:auto;max-height:100vh;">
    <table id="myTable" class="table table-bordered table-striped mb-0"></table>
</div>

VIEW DEMO

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

What is the best way to display a horizontal list when a link is clicked?

Is it possible to add a "share" link similar to the one in the lower right corner of this page: I have attempted several times to achieve this using CSS only, but without knowledge of javascript/jquery, I am limited in what I can accomplish. Thank you fo ...

Adding a touch of flair to your Vue-i18n parameter

If the template has the following translation: <p> {{ $t('Counter: {n}', {n: counter}) }} </p> where counter is a number returned from the script, I want to style the variable "n" (for example, make it red). Is there a way ...

Tips for creating a stylish scrollbar in a React Material-Table interface

Currently, I am utilizing the react material-table and looking to implement a more visually appealing scroll-bar instead of the default Pagination option. Although I have experimented with the react-custom-scroll package, it has not produced the desired ...

Text transitions in a gentle fade effect, appearing and disappearing with each change

I want to create a smooth fade in and out effect for the text within a div when it changes or hides. After researching on Google and Stack Overflow, I found that most solutions involve adding a 'hide' CSS class and toggling it with a custom func ...

What causes a 404 error when a GET response is returned in a Node.js server?

Having some issues with my server setup. I have a server.js file running on node js. When I try to access the CSS and JS files linked in my index.html, I keep getting 404 errors even though the files are present in the specified path. I suspect there might ...

Introducing a variety of sub-menu fonts within an elegantly designed jQuery vertical accordion menu

I am struggling to achieve different font sizes, colors, and weights for top and sub-menu level links in my simple jQuery vertical accordion. Despite changing the CSS, I can't seem to get it right. What am I missing? Is there an easy way to accomplish ...

What is the best way to set this to display in line?

I'm in need of some assistance to troubleshoot an error I encountered while attempting to showcase a list in a single line, unfortunately it didn't work out as planned. #main-nav ul ul li { display: inline; } Despite setting the display to inli ...

I am having trouble getting my textarea to accept width attributes

Strangely, the text area on my website just won't cooperate with the width I specify. I've double-checked the CSS multiple times to no avail! Take a look at this jsfiddle example that demonstrates what I'm trying to achieve. However, on my ...

consistent character spacing for a custom font upload

Developing an application that necessitates counting up and opting for the font Orbitron due to its square appearance. The issue arises as, unlike the default chrome font, the width of this font's digits is not consistent, causing the count character ...

A guide to using JavaScript to restrict the textarea's height while allowing it to expand dynamically and setting a maximum height

Seeking assistance with a challenge I have encountered and unsure how to resolve. Any help would be greatly appreciated! The issue at hand is as follows: I am currently working on a textarea. My goal is to have the input box start with a height of 36px, ...

The Dilemma of Hover Effects in Internet Explorer 7

How can I make an image display another image with 4 absolutely positioned links when hovered over? The code currently works in Chrome, Firefox, Safari, and all versions of IE except IE7. Any suggestions for IE7 compatibility? For reference, here is the J ...

Mastering the Art of Harnessing External Templates in Meteor Mantra

I have been diving into the Mantra style guide () in order to integrate it with meteor. What confuses me is determining the "right" approach for using external templates with meteor and mantra. Specifically, I'm unsure about handling CSS and JS files. ...

What is the best way to apply CSS exclusively to a single element on a webpage?

As an illustration, I desire the following: <link rel="stylesheet" href="stylus.css"> specifically for this snippet of code: <a href="yeet">Buy!</a> ...

"Utilizing a custom CSS style for a half heart rating system

I am currently working on implementing a rating system using the font-awesome fa-heart class. While I have successfully colored the full heart, I am facing difficulty in filling only the first half of the heart in red. Despite my research efforts, all solu ...

Modifying the Collapse Direction of Navigation in Bootstrap 4

Is it possible to change the collapse direction of the Bootstrap 4 navbar from 'top to bottom' to 'right to left'? Here is the code snippet I am currently using: <nav class="navbar navbar-light bg-faded"> <button class="na ...

What is the process for using a click event to redirect to a different page on a website?

Currently, I am working with vue-bootstrap and I have a set of cards, each containing a button. I want each of these buttons to redirect me to a different form, but I am struggling with implementing this functionality. Below is the snippet of my code: < ...

Enhance the appearance of your responsive embedded video with a stylish border

I'm attempting to give a decorative border to a flexible embedded video. I've experimented with two different techniques to display the video: 1. <div class="embed-responsive embed-responsive-16by9"> <iframe class="embed-responsiv ...

Pressing the menu button will trigger a function that halts after the third click

As I attempted to implement the functionality of this left menu bar, I encountered a roadblock. The click event on the menu button seems to work fine initially - the left bar appears with the first click and closes as expected with the second click. Howeve ...

Issue with JavaScript functionality after relocation to an external .js file

Initially, I had a JavaScript code in my HTML page. However, I decided to move the script to an external JavaScript file named jful.js. <script type="text/javascript> $(function() { // Determine the initial top offset of the navigation bar ...

Utilizing a wildcard as a variable

Is there a more efficient way to consolidate all twenty rules into one using wildcards: .margin-bottom-1rem { margin-bottom: 1rem; } .margin-bottom-2rem { margin-bottom: 2rem; } ... .margin-bottom-20rem { margin-bottom: 20rem; } I have searched f ...