Arranging Boxes side by side

I am struggling to align three boxes horizontally on my website, as they are currently stacking vertically. I have implemented Twitter Boostrap's 'row' class in an attempt to achieve this layout.

HTML:

.img-box-kai {
        width: 300px;
        height: 450px;
        border: 3px solid red;
    }
    
    .img-box-lucas {
        width: 300px;
        height: 450px;
        border: 3px solid red;
    }
    
    .img-box-bryant {
        width: 300px;
        height: 450px;
        border: 3px solid red;
    }
<div class="container">
      <div class="row">
        <div class="img-box-kai">Rectangle Test</div>
        <div class="img-box-lucas">Rectangle Test</div>
        <div class="img-box-bryant">Rectangle Test</div>
      </div>
    </div>

Here is a visual representation of the current alignment: image

Answer №1

If you plan to utilize Bootstrap, it is recommended to eliminate the fixed widths and take advantage of the grid system for horizontal stacking:

.img-box-kai {
    height: 450px;
    border: 3px solid red;
}

.img-box-lucas {
    height: 450px;
    border: 3px solid red;
}

.img-box-bryant {
    height: 450px;
    border: 3px solid red;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
  <div class="row">
    <div class="col-xs-4 img-box-kai">Rectangle Test</div>
    <div class="col-xs-4 img-box-lucas">Rectangle Test</div>
    <div class="col-xs-4 img-box-bryant">Rectangle Test</div>
  </div>
</div>

Answer №2

Utilize the display: flex property within the .row class, as shown below:

.row {
  display: flex;
}

Take a look at the code snippet provided:

.img-box-kai {
    width: 300px;
    height: 450px;
    border: 3px solid red;
}

.img-box-lucas {
    width: 300px;
    height: 450px;
    border: 3px solid red;
}

.img-box-bryant {
    width: 300px;
    height: 450px;
    border: 3px solid red;
}


.row {
  display: flex;
  justify-content: center; /* Aligning Horizontally */
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
  <div class="row">
    <div class="img-box-kai">Rectangle Test</div>
    <div class="img-box-lucas">Rectangle Test</div>
    <div class="img-box-bryant">Rectangle Test</div>
  </div>
</div>

I trust this information proves to be useful for you!

Answer №3

To ensure proper alignment, it is recommended to include float:left in the style of each element. For example:

  .img-box-kai {
    width: 300px;
    height: 450px;
    float:left;
    border: 3px solid red;
}

.img-box-lucas {
    width: 300px;
    height: 450px;
    float:left;
    border: 3px solid red;
}

.img-box-bryant {
    width: 300px;
    height: 450px;
    float:left;
    border: 3px solid red;
}

Answer №4

To implement this solution, simply insert the following code:

.row{
  display: flex;
  flex-direction: row
  }

.img-box-kai {
            width: 300px;
            height: 450px;
            border: 3px solid red;
        }
        
        .img-box-lucas {
            width: 300px;
            height: 450px;
            border: 3px solid red;
        }
        
        .img-box-bryant {
            width: 300px;
            height: 450px;
            border: 3px solid red;
        }

       .row{
          display: flex;
          flex-direction: row
       }
    <div class="container">
          <div class="row">
            <div class="img-box-kai">Rectangle Test</div>
            <div class="img-box-lucas">Rectangle Test</div>
            <div class="img-box-bryant">Rectangle Test</div>
          </div>
        </div>

Answer №5

To ensure consistent styling, apply the Bootstrap class to each element as shown below:

HTML:

<div class="container">
  <div class="row">
    <div class="img-box-kai col-md-4 pull-left">Rectangle Test</div>
    <div class="img-box-lucas col-md-4 pull-left">Rectangle Test</div>
    <div class="img-box-bryant col-md-4 pull-left">Rectangle Test</div>
  </div>
</div>

CSS:

.img-box-kai {
    min-height: 450px;
    border: 3px solid red;
}

.img-box-lucas {
    min-height: 450px;
    border: 3px solid red;
}

.img-box-bryant {
    min-height: 450px;
    border: 3px solid red;
}

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

Using Twig: Transfer the content of a textfield as a parameter in the routing

I have a task of redirecting to another page while passing along the value from a textfield. Here is my current code: {% extends "base.html.twig" %} {% block body %} <button onclick="host()">Host the session</button> <button onclic ...

Develop a design utilizing a foundational database entity

I'm new to AngularJS and I am seeking guidance on how to properly separate the model from the controller. In my previous experience, I have always integrated models within the controllers. For example: angular.module("app").controller("customerContr ...

Different option to employ instead of utilizing the <br> tag on multiple lines

Struggling with the tedious task of copying and pasting code snippets on my websites. Is there a simpler way to achieve this? I am looking for an option to easily insert <br> at the end of each line. Currently, I am manually adding <br> at th ...

What is the best way to get my loading screen div to cover the entirety of my screen, including all content beneath it?

In order to create a loading screen, I am utilizing PHP to dynamically load specific services for my website. I attempted to set the height of my wrapper div to 100% but it did not produce the desired results. After that, I experimented with setting the he ...

How to adjust the size of the text on a button in jQuery mobile using custom

I am facing an issue with my jQuery mobile buttons that are placed inside a fieldset. Specifically, I need to adjust the font-size of one of the buttons. Despite attempting to add an inline style, it did not have the desired effect. Furthermore, I tried u ...

How to align multiple span elements vertically using HTML and CSS

<div class="row history"> <div class="col col-50 histroy1"> <span class="my-orders">Statistics</span> <span class="my-orders-numbers">27</span> </div> <div class="col col-50 histroy ...

Alter the CSS display based on the user's userAgent if they are using an iPhone and window.navigator.standalone is set to true

Looking to create a unique webAPP with different content displays based on how it is accessed. If the user opens the webAPP through their Safari browser Or if they open the webAPP from a webclip on their home screen The detection is functioning, as conf ...

"The functionality of the personalized checkbox is not working as expected

Having an issue with my custom checkbox where only the first one gets selected when I select the bottom checkbox. I suspect it might be a styling problem, but I'm unsure. I've recreated the issue in a sandbox for you to check out: https://codesan ...

Add CSS styling to input text that is not empty

Is it possible to achieve this using CSS3 alone? var inputs = document.getElementsByTagName("INPUT"); for (var i = 0; i < inputs.length; i++) { if (inputs[i].type == "text") { if (inputs[i].value != "") { inputs[i].s ...

The vertical-align property fails to properly align the list-style-image with the text

My HTML list is structured like this: <ul id="remove"> <li id="rm_txt_1" onClick="remove_1();">Remove </li> </ul> <ul id="move"> <li id="mv_txt_1" onClick="position();">Move Down</li> </ul> It is styled u ...

Increase the Z-Index of the Header above the Material UI Modal Background

Currently, I'm in the process of developing a mobile version of a web application using Material UI. However, I am encountering some challenges when it comes to matching the designs accurately. My approach involves utilizing the MUI App-Bar in conjunc ...

Ways to remove the initial row of inline-block divs

My webpage is filled with inline-block divs that are contained within a larger div like so: <div class="container"> <div class="text">Text 1</div> <div class="text">Text 2 ... rest of the nu ...

The speed at which Laravel loads local CSS and JS resources is notably sluggish

Experiencing slow loading times for local resources in my Laravel project has been a major issue. The files are unusually small and the cdn is much faster in comparison. Is there a way to resolve this problem? https://i.stack.imgur.com/y5gWF.jpg ...

Handling 404 errors in Nginx when using try_files directive for .html files

When presented with this SEF URL /attrazioni/madame-tussauds-londra.html, I am required to retrieve the actual URL which is /index.php?q=/attrazioni/madame-tussauds-londra.html I currently have a directive in place, however, it functions correctly only fo ...

Enhancing Image Quality in Internet Explorer 10

Here is my current situation: I am working on a web page with a responsive design. The layout of the page consists of two vertical halves, and I intend to display an image (specifically a PDF page converted to PNG or JPG) on the right side. The challenge ...

Preserving content following the use of jQuery's fadeIn/fadeOut methods

I have a jQuery function that fades in and out a sprite (sprite without text) from one background to another, and it's working as intended. However, this function is also fading out the text within an element. HTML: <div id="menu"> <ul c ...

Exploring "Additional resources" using Selenium and Python

I am looking to extract text from the "Further reading" section of a Wikipedia article. My current code can open Google, input a request (such as 'Bill Gates'), and then find the URL of the corresponding Wikipedia page. Now I need help parsing th ...

Comparison of element state prior to and post editing (with contentEditable)

Exploring how elements within a div can be monitored for changes made by the user (thanks to contentEditable), I created a sample page with the following setup: before_html = $("#example_div").children(); $("#differences_button").on("click", ...

Ways to conceal and reveal content within div elements

I have a code snippet that is currently operational, but I am looking to enhance it by displaying one div at a time. If you would like to view the code, please visit my CodePen link below: https://codepen.io/danongu/pen/YzXvpoJ Due to the extensive amou ...

Create automatic transcripts for videos, including subtitles and captions

Are there any tools or plugins available that can automatically create a transcript of a video for website playback? For example, generating captions and subtitles in the English language. ...