Is there a way to align these images vertically on a smaller device screen?

I am attempting to arrange these images vertically on a smaller screen, displaying them in one column instead of two.

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

Below is the code I currently have:

<div class="container">
      <div class="row g-0">
        <div class="col-6 col-ms-12">
          <div class="hovereffect">
            <img
              class="img-responsive img-fluid"
              src="project-images/skylit.jpg"
              alt=""
            />
            <div class="overlay">
              <a class="info" href="#">link here</a>
            </div>
          </div>
        </div>
        <div class="col-6 sm-col-12">
          <div class="hovereffect">
            <img
              class="img-responsive img-fluid"
              src="project-images/skit4.jpg"
              alt=""
            />
            <div class="overlay">
              <a class="info" href="#">link here</a>
            </div>
          </div>
        </div>
        <div class="w-100"></div>
        <div class="col-6 xl-col">
          <div class="hovereffect">
            <img
              class="img-responsive img-fluid"
              src="project-images/skit6.jpg"
              alt=""
            />
            <div class="overlay">
              <a class="info" href="#">link here</a>
            </div>
          </div>
        </div>
        <div class="col-6 sm-col-12">
          <div class="hovereffect">
            <img
              class="img-responsive img-fluid"
              src="project-images/skylit2.jpg"
              alt=""
            />
            <div class="overlay">
              <a class="info" href="#">link here</a>
            </div>
          </div>
        </div>
        <div class="col-6 sm-col-12">
          <div class="hovereffect">
            <img
              class="img-responsive img-fluid"
              src="project-images/lvr.jpg"
              alt=""
            />
            <div class="overlay">
              <a class="info" href="#">link here</a>
            </div>
          </div>
        </div>
        <div class="col-6 sm-col">
          <div class="hovereffect">
            <img
              class="img-responsive img-fluid"
              src="project-images/gym.jpg"
              alt=""
            />
            <div class="overlay">
              <a class="info" href="#">link here</a>
            </div>
          </div>
        </div>
      </div>
    </div>

This is my current approach:

/* Please enhance your content by detailing your attempts so far */

For example, you could mention adding "some" to "thing", adjusting column counts, etc. Though not well-versed in HTML, the idea should be clear.

Answer №1

If you're working with Bootstrap, make sure to use the classes col-sm-12 for better grid alignment. It seems like you are currently using sm-col-12 and col-ms-12 which may not work as intended. Check out this link for more information: https://getbootstrap.com/docs/4.0/layout/grid/

Remember to start from the smallest class when setting up your elements, such as class="col-12 col-sm-12 col-md-6"

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

I am struggling to get the images aligned properly on my HTML page. Can someone please advise on how to fix this issue?

On my HTML page, I have 2 div fields. Within each field, there are 5 images listed sideways. The issue is that the images in the div below are not lining up properly side by side. Given my limited frontend knowledge, how can I align them correctly? Here&a ...

When an error message is displayed in the textField, the Material UI button shifts downward

I have incorporated the material UI error message display into my text field. When I click on the button without entering any text in the field, an error message pops up which pushes down the button. I am looking for a way to prevent this behavior but have ...

The wonders of CSS flexbox and the power of justify-content

I am working on a layout where I need three flex items (rows) in a flex container, and my requirement is to justify them as space-between... The first row will consist of cloud tags, the second will have a price, and the third will contain a Read more link ...

CSS techniques for positioning a header image

I'm having an issue with using a banner I created in CS6 Illustrator as a header on my website. Despite setting it as the background, positioned at the top and set to "no-repeat", it keeps appearing at the bottom of the header area with around 300px o ...

What are the steps to enable CSS code completion for JavaFX again?

Hello everyone, Recently, I disabled the CSS code completion feature for JavaFX-Tags such as '-fx-...'. Unfortunately, I'm not sure how or why it happened but now I would like to enable the code suggestions again. I have been unable to loca ...

What is the best way to include a CSS stylesheet in a Wordpress theme?

Is there a way for me to properly load my custom CSS in Wordpress so that the dynamically inputted content on my pages matches the styling of my header and footer? In my functions.php file, I currently have the following code, but it only prints the code ...

Adjust the button's color even after it has been clicked

My goal is to update the button's color when it's clicked. I found some examples that helped me achieve this, but there's an issue - once I click anywhere outside of the button, the CSS class is removed. These buttons are part of a form, and ...

The "read more" button seems to be malfunctioning

I've been working on integrating a gallery of images into my posts. My goal is to display 4 images initially, followed by a "load more" button that, when clicked, will reveal another set of 4 images, and so on. I have already created the HTML, CSS, an ...

Adjustable Footer Size with Minimum Size Constraint

On my webpage, I have a footer that is not fixed in place. Currently, the page's content does not require scrolling, and the footer occupies about 25% of the browser window at full screen on a 1920 x 1080 display. The footer's contents are aligne ...

Tips on how to align several divs within another div

I've been attempting to center multiple div blocks within another div or HTML document, but I haven't had any success with the methods I've found on StOv. Here's an image of what I'm aiming for: https://i.stack.imgur.com/DB7uQ.jp ...

Creating Custom Stylus Themes using Grunt

Is there a way to make my Stylus file dynamically accept variable input from Grunt, iterate through the variable values, and generate multiple themed CSS files? This would allow for easy theme switching, similar to the method described in this Stack Overf ...

Separate the divs in a template into individual templates, or alternatively, utilize ng-if to display different divs within a single template

As a newcomer to AngularJS, I am seeking advice on the most efficient way to code for the given scenario: Scenario: I have a single HTML template containing multiple divs, and I need to display only one div at a time based on specific conditions. Two app ...

Customizing Sass Bootstrap Variables for Tailored Responsive Designs (Specifically for Mobile or Desktop)

Currently, I am in the process of working on a website that has opted for the adaptive approach, using separate mobile and desktop templates instead of responsive design. Despite this choice, Bootstrap is still being utilized on these templates, loading al ...

Is there a way to adjust the size of a table display to ensure that both vertical and horizontal scroll bars are constantly visible?

[edits added below per the request to see code. Edits also added to the original post to clarify the ask - marked in bold] My application features a broad table with the potential for many rows, generated by django-tables2 using the bootstrap5-responsive ...

The HTML button with Google's material-icons appears noticeably small when displayed on mobile devices

Looking to design a basic HTML page with a button placed in the lower right corner? Check out the code below: <!DOCTYPE html> <html> <head> <title>Sample Page</title> <style> /* Styles for the container * ...

retrieve the parent frame's request URL

I am faced with the task of writing a JSP code that retrieves the getRequestURL() of the parent frame (the URL shown in the address bar) from a child frame. However, when I attempt to do this, I only obtain the URL of the child frame. Is there anyone who ...

Align navigation items in the center of the navigation container

I've been grappling with aligning the content of a nav-item inside a nav container in my project. I'm unable to apply a margin on the ul>li items as it doesn't adjust properly on different resolutions. I've tried using percentages, b ...

Tips for CSS: Preventing onhover animation from resetting with each hover

I've created an on-hover CSS animation that smoothly transitions between images. However, I encountered a lagging issue when the user quickly hovers over SECTION ONE and SECTION TWO before the animation ends, causing the animation to restart and lag. ...

CSS Hyperref and Anchor tags

It appears that when adding an 'href' tag to my anchor, all of the CSS formatting is lost. Is there a special way that CSS treats links? Below is the basic CSS: .topmenu > ul > li > a:visited, .topmenu > ul > li > a:active, .t ...

Why is my image not extending to the full height on mobile devices?

How can I keep the image on desktop the same size, but make it larger on mobile devices? I'm using Bootstrap 5. What changes should I make in the code? https://i.sstatic.net/YCeT4.png <div class="container"> <div class=&quo ...