Bootstrap maximizes the utilization of the space in an adjacent column

I am currently working on a React project, and one of the pages includes a left sidebar that takes up 3 column spaces in the container.

The main content of the page occupies the remaining width, using an additional 8 columns.

The sidebar contains only 7-8 links, and the main content is limited to 8 columns in height. My goal is for the main content to fill up the empty space under the sidebar when its height drops below that of the sidebar, rather than continuing straight down with whitespace beneath the sidebar.

I created a mock HTML code snippet in this jsfiddle. What I need is for the main content to expand and take up the excess container space, including the area underneath the sidebar as shown in this image (please excuse the rough layout edited using Photoshop).

I have spent roughly 2 hours searching for a solution but have been unable to find one, or perhaps I am not articulating my requirements effectively.

Code:

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>;

    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.4/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">

    <style>
        .container {
            margin-top: 50px;
        }

        li {
            margin: 30px;
        }
        .main-text {
            border: 3px dashed red;
            padding: 20px;
        }
        .overflow-text {
            border: 3px solid blue;
            padding: 20px;
        }
    </style>

</head>

<body>
    <div class="container">
        <div class="row">
            <div class="col-md-3 ">
                <ul style="border: 2px solid black">
                    <li>List item</li>
                    <li>List item</li>
                    <li>List item</li>
                    <li>List item</li>
                    <li>List item</li>
                    <li>List item</li>
                    <li>List item</li>
                </ul>
            </div>

            <div class="col-md-8">
                <div class="main-text">
                    <h3>Main Content</h3>
                    <p>
                        Lorem ipsum dolor sit amet consectetur adipisicing elit...
                    </p>
                </div>

            </div>
        </div>


    </div>

