showing a pair of divs in a split layout on the homepage

I have a partially split homepage with two sections using Twitter Bootstrap v5.1.3 for the layout. The left side consists of two divs, one for text and one for an image.

These divs are contained within a flex-parent, giving them an inline-block appearance.

My goal is to have the text at the top and the image at the bottom within the "leftside col-md-6" section, both centered.

Here is what I am aiming for:

https://i.sstatic.net/6UIyO.png

body {
  font-family: "Merriweather", sans-serif;
  background-color: #fafafa;
  overflow-x: hidden;
}

.leftside,
.rightside {
  height: 50vh;
  width: 100%;
}

@media screen and (min-width: 768px) {
  .leftside,
  .rightside {
    height: 100vh;
  }
}

.leftside {
  background-color: #8a68ff;
  opacity: 83%;
}

.rightside {
  background-color: #ffffff;
}

.left-hero-text {
  font-size: 48px;
  font-weight: 400;
  color: #ffffff;
}

.bold-text {
  font-size: 55px;
  font-weight: 700;
}

img {
  width: 50%;
  height: auto;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection"
          class="__cf_email__"
          data-cfemail="32505d5d46414640534272071c031c01">[email protected]</a>/dist/css/bootstrap.min.css"
      integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">

<div class="row gx-0">
  <div class="col-md-6 gx-0">
    <div class="leftside d-flex justify-content-center align-items-center">
      <div class="left-hero-text">
        <span class="bold-text">Lorem</span> ipsum
        <span class="bold-text">dolor</span> sit amet
      </div>
      <img src="https://wiki.geogebra.org/uploads/a/a4/Menu-tools.svg" alt="tools" />
    </div>
  </div>
  <div class="col-md-6 gx-0">
    <div class="rightside d-flex justify-content-center align-items-center">
      Right Side
    </div>
  </div>
</div>

Answer №1

To modify the layout, simply adjust your inner flex container's direction to column.

body {
  font-family: "Merriweather", sans-serif;
  background-color: #fafafa;
  overflow-x: hidden;
}

.leftside,
.rightside {
  height: 50vh;
  width: 100%;
}

@media screen and (min-width: 768px) {
  .leftside,
  .rightside {
    height: 100vh;
  }
}

.leftside {
  background-color: #8a68ff;
  opacity: 83%;
}

.rightside {
  background-color: #ffffff;
}

.left-hero-text {
  font-size: 48px;
  font-weight: 400;
  color: #ffffff;
}

.bold-text {
  font-size: 55px;
  font-weight: 700;
}

img {
  width: 50%;
  height: auto;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e3818c8c979097918293a3d6cdd2cdd0">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">

<div class="row gx-0">
  <div class="col-md-6 gx-0">
    <div class="leftside d-flex flex-column justify-content-center align-items-center">
      <div class="left-hero-text">
        <span class="bold-text">Lorem</span> ipsum
        <span class="bold-text">dolor</span> sit amet
      </div>
      <img src="https://wiki.geogebra.org/uploads/a/a4/Menu-tools.svg" alt="tools" />
    </div>
  </div>
  <div class="col-md-6 gx-0">
    <div class="rightside d-flex justify-content-center align-items-center">
      Right Side
    </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

Ben Kamens has developed a new feature in jQuery Menu Aim where the sub menu will not reappear once it

While exploring Ben Kemens’ jquery-menu-aim, I came across a demonstration on codepen. The code on codepen allows smooth transition from the main menu to the sub menu, but if you move away completely, the submenu remains visible and doesn't disappe ...

Is there a way to adjust the border color of my <select> element without disrupting the existing bootstrap CSS styling?

In my Bootstrap (v4.5.3) form, the select options appear differently in Firefox as shown in the image below: https://i.sstatic.net/3suke.png Upon form submission, I have JavaScript code for validation which checks if an option other than "-- Select an Op ...

Use jQuery to set the onclick attribute for all elements rather than relying on inline JavaScript

I am currently facing a challenge with converting inline JS to jQuery. My goal is to eliminate all inline onclick events and instead target them by class. HTML - checkbox <td class="center"> <?php if ($product['selected']) { ?> ...

Displaying content on a webpage using PHP, AJAX, and HTML

Looking to update my current form setup. I have a basic Form below: <form action="" method="POST"> <input type="button" value="Generate Numbers" onclick="on_callPhp1()"/> </form> Accompanied by this javascript code: <script type="te ...

Having trouble with React Bootstrap in Gatsby 4?

I've been facing a challenge while trying to integrate React Bootstrap into Gatsby version 4. I'm unable to get it to work properly, especially in terms of responsiveness. To investigate further, I set up a small test project which can be found ...

Moving elements upwards and downwards using CSS transitions

I am currently designing a metro tiles menu for my website, without using JavaScript and only relying on HTML and CSS. The issue I am facing involves the sliding tiles and the direction in which they slide. Additionally, there seems to be a problem where ...

How can we modify this function to interpret multiple selections at once?

For the task of displaying multiple selections from a scrolling list to an alert, I have implemented the following function: var toppings = ""; function displaySelectedToppings() { var topList = document.getElementById('to ...

Issue with IE 11: Including card image inside anchor tags in Bootstrap 4 causes unwanted white space

I'm having an issue with my Bootstrap 4 card markup where the image is wrapped inside an anchor tag. The problem arises when viewing it in IE 11, as there is a large white space underneath the image, while everything displays fine in Chrome, Edge, and ...

Incorporating @font-face webfonts into a Jekyll project

I'm currently working on incorporating webfonts into a Jekyll build. Interestingly enough, the fonts show up perfectly fine when I view them locally, but once I push my project to a live environment, the fonts mysteriously disappear. To make matters w ...

Guide to placing an element behind text using Bootstrap 3

On my webpage, I have a straightforward Bootstrap Jumbotron displayed prominently: <div class="jumbotron"> <div class="container"> <h1>Welcome to My Wonderful Site</h1> <p>There's some information her ...

Integrating Labels on External Websites with ASP.NET

I have been developing a website that needs to display a counter on the home page. To accomplish this, I used an asp label that counts and displays the database records (e.g. 180000) with no issues at all. However, now I am facing a new challenge. I want ...

Encountering difficulty transforming DataFrame into an HTML table

I am facing difficulties incorporating both the Name and Dataframe variables into my HTML code. Here's the code snippet I have: Name = "Tom" Body = Email_Body_Data_Frame html = """\ <html> <head> </he ...

What are the steps to generate a production build directory in a React project?

Currently, I am developing a website utilizing react for the frontend and node.js for the backend. However, I'm unsure of how to deploy it to the live server. After conducting some research, I learned that I need to create a build folder. To provide a ...

Updating and showing a variable in a PHP file using JavaScript within an HTML webpage

My goal is to establish a variable in a PHP file on my server named "likes." Subsequently, I wish to incorporate a like button on my HTML webpage that, when clicked, will utilize JavaScript to modify the "likes" variable in the PHP file and increase it by ...

Exploring Material-UI: Leveraging makeStyles and CSS-In-JS for customizing library component styles

I'm currently utilizing Material-UI to construct a form using makeStyles and CSS-In-JS for styling purposes. I have a form component from the Material-UI library that I want to style according to my needs. My main focus is on how to address classes or ...

What is the best method to display each HTML output on a separate line using Python?

As a beginner, I am working on a small project involving webscraping. My goal is to print the lyrics of a song with each line on a separate line using Beautiful Soup in Python. However, the output I'm getting looks like this: I looked out this mornin ...

Delay the rendering of the MUI DataGrid column until after the DataGrid is visible on the screen

Would it be feasible to asynchronously load a column of data in the MUI DataGrid after the table is displayed on the screen? Retrieving this additional data from the database is time-consuming, so I aim to have it appear once the table has fully loaded. T ...

Style large and small text side by side with CSS styling

I've been trying to figure out how to position a smaller biography-style text next to this large title, but I'm having trouble finding a solution. I've experimented with float: left, float: right, and display: flex in my CSS code. Below is t ...

What is the best way to incorporate data from a foreach method into a function call within an HTML string?

Having trouble calling a function with data from a foreach loop while generating HTML cards and buttons from an array. The issue seems to be in the renderProducts() method. /// <reference path="coin.ts" /> /// <reference path="prod ...

The value returned by $(this).next() is undefined

I'm struggling to implement jQuery functionality to toggle the display of a div, but I am encountering an issue where my jQuery code is unable to select it. Every time I try, it returns undefined. Can anyone provide assistance? $(document).on(&apos ...