Responsive layout optimization using Bootstrap

I'm struggling with bootstrap responsiveness. I have four items aligned to the right of an image (a title section and 3 items). Currently, it works fine on large screens but on small screens, all the items and the title go down. However, I want to keep just the title section on the right of the image and have the other 3 items drop below. Here is the CSS code I've tried:

@media (min-width: 576px) {
  img {
    width: 100%;
  }

  .title {
    text-align: left;
    width: 100%;
  }

  .item .item-icon {
    float: left;
    font-size: 40px;
    width: 50px;
    height: 50px;
  }

  .item .item-content {
    float: right;
    text-align: left;
  }
}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>

    <!-- fontawesome -->
    <script
      src="https://kit.fontawesome.com/24734ac872.js"
      crossorigin="anonymous"
    ></script>

    <!-- bootstrap -->
    <link
      rel="stylesheet"
      href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
    />

    <!-- style -->
    <link rel="stylesheet" href="style.css" />
  </head>

  <body>
    <div class="container">
      <div class="row">
        <div class="col-md-6">
          <img src="http://placehold.it/300" />
        </div>
        <div class="col-md-6">
          <div class="row">
            <div class="title text-center">
              <h1>About me?</h1>
              <p>things about me...</p>
            </div>
          </div>
          <div class="row">
            <div class="item">
              <div class="item-icon">
                <i class="fas fa-heart"></i>
              </div>
              <div class="item-content">
                <h1>Thing 1</h1>
                <p>About thing 1...</p>
              </div>
            </div>
          </div>
          <div class="row">
            <div class="item">
              <div class="item-icon">
                <i class="fas fa-heart"></i>
              </div>
              <div class="item-content">
                <h1>Thing 2</h1>
                <p>About thing 2...</p>
              </div>
            </div>
          </div>
          <div class="row">
            <div class="item">
              <div class="item-icon">
                <i class="fas fa-heart"></i>
              </div>
              <div class="item-content">
                <h1>Thing 3</h1>
                <p>About thing 3...</p>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- jquery -->
    <script
      src="https://code.jquery.com/jquery-3.4.1.min.js"
      integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
      crossorigin="anonymous"
    ></script>

    <!-- bootstrap -->
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
  </body>
</html>

The desired result should look like this:

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

Gif:

https://i.sstatic.net/G9DcF.gif

Thanks!

Answer №1

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>

    <!-- fontawesome -->
    <script
      src="https://kit.fontawesome.com/24734ac872.js"
      crossorigin="anonymous"
    ></script>

    <!-- bootstrap -->
    <link
      rel="stylesheet"
      href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
    />

    <!-- style -->
    <link rel="stylesheet" href="style.css" />
    <style>
        @media (min-width: 576px) {
  img {
    width: 100%;
  }

  .title {
    text-align:right;
    width: 100%;
  }

  .item .item-icon {
    float: left;
    font-size: 40px;
    width: 50px;
    height: 50px;
  }

  .item .item-content {
    float: right;
    text-align: left;
  }
}
    </style>
  </head>
  <body>
    <div class="container">
      <div class="row">
        <div class="col-md-6 col-sm-6 col-xs-6">
          <img src="http://placehold.it/300" />
        </div>
        <div class="col-md-6 col-sm-6 col-xs-6">
            <div class="title text-center">
              <h1>About me?</h1>
              <p>things about me...</p>
            </div>
        </div>
        <div class="row">
          <div class="row col-sm-12 col-xs-12">
            <div class="item">
              <div class="item-icon">
                <i class="fas fa-heart"></i>
              </div>
              <div class="item-content">
                <h1>Thing 1</h1>
                <p>About thing 1...</p>
              </div>
            </div>
          </div>
          <div class="row col-sm-12 col-xs-12">
            <div class="item">
              <div class="item-icon">
                <i class="fas fa-heart"></i>
              </div>
              <div class="item-content">
                <h1>Thing 2</h1>
                <p>About thing 2...</p>
              </div>
            </div>
          </div>
          <div class="row col-sm-12 col-xs-12">
            <div class="item">
              <div class="item-icon">
                <i class="fas fa-heart"></i>
              </div>
              <div class="item-content">
                <h1>Thing 3</h1>
                <p>About thing 3...</p>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- jquery -->
    <script
      src="https://code.jquery.com/jquery-3.4.1.min.js"
      integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
      crossorigin="anonymous"
    ></script>

    <!-- bootstrap -->
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
  </body>
</html>

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 is the best way to validate if fields are blank before sending a message using the button?

<template> <div> <div class="form-group"> <label for="name">First Name</label> <input type="text" class="form-control" v-model="firstName" placeholder="Ente ...

Using HTML5 input pattern to permit the use of a comma separator when entering thousands

I'm currently working on creating a regular expression for an HTML5 input form that allows the comma as a separator for thousands. Here are some examples of valid input: 20 3000 4,000 600000 7,000,000 8000000 The requirements for the input are: o ...

The image appears uniquely sized and positioned on every screen it is viewed on

After reviewing the previously answered topics on the site, I couldn't seem to make the necessary adjustments. Despite setting the size and location in the css file, the large image remains centered and fitting for the screen. The "imaged1" class seem ...

Splitting the page into four sections with a unique H layout using CSS styling

Attempting to create an H page layout: body { background-color: grey; background-size: 100%; background-repeat: no-repeat; } html, body { height: 100%; margin: 0px; } .a { float: left; width: 25%; height: 100%; border: 1px solid blue ...

CSS: Struggling to Keep Footer at the Bottom of the Page

I've been struggling to get my footer to stick to the bottom of the page, but I just can't seem to make it work. I've searched online for solutions with no success, so I thought I would ask for help here. http://jsfiddle.net/f54eq3w8/ Here ...

Adaptable layout - featuring 2 cards side by side for smaller screens

I am currently designing a webpage that showcases a row of cards, each featuring an image and a title. At the moment, I am utilizing the Bootstrap grid system to display 4 cards per row on larger screens (col-md-2), but my goal is to modify this layout t ...

When implementing Critical CSS, the Jquery function fails to execute upon loading

Currently, I am working on optimizing my website at . In an attempt to improve its performance, I decided to implement critical CSS using penthouse. The Critical CSS code can be found here, generously provided by the main developer of penthouse. However, ...

Image placed as background for registration form

In my Vue project, I am trying to create a login form with an image as the background. However, I am facing an issue where the image is not displaying on the page. Can someone guide me on how to add a picture behind the form? HTML: Below is the HTML code ...

Challenges with altering the height of a div through animation

HTML <div class="blok1" ></div> <div class="blok2"></div> <div class="blok3"></div> CSS .blok1 { background-color: green; border-bottom-left-radius:15px; border-bottom-right-radius:15px; h ...

Discussing the use of local identification within a <BASE> tag in SVG specifically on the Firefox browser

Encountering an issue on a current Firefox browser running on Win7 while utilizing SVG (although the details may not be directly related to the problem): ` <head> <!-- base href="http://127.0.0.1/package/index.php" /--> < ...

Is there a way to prevent HTML Tidy from inserting newlines before closing tags?

Have you ever noticed how HTML Tidy always seems to add an extra newline before the closing tag? It's so frustrating! For instance: <p>Some text</p> ends up looking like this: <p>Some text </p> Is there a way to make Tidy k ...

"Share your social media profiles without redirecting users to new tabs

Currently in the process of launching my own website using the free Portra theme. So far, everything has been going smoothly with this widget free template. However, I have encountered an issue with my social links opening in the same window. I would prefe ...

When the URL is modified, triggering an event to load

Is there a way to make a page load directly to a specific section and automatically open an accordion? For instance, I have a page with multiple accordions displayed vertically. I already know that using id's in the URL like page#accordion1 will scro ...

Adding multiple elements with varying content to a separate division

I am attempting to combine two div elements into a single div, but I'm encountering difficulties. Despite thoroughly examining my code, everything appears to be correct. Here's what I've tried so far. To assist me in achieving this, I am ut ...

The Bootstrap dropdown menu is cut off and not fully visible on mobile devices

I am experiencing an issue with the mobile version of a website where the dropdown menu is not fully visible due to the position of a specific menu item and the number of items in the dropdown. https://i.sstatic.net/HmXeq.png The image below shows how I ...

Tips for adjusting image size using media queries

How can I ensure that the image resizes correctly on smaller screens? Currently, the image spills over the container and there are gaps between the top/left of the container and the image. Should I adjust the image size in the media query or expand the con ...

Image broken on default bootstrap navbar

On my computer where I am developing a Ruby on Rails app, I have a relative link to an image. To customize the style, I am using Bootstrap and have used their code to source the image for the top left brand placement. You can view the Bootstrap link here. ...

Searching and manipulating arrays in PHP

<?php include 'database.php'; $sql="SELECT `j_company`,`j_salary`,`j_title` FROM `jobs`"; $query=mysqli_query($conn, $sql); if(!$query) { echo "<h1>Unsuccessful</h1>"; echo("Error description: " . ...

Personalized design options for ASP text fields

I have two textboxes (asp:TextBox) close to each other, currently styled like this: https://i.sstatic.net/mcha5.png I want to remove the shadow effect on the top and left edges of the textboxes to apply custom styling. However, using box-shadow has no im ...

Ways to disable the ability to close a bootstrap modal by pressing the backspace key

How can I enable the backspace button in a Bootstrap Modal form for textboxes and textareas? $('body').keydown(function (e) { if ($('#myModal').is(':visible')) { if (e.keyCode == 8) { retu ...