</body>
`

Answer №1

It might be challenging to achieve the desired layout by separating links into one column and text into another, but you could consider placing them in separate divisions and floating the link division for larger screens.

.container {
    margin-top: 50px;
}

li {
    margin: 30px;
}

.main-text {
    border: 3px dashed red;
    padding: 20px;
}

.overflow-text {
    border: 3px solid blue;
    padding: 20px;
}
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6a0805051e191e180b1a2a5f445a445a47080f1e0b58">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
        <div class="row">
            <div class="col-md-12">
                <div class="float-md-start me-md-3">
                    <ul class="mb-1" style="border: 2px solid black">
                        <li><a href="https://google.com">List item</a></li>
                        <li><a href="https://google.com">List item</a></li>
                        <li><a href="https://google.com">List item</a></li>
                        <li><a href="https://google.com">List item</a></li>
                        <li><a href="https://google.com">List item</a></li>
                        <li><a href="https://google.com">List item</a></li>
                        <li><a href="https://google.com">List item</a></li>
                    </ul>
                </div>
                <div class="main-text">
                    <h3>Main Content</h3>
                    <p>
                        Lorem ipsum dolor sit amet consectetur adipisicing elit ...
                    </p>
                </div>
            </div>
        </div>;
    </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

Parsing HTML with a simple DOM parser

I am utilizing the simple php dom parser in my project. Within my loaded dom, there is a link that appears like this in html: <a href="...">Some const tesxt</a> I am wondering how I can utilize the find function to select this particular obje ...

The div background image in Vue.js is displaying a 404 not found error

I've encountered an issue while trying to set a background for a div. Strangely, when using the same relative path with an img tag everything works fine, but as soon as I try to achieve the same result with a div, I receive a 404 error. This img tag ...

Is there a way to prevent automatically scrolling to the top of the page when submitting a form?

Resolved! By enclosing the input tag within an anchor tag, the issue has been resolved. The question may appear confusing at first, so let me provide some clarification. I created a mail form using PHP. This form is located at the bottom of the page. Whe ...

Using React.js to dynamically change a CSS class depending on a certain condition

I am trying to assign a CSS class to a div based on a specific condition. The issue I am facing is that it always takes the last condition. Below is the code snippet: When I run the code, I receive logos.length as 3 <div className= "${ (this.state. ...

How to Alter the Color of a Hyperlink in HTML

I've been working on an angular2 application and I'm using a hyperlink to trigger a method that opens a small popup window. I've tried different methods to change the color of the link when it's clicked, but so far none have worked. Th ...

Tips for achieving uniform spacing between three buttons in a horizontal alignment using bootstrap 3

Is there a way to make buttons enclosed in a <div> with class="row" and each button having class="span4" only as wide as the text it contains, centered at 25%, 50%, and 75% of the width of the screen? [aaa] [bbb] [ccc] not [ aaa ][ bbb ][ ccc ] ...

Capybara - Navigating a page by clicking on a link related to another value

I'm currently facing a challenge in locating and selecting a particular link on a web page. All links within an HTML table contain the term 'Edit' (it's a link for editing configuration settings). However, the exact link changes depend ...

Utilizing unique symbols to dynamically add form elements to an HTML page with jQuery's append method

I am facing an issue with creating forms on my HTML page. Here is an example of how I am trying to do it: <form action="/tasks/<%= allTasks.e[0].id %>/delete" method="POST"> <button class="deleteTask">Delete</button> </f ...

Displaying the loading image only on the first result within a while loop

When a submit button is clicked on any result, the loading image below the button displays only for the first result in the while loop. For example, if I click the submit button on the first result, the loading image shows below it. However, when I click t ...

Is it possible for a parent element to inherit the margin of a child element in HTML and

strong text It's puzzling to me why my header shifts downward when I add a margin-top to its child element (.navigation). When I apply padding, the header remains at the top. Can someone please explain why this happens? I've read that setting ov ...

The Mysteries of Key Codes in JavaScript

I'm curious about the character codes used for keyboards. Recently, I came across an informative article discussing this topic. In particular, I am interested in finding out which key code to use when a user presses both the alt and down arrow keys s ...

Navigating using JavaScript dot notation is a powerful way to

Is there a way to implement JavaScript or jQuery code that will assign an active class to a dot when it is clicked, while also removing the active class from any other dots in the sequence? HTML: <div class="dotnav"> <div class="dot active" ...

Issue with text input field causing the Enter key to not create a new line

In the example above, the text is placed in the middle of the text area. Here is the CSS code : .form-control { height: 300px; display: block; width: 100%; padding: 0.375rem 0.75rem; font-size: 1rem; font-weight: 400; line-heig ...

Tips for changing the CSS pseudo class of an HTML element with JavaScript?

Here's a code snippet I have: const myDiv = document.querySelector("#myDiv"); myDiv.addEventListener("click", fct_Div); function fct_Div(ev) { console.log(ev); if (ev.altKey === true) { myDiv.style["background ...

When the user hits the enter key, automatically submit a form without the need for

Is it possible to submit a form on enter using type="button"? Here are my input fields: <input type="text" id = "login-user" class="form-control log-input" placeholder="Username" required="required"> <input type="password" id="login-password" clas ...

Error: The flash messages cannot be shown upon form submission

I am currently utilizing nodejs, Express, and Angular 6 for my website project. Recently, I implemented a contact form with nodemailer and now I aim to incorporate a flash message to appear on the contact page upon form submission. Data successfully submi ...

How to adjust the size of <img> in a Bootstrap carousel to fit the parent element using CSS

My webpage has a dynamic carousel feature where users can upload images, but I have no control over their dimensions. Despite some guidelines in place, it is uncertain if they will be followed. In my development tests, I have used three sample images: one ...

Is there a way for me to include a transition in the text of the picture's caption?

I've been attempting to incorporate a transition:1s; and transition the text to color:#0000. The specific text I'm working with is 'Joe Doe' in the image caption below my image. I've experimented with various placements in my CSS, ...

Angular HTML is throwing an error related to object arrays

Is there a way to display only specific fields of an array? <div class="form-check" *ngFor="let periodo of filterPeriodos()"> <div>{{periodo.periodos | json}}</div> <input class="form-check-input mr- ...

Customize the background color of a clipPath in SVG

I'm looking to design a landing page featuring a colored div with a clip-path, intended to showcase a video playing in the background. However, I'm encountering an issue where the background looks grayish without any clear explanation. Despite t ...