Beginner in Bootstrap CSS - basic code for a 5x5 grid containing nested grids in every "cell"

I am currently in the process of developing a seating chart application that I envision to look similar to this design: https://i.sstatic.net/vZ5Au.png

While exploring different options, I have some concerns about whether it can be fully accomplished using Bootstrap. One limitation I have come across is that the BS "container" class cannot be nested. Additionally, my goal is to have the entire chart automatically adjust to fit both the width and height of the viewport. My current approach involves utilizing a 5x5 HTML table with a BS grid inside each td element. However, I am facing challenges with aligning the elements correctly within the space provided (indicated by red bars in the diagram). Moreover, fitting all elements within the designated "row" (utilizing the BS "row" class) has proven to be problematic.

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

<td style="white-space:nowrap">
        <div class="row">
            <div class="col-xs-3"><input id="39638" type="text" value=""></div><div class="col-xs-3"><label id="39638pc"><?php echo $part['39638'] ?></label></div>
            <div class="col-xs-3"><input id="39638bt" type="text" value=""></div><div class="col-xs-3"><label id="39638bc"><?php echo $part['39638'] ?></div></label></div>
        </div>
        <div class="row">
            <div class="col-xs-12"><label class="name-label">Opas</label></div>
        </div>
        <div class="row">
            <div class="col-xs-4"><button class="btn btn-primary" type="button" onclick="participate(39638)">Good</button></div>
            <div class="col-xs-4"><button class="btn btn-primary" type="button" onclick="behave(39638)">Bad</button></div>
            <div class="col-xs-4"><button class="btn btn-primary" type="button" onclick="comelate(39638)">Late</button></div>
        </div></td>

In my style.css:

    table {
    font-family: arial, sans-serif;
    border-collapse: collapse;
    width: 100%;
}

td, th {
    border: 1px solid #dddddd;
    text-align: left;
    /* padding: 8px; */
}

.row .col-xs-3 {
    display: inline-block; 
    float: none;
    padding-left: 5px;
    padding-right: 5px;
}

.row .col-xs-4 {
    display: inline-block; 
    float: none;
    padding: 0;
}

.row .col-xs-3 input, .row .col-xs-3 label {
    width: 100%;
    text-align: center;
    background-color: pink;
}

.row .col-xs-4 button {
    width: 95%;
    padding: 0;
    margin: 0;
}

td .row {
    margin: 0px;
}

.name-label {
    width: 100%;
    font: bold 14px calibri, sans-serif;
    text-align: center;
    margin: 0;
    padding: 0;
}

Answer №1

Utilizing Bootstrap makes it feasible. You do not have to nest multiple containers; simply nest the rows and columns.

Working with a 5x5 grid can be a bit challenging, as 12 is not evenly divisible by 5. However, there is an elegant solution to that dilemma here.

Provided below is the HTML code.

Also included is the CSS.

See how it appears:https://i.sstatic.net/Sg6xf.png

The key techniques used involved utilizing the BS "text-center" class and employing display: table-row; and display: table-cell; in the css.

If only I could find a way to vertically center the elements...

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 are the steps to enlarge the logo in the header of a WordPress website?

I recently added a logo to my website located at www.theestablishmenthairdressing.com, but I am encountering an issue where the logo appears very small in the top-left corner of the header. Upon inspecting the code using Safari, it seems that there is a s ...

Running a shell script in PHP and supplying inputs for any prompts

My Raspberry Pi is running an Apache server with a simple program that allows users to input a string into an HTML form. Upon submitting the form, the entry is sent to a PHP file which then calls a shell script and passes the input as a prompt. I am strugg ...

Trouble with z-index when attempting to stack forms on top of one another

Currently, I am working on creating a login page and signup page for my program. The goal is to stack them on top of each other with only one being displayed at a time. However, I am facing an issue where they are not stacking properly. I attempted using t ...

How to hide columns in Bootstrap 5 on devices smaller than a specific breakpoint size

When resizing the browser window, the navbar successfully hides, but when using the "Toggle device toolbar" in Chromium, it remains constantly visible. The issue does not appear to stem from Chromium's devtools, as testing on a mobile device (using Go ...

What exactly does '?' symbolize in pagination hyperlinks?

Hey there! I've been diving into a Django book lately and came across a pagination template with a mysterious question mark in the URL. I've looked everywhere but can't seem to find an explanation for it. Check out the template below: < ...

'Find the declaration/implementation' feature in VS Code

Recently, I made the switch from using Webstorm to VS Code as my IDE. One issue I encountered is related to editing CSS classes in Vue files. Specifically, when I use shortcuts like 'f12' and 'cmd + f12', there seems to be no way to eas ...

Non-negotiable, non-deletable component of a text field

My goal is to create a textarea with a default value that cannot be removed by the user, but they should be able to add extra text after it. <textarea>This is constant</textarea> As shown above, the textarea has a default value. How can I ...

Encountered a Socket.io issue: CONNECTION_TIMED_OUT_ERROR

I'm in the process of developing a simple HTML chat program. I've set up a node server for testing, but encountering a socket error when trying to access the HTML page. This is my first experience with Node.js and setting up a server, so it' ...

What is the best way to center numbers in a table cell while aligning them to the right?

In a table, I want to display numbers centered in a column but right-aligned as well. To achieve this: table { border: 1px solid black; } th { width: 200px; } td { text-align: center; } <table> <thead> <tr> <th& ...

Stop iPhone body scrolling when fullscreen overlay is opened

My goal is to prevent the body from scrolling when my fullscreen overlay navigation is open. I have added a class show-nav to the body with the CSS attribute overflow: hidden, which works perfectly on desktop but not on iPhones. After researching similar ...

Steps to modify the HTML content of an element using a directive

Is there a way in AngularJS to access the actual HTML content of an element that contains a directive attribute? I am not looking to modify its attributes, but rather manipulate the HTML itself. This could involve changing the element into a different type ...

Angular pagination with enhanced animation effects

I found a helpful tutorial on creating an expandable list using Angular. It's working fine, but I wanted to add an animation when the div expands or collapses. I tried adding a class with a transition in the max-height property, but it didn't wor ...

Enhance your content with stylish text additions

Can anyone help me with merging 2 pieces of text in React JS, where one part of the text has unique styling? Below is an example of the code: <div> <div> {'If you haven\'t received an email, please check your spam filte ...

Accessing the scope value in Angular JS beyond the HTTP call

I am faced with a situation where I have multiple select boxes, each requiring data from different URLs to populate them. I am trying to load the response data into these boxes using the following code: function getFilterDataUrl(category_url) { var filt ...

Forecasting text input demands

Many websites display suggestions in a drop-down menu as you type, some even showing a preview of the most likely result in a lighter-gradient font next to the cursor. For example, Spotlight on my Mac does this: https://i.sstatic.net/hDyxG.png Spotlight ...

Using jquery to update a link when a different link is clicked

Recently, I've started using JQuery and encountered a challenge. When I click on the first link, an Ajax request is sent to the server and data is received successfully. However, in the callback function, I'm struggling to change the display text ...

Having trouble properly refreshing Bootstrap scrollspy that is spying on the <body> element

I've been looking at a post on Bootstrap's scrollspy component (found here). In my code, I initialize a new scrollspy to track the body element using: $("body").scrollspy({ offset: 25 }); As my code progresses, I make AJAX requests that add or ...

When implementing CSS, the background image in the header section of my webpage is not visible to me

I'm currently working on a basic webpage and encountering an issue with setting an image as the background for my header section. Despite using what I believe to be the correct code in the CSS section, specifying the right path and file name for the i ...

Exploring the Contrasts: AppBar vs Toolbar in MUI v5

Can you explain the variations between AppBar and Toolbar in MUI? I know that AppBar defaults to 'column' flex direction, while Toolbar defaults to 'row'. Are there any other distinctions? Additionally, why do MUI docs show examples of ...

What causes jquery to malfunction when making an ajax call?

UPDATE #2: I am experiencing a similar issue to this one, although it is not related to WP: . How can I implement this with my scripts? UPDATE: The main problem arises when the page is initially loaded, everything works smoothly and ajax is not triggered. ...