Tips for organizing a Bootstrap layout with a vertically centered single column alongside a 4x4 grid

I am currently in the process of familiarizing myself with Bootstrap, and I have a question about arranging the grid layout more flexibly. My goal is to center a single div vertically on the left side of the page, while having a 4x4 grid displayed on the right. I have included an example image illustrating the desired arrangement of elements. Please refer to the Example.

Could you please provide guidance on how to achieve this layout? Thank you!

Answer №1

In this scenario, I would opt for a grid system over using bootstrap. Here is an example implementation:

HTML:

<div class="grid-container">
        <div class="child item-a">Image</div>
        <div class="child item-b">Text 1</div>
        <div class="child item-c">Text 2</div>
        <div class="child item-d">Text 3</div>
        <div class="child item-e">Text 4</div>
    </div>

CSS:

.grid-container {
            display: grid;
            height: 50vh;
            padding: 10px;
            background-color: coral;
            border: 1px solid;
            grid-template-columns: 1fr 1fr 1fr 1fr;
            grid-template-rows: 1fr 1fr;
            grid-row-gap: 20px;
            grid-column-gap: 20px;
        }
        .child {
            background-color: cornflowerblue;
            border: 1px solid;
        }
        .item-a {
            grid-area: 1/1/3/3;
        }

Answer №2

When working with bootstrap, it is highly recommended to utilize flex properties for better layout control

Illustration

<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c8aaa7a7bcbbbcbaa9b888fde6f8e6f8e5aaadbca9fb">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">

<div class="d-flex align-items-center justify-content-around p-3 bg-dark" style="height: 350px; width: 350px">
  <div class="bg-light" style="height: 100px; width: 100px">IMAGE</div>
  <div class="row bg-light p-1" style="height: 150px; width: 150px">
    <div class="col-6 bg-secondary text-light">1</div>
    <div class="col-6 bg-secondary text-light">2</div>
    <div class="col-6 bg-secondary text-light">3</div>
    <div class="col-6 bg-secondary text-light">4</div>
  </div>
</div>

  • d-flex: sets the display property to flex
  • align-items-center: aligns items vertically at the center
  • align-content-around: controls horizontal spacing of items by distributing free space equally

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

Spacing between letters on a canvas element

This question is straightforward - I am struggling to find a way to adjust the letter spacing when drawing text on a canvas element. I want to achieve a similar effect as the CSS letter-spacing attribute, by increasing the space between each letter in the ...

Issue with Bootstrap causing individual scroll panels for each column to be unresponsive

Hello, I'm currently using Bootstrap to build a website from scratch. This is my first time working with Bootstrap, so I might be making some errors along the way. My current challenge involves creating individual scroll panels for each of the 3 cont ...

Tips for positioning an image in the TOP Right corner below the navbar using CSS

I am currently in the process of learning HTML and CSS, and I would like to practice and conduct research whenever I encounter difficulties. Recently, I have been attempting to style my landing page based on a screenshot that I took. However, I have been u ...

Elevate Your Design with Bootstrap 4 - Rearrange Rows with Ease

I have been browsing the Bootstrap documentation, but I am unable to locate the specific class needed to achieve a certain effect. Is there a method for shifting or offsetting a div Row if the parent row has a column that pushes down the bottom div? Can th ...

Utilizing Python's BeautifulSoup library to extract specific elements from an HTML document

Just getting started with BeautifulSoup and I'm looking to extract specific elements that represent percentages - 98.2% and 94.2%. What I want to print is: apples: 98.2% bananas: 94.2% Any insights on how I can achieve this? Thanks in advance. <d ...

Assistance needed for aligning a div to the right using

Check out my website at www.whiterootmedia.com. I am trying to prevent my ads on the right from wrapping and disappearing off the screen when the width is around 800px. I believe I need to create a wrap div container, float my ads div to the right, set a ...

What is the best method for efficiently wrapping contents within a div container?

On the website cjshayward.com/index_new.html, there is a div wrapped around the content of the body, which is approximately 1000 pixels wide. In Chrome and Firefox, the wrapper works perfectly for the top section of about 100 pixels. Further down the page, ...

Is it a commonly recommended method to nest fxLayout containers?

Recently, I ventured into using Angular Flex for the first time and I find myself a bit unsure about the nesting of layout containers. The issue arises when dealing with a navigation tag that triggers an angular-material sidenav opening to the left, pushin ...

Using JavaScript to dynamically load Cascading Style Sheets based on the current

I am trying to dynamically load different CSS files based on the current date (season). I attempted to tweak an image script that I found on Stack Overflow, but it didn't yield the desired result. Could someone please guide me on where I might be ma ...

Issue with fancyBox not functioning properly when integrated with a caption script

Hey there! I've been working with both jQuery's fancyBox for displaying image/video galleries and the Capty script for showing image titles on images. However, I've run into a snag - when the title is displayed on the image, fancyBox st ...

Guide on creating a menu that remains open continuously through mouse hovering until the user chooses an option from the menu

I have a unique scenario where I am working with two images. When the mouse hovers over each image, two corresponding menu bars appear. However, the issue is that when the mouse moves away from the images, the menu disappears. Any suggestions on how to im ...

Modification of a CSS element

The CSS I am working with looks like this: .cls .imageX { float:left; } .cls .imageY { float:right; } It is currently being used on a page in this way: <div class="cls"> <a href="" class="imageX"><img src="left.png"/></a> &l ...

The Bootstrap Datepicker is always set to display a date that is one day earlier than the selected date

I have encountered an issue with the Bootstrap date-picker where the selected date appears to be one day less when passed to the backend. For example, the date I select in the UI is 04-Apr-1997, but the date shown in the console is 1997-04-03T18:30:00.000Z ...

`Execute onClick function for submit button only when all the required input fields have been populated`

I have created a form with mandatory fields and included an onClick event listener on the submit button to show a loading spinner while the process is running. However, I am facing an issue where the onClick function is triggered every time the button is c ...

Implement rounded corners to bootstrap table

After working on this fiddle with a bootstrap table, I encountered an issue where I was unable to apply the desired border-radius to it. Can someone shed some light on why this is happening and provide guidance on how to successfully implement it? This is ...

Move the remaining blocks after deletion

Is there a way to create a seamless effect when removing an element? I am looking to incorporate a transition or slide effect when deleting a block and causing the blocks below it to move up smoothly. const animateCSS = (element, animation, prefix = &ap ...

JQuery ajax fails to trigger the success function

Upon using an ajax request to insert data into the database, I encountered an issue where the button message did not update after the submission was successful. Initially, I set the button text to Please wait... upon click, and intended to change it to Don ...

"Uncovering the ways iOS disrupts background-size functionality

I am currently working on creating several marked images that will adjust in size to fit the length of their content. This functionality works well on most browsers, except for those on iOS devices like iPhone and iPad. Take a look at the image-link below ...

Incorporate your weekly itinerary from Google Sheets directly onto your Webnode website

I have a weekly schedule arranged in a Google Sheet that I want to incorporate into my Webnode website. Unfortunately, using the embed HTML option resulted in a poor display when accessed on mobile phones. Additionally, exporting it to Google Calendar an ...

Altering the hue of a picture

Looking to alter the color of an image on a webpage, specifically a carport. It's crucial that the texture and shadows remain consistent. Swapping out images with different colors would require an excessive amount of images, so I'm seeking advice ...