Tips for expanding the grid elements on a Cartesian plane created using Bootstrap4 and Flex!

I am looking to create a Cartesian plane using Bootstrap 4 and Flex. The end goal is to achieve a layout similar to the image linked below:

https://i.sstatic.net/THmwV.jpg

The plane will consist of a 10x10 grid, with a row for the x labels and a column for the y labels.

Below is the code I currently have:

<div class="d-flex p-2" style="border: 1px solid black; width: 40%; margin-bottom: 50px;">
    <div class="d-flex flex-row">
        <div class="p-2 align-items-stretch">1</div>
    </div>
    <div class="d-flex flex-column">
        <div class="p-2">1</div>
        <div class="p-2">2</div>
        <div class="p-2">3</div>
        <div class="p-2">4</div>
        <div class="p-2">5</div>
        <div class="p-2">6</div>
        <div class="p-2">7</div>
        <div class="p-2">8</div>
        <div class="p-2">9</div>
        <div class="p-2">10</div>
        <div class="p-2 align-items-stretch">11</div>
    </div>
    <div class="d-flex flex-column">
        <div class="p-2">1</div>
        <div class="p-2">2</div>
        <div class="p-2">3</div>
        <div class="p-2">4</div>
        <div class="p-2">5</div>
        <div class="p-2">6</div>
        <div class="p-2">7</div>
        <div class="p-2">8</div>
        <div class="p-2">9</div>
        <div class="p-2">10</div>
    </div>

    <!-- code for the remaining rows goes here -->
</div>

Here is the CSS associated with this structure:

.p-2 {
    border: 1px solid lightgray;
}

.p-2:before {
    content:'';
    float:left;
    padding-top:100%;
}

The current output can be viewed at the following link: https://i.sstatic.net/lU4JB.png

There are two main issues that I am facing:

  1. The 11th row should stretch to cover the entire last column;
  2. The grid items need to adapt their size based on the available space within the container.

How can I address these problems? Thank you!

Answer №1

To implement a responsive layout, you can utilize the Bootstrap grid system in the following manner...

Check out this demo:

<div class="container text-center">
    <div class="row">
        <div class="col-md-8 mx-auto">
            <div class="row">

                <div class="col-1">y</div>
                <div class="col-11">
                    <div class="row">
                        <div class="col">1
                        </div>
                        <div class="col">2
                        </div>
                        <div class="col">3
                        </div>
                        <div class="col">4
                        </div>
                        <div class="col">5
                        </div>
                        <div class="col">6
                        </div>
                        <div class="col">7
                        </div>
                        <div class="col">8
                        </div>
                        <div class="col">9
                        </div>
                        <div class="col">10
                        </div>
                    </div>
                    <!--/row-->
                    9 more rows ...

                    <div class="row">
                        <div class="col">x
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--container-->
</div>

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 the $spacer variable in Bootstrap be modified?

My attempt to adjust the $spacer variable in SASS to increase margins seems to be failing. Here is my code: @import url(../node_modules/bootstrap/scss/_functions.scss); @import url(../node_modules/bootstrap/scss/_variables.scss); @import url(../node_module ...

Is there a way for me to implement this code to achieve the functionality shown in the demo link

$('select').change(function() { var sum = 0; var sum = parseInt($('select[name="bathrooms"]').val() * 25) + parseInt($('select[name="bedrooms"]').val() * 8); $("#sum").html(sum); }); <script src="https://ajax.googleap ...

Creating animations with an svg mask can be effective, however, it seems to only work properly

I have been experimenting with creating a transition effect using SVG masks and CSS. Initially, everything was working as intended, but after a few repetitions (usually 1 or 2, unpredictably), the transition effect would suddenly stop and become instantane ...

Ways to enable file/result downloads on a website using HTML

Could you please take a look at this repository: https://github.com/imsikka/ArtGallery I am looking to create a downloadable result using a download button. I can create the button, but I am unsure of how to make the file actually downloadable. Do I need ...

The effectiveness of the javascript widget is hindered by the absence of the meta viewport tag,

As I work on creating a widget to appear at the bottom of webpages, I've encountered a styling issue. The widget's display varies based on whether the webpage includes a specified meta viewport tag or not. <meta name="viewport" content="width ...

What could be causing the content to disappear when switching from flex: column to flex: row?

In the code snippet provided below, you may notice that when the screen size is less than 768px, the video and content underneath it are visible. However, as soon as the screen size exceeds 768px, the video disappears. Have you ever wondered why the video ...

Change your Bootstrap 4 navbar to a two-row layout using Bootstrap 5

Looking to update the navbar from Bootstrap 4 to Bootstrap 5 with two rows I came across this code snippet that works well for me in Bootstrap 4: https://codepen.io/metismiao/pen/bQBoyw But now I've upgraded to Bootstrap 5 and need help converting it ...

Set a maximum height for an image without changing its width dimension

I am facing an issue with an image displayed in a table. The image is a graph of profiling information that can be quite tall (one vertical pixel represents data from one source, while one horizontal pixel equals one unit of time). I would like to set a ma ...

Customizing the appearance of the 'Submit' button compared to the <a href=""></a> button using CSS

I am experiencing some issues. Even though the CSS code for these two buttons is exactly the same, their appearance is different. I am unable to make the :hover or :active effects work either. My goal is to have the left 'input type="submit' but ...

Article that fills the entire screen

I am currently in the process of developing a mobile application. The issue I am facing is that the text is not aligning properly and the images are not displaying fullscreen. Additionally, I want the images to adjust automatically based on whether you are ...

"Utilize HTML to make inline-block elements appear small in size while giving the illusion of being

I have a group of inline-block elements (4 total), all arranged neatly in a single row. As the window size changes, the elements wrap to the next line accordingly. The page does not display scrollbars at the bottom until the browser width reaches the minim ...

Utilizing Jquery to Add Elements and Adjust Element Height

Encountering an unusual issue where the height of a div is not updating when content is appended to it using JQuery. To demonstrate the problem, I have created a simple JSFiddle: http://jsfiddle.net/hf66v/5/ Here is the initial HTML structure: <div i ...

What is the best way to assign a dynamic width to a block element?

In my project, I am working with 30 elements that have the class .lollipop and are styled with line-height: 30px; height: 30px;. <a class="lollipop">Random text</a> <a class="lollipop">Random text longer</a> <a class="lollipop"& ...

The image tag disrupting the spacing between lines

Here's a snippet of the css and html code: CSS: div { height:24px; line-height:24px; } HTML: <div><img src="image.png"/>Text</div> According to the code, a div should be 24 pixels high with text vertically centered after ...

Is it possible to use HTML text as a CSS selector with JavaScript?

I've been searching for a solution to this issue but haven't found anything that works for me. Check out this code on jsfiddle. Person1 and Person2 both have class="from" and the CSS selector is .from so it applies to both. However, I want it ...

Tips for hiding website content on larger screens

Is there a way to hide website content on screen sizes over 1600px and display only a message image instead? ...

Why is my column getting devoured even though it has custom content tailored to it?

In my layout, I have one column, one row, and three nested columns. Each column contains a custom-designed button instead of using the default Bootstrap button. However, there seems to be an issue where one of the columns is getting cut off. To better und ...

Looking to design a popup using CSS styles

How can I design a pop-up window using CSS for a specific div? I also want to display additional information within another div inside the popup. ...

How can I eliminate the tiny white square located beneath the scrollbar track?

`::-webkit-scrollbar{ width: 12px; } body::-webkit-scrollbar-track{ background: #f1e9e9; border-radius: 10px; margin-block: 0.1875rem; } ::-webkit-scrollbar-thumb{ background-color: #582965; border-radius: 10px; border: 3px so ...

Different option for positioning elements in CSS besides using the float

I am currently working on developing a new application that involves serializing the topbar and sidebar and surrounding them with a form tag, while displaying the sidebar and results side by side. My initial attempt involved using flex layout, but I have ...