Issue with Inline Block Display not functioning correctly

My issue arises when trying to move multiple boxes at once on a mobile screen using display inline-block. Instead of all 3 "single-facilities" boxes moving together, they shift one by one. This problem occurs when I apply display inline-block within the media screen.

Here is the HTML:

<div class="box-facilities">

            <div class="single-facilities">
                <div class="img-facilities"></div>
                <div class="text-facilities">
                    <h1>World Class Library</h1>
                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusm
                    od tempor.</p>
                </div><!--facilities-text-->
            </div><!--single-facilities-->

            <div class="single-facilities">
                <div class="img-facilities"></div>
                <div class="text-facilities">
                    <h1>Largest Play Ground</h1>
                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusm
                    od tempor.</p>
                </div><!--facilities-text-->
            </div><!--single-facilities-->

            <div class="single-facilities">
                <div class="img-facilities"></div>
                <div class="text-facilities">
                    <h1>Tasty and Healthy Food</h1>
                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusm
                    od tempor.</p>
                </div><!--facilities-text-->
            </div><!--single-facilities-->

        </div><!--box-facilities-->

This is the CSS being used:

        .box-facilities{
        display: flex;
        height: 800px;
        align-items: center;
        justify-content: space-evenly;
    }
    
    .single-facilities{
        display: inline-block;
    }
    
    .img-facilities{
        background-color: gray;
        width: 27rem;
        height: 27rem;
        border-radius: 1.5rem; 
    }
    
    .text-facilities{
        margin-top: 1rem;
        max-width: 28rem;
    }

    @media screen and (max-width: 1370px){
    .box-facilities{
        display: inline-block;
    }
}

Answer №1

To adjust the layout in a vertical direction, simply set the flex-direction property to column:

flex-direction: column;

.box-facilities {
  display: flex;
  height: 800px;
  align-items: center;
  justify-content: space-evenly;
}

.single-facilities {
  display: inline-block;
}

.img-facilities {
  background-color: gray;
  width: 27rem;
  height: 27rem;
  border-radius: 1.5rem;
}

.text-facilities {
  margin-top: 1em;
  max-width: 28rem;
}

@media screen and (max-width: 1370px) {
  .box-facilities {
    /* display: inline-block; */
    flex-direction: column;
  }
}
<div class="box-facilities">

  <div class="single-facilities">
    <div class="img-facilities"></div>
    <div class="text-facilities">
      <h1>State-of-the-Art Gym</h1>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>
    <!--facilities-text-->
  </div>
  <!--single-facilities-->

  <div class="single-facilities">
    <div class="img-facilities"></div>
    <div class="text-facilities">
      <h1>Olympic-Size Swimming Pool</h1>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>
    <!--facilities-text-->
  </div>
  <!--single-facilities-->

  <div class="single-facilities">
    <div class="img-facilities"></div>
    <div class="text-facilities">
      <h1>Healthy Dining Options</h1>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>
    <!--facilities-text-->
  </div>
  <!--single-facilities-->

</div>
<!--box-facilities-->

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 reason for the malfunction of input :: - webkit-slider-thumb and input :: - moz-slider-thumb?

Designing a compact slider for enhancing user experience not limited to webkit browsers requires utilizing a scss template such as input { width: 100%; -webkit-appearance: none; -moz-appearance: none; appearance: none; height: 1vm ...

Is it possible to swap a <div> element with the content of another HTML page using the .innerHTML method?

I am currently working on a project that involves loading different webpages into a <div> on my page once specific links are clicked. I came across a thread about using jQuery for this purpose, but I'm not familiar with it. Is there a way to ach ...

how can I apply a class name to an SVG element within styled components

I've been attempting to style an SVG icon component using styled-components, but I'm encountering some issues as the styles I apply to the close icon are not taking effect. import styled from 'styled-components' import Close from ' ...

Annoying AngularJS Scrolling Problem

I am facing an issue with a Container that loads multiple views <md-content flex id="content"> <div ng-view></div> </md-content> One of the loaded views has the following structure: <div layout="column" id="selection-whit ...

Encountering an Error when Using Sass 3 to Customize Bootstrap 5 Color Values

Having some trouble changing the default theme colors in Bootstrap using SASS. Whenever I try to change a color and compile, I keep getting an error saying 'invalid CSS value'. I've gone through the documentation and watched a few tutorials ...

Unexpectedly, CSS is failing to override React-Bootstrap and Bootstrap as intended

Currently, I am tackling a project that involves utilizing react-bootstrap along with my own custom CSS for styling. Both are imported in my index.js file as shown below: import React from 'react'; import ReactDOM from 'react-dom'; impo ...

Position tables on the right side of adjacent tables

There are two tables named id="BFCategories" and "BMICategories". Additionally, there are two other tables with id="BFTable" and "BMITable" BFCategories should come after BFTable, while BMICategories should follow BMITable. How can I a ...

Trouble with Bootstrap accordion staying open even after a different one is chosen

Looking for assistance! I am encountering an issue with using jQuery on Bootstrap. The accordion feature is not functioning correctly as it fails to collapse when another section is selected. https://i.stack.imgur.com/uiZPh.png The problem arises when th ...

Different Positions in Flexbox/Container

I am trying to create a series of flexbox items that have both an image and content. I want the images to alternate sides within each flexbox item (one on the left, one on the right, and so on), but I can't figure out how to make it work. Any advice o ...

How to align several DIVs within a container with an unspecified size

I have several blue rectangles with known dimensions (180 x 180 px) within a container of unknown size. <html> <head> <style> @import url('http://getbootstrap.com/dist/css/bootstrap.css&a ...

Adjusting the position of navbar links to the right in Bootstrap 4 using a toggle button

Attempting to shift the links from the left of the navbar to the right side proved to be challenging. I tried floating it to the right, using position:relative; right: 200px;, and padding-right: -200px;, but none of it worked. If anyone has any other sug ...

Alignment problem

In my design, I have a toolbar with flex display and I am trying to center my span element within it. However, I seem to be missing something in the CSS. CSS .toolbar { position: absolute; top: 0; left: 0; right: 0; height: 60px; d ...

CSS3 Animation displaying text color change on various elements in a continuous loop

I was attempting to create a dynamic animation where multiple texts change color, similar to what you can see on https://vercel.com. I have successfully figured out how to make one text change color using keyframes, but I am struggling to make each text ch ...

Sequence of loading unique CSS skin for MediaWiki

Running a MediaWiki site with a personalized skin, I've noticed that the CSS code from my custom skin is being overshadowed by the default MediaWiki CSS. Is there a way to modify the sequence in which the CSS code is loaded? ...

The clash of names between tags and classes in Tumblr themes can cause conflicts

I have discovered a method to customize the style of different posts based on their respective "#tags" using {TagsAsClasses}: <div class="post {TagsAsClasses}"> div.tag { /* customize styling here */ } While this approach works well, I encount ...

How can I center two images using a hover effect in WordPress?

When the mouse hovers over an image, it changes to another image. Everything works smoothly except for one issue - the image is not centered. Below is the code I am currently using: HTML: <figure> <a> <img class="hover" src="na ...

What is the technique for creating multiple circles using CSS?

Creating multiple circles in CSS and linking them to my HTML file has posed a challenge. The code I have so far is: .circle{ height: 50px; width: 50px; background-color: red; } However, attempting to make another circle using the same 'circle' c ...

Vue is actively eliminating a background image through the use of the style attribute

There appears to be an issue where Vue is removing both the style attribute and the background image from this tag. <section style="background: url(images/banners/profiles/profile-banner-1.png);" class="profile-banner flex items-end md:items-end md:j ...

Display a series of elements in rows using styled-components

Here is a simple array that I need help rendering into a grid structure. Currently, the array is displayed like this: HAMDDN I want each element to be on a new row like so: HA MD DN Any suggestions on how to achieve this? Below is the full code. I am ...

What causes child elements to contribute padding to the parent element when using CSS float?

While working on a website coding project, I encountered a puzzling issue. The layout consists of two columns with float: left, along with margin: 0 and padding: 0. Within these columns are blocks. When the blocks are empty, everything seems fine, and I c ...