Troubleshooting: Addressing the issue of two floated divs not aligning properly

I have the main section called panel-body with packages nested inside. The packages are displaying properly inside the panel-body and stacking in a row.

If you want to see it live, visit:

Although I attempted to use float:left; in my package CSS, the packages did not align within the body as expected.

To illustrate:

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

Removing the float:left; property solves the alignment issue, but then the packages do not display three per row like desired.

See here:

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

Below is the CSS for my packages:

.package {
    width: 33.33333333%;
}

And this is the CSS for the panel-body:

.panel {
    margin-bottom: 30px;
    background: url(https://castiamc.com/buycraft/bordersv2/Middle.png);
    width: 850px;
    border: none;
    border-radius: 0;
    position: relative;
    min-height: 300px;
    padding: 20px;
    color: #fff;
}
.panel-body {
    padding: 15px;
    text-align:justify;
}
.panel .panel-body {
    color: #3d3e3f;
    box-sizing: border-box;
    position: relative;
    max-width: 750px;
    top: -75px;
    left: 13px;
}
<div class="package">
<img src="'.(isset($image) && $image!="" && ($it == 1 || $it == 3 || $it == IMG_JPEG) ? $image : "img/404.jpg").'" class="img-rounded img-responsive" style="width:250px; height:168px;">
</div>

Currently, my goal is to have each row in the panel-body display three packages side by side.

Answer №1

To ensure the proper display of packages, include a new class called clearfix in the parent element and define it in your CSS file:

.clearfix:after {
  content: " ";
  display: block;
  clear: both;
}

By applying this clearfix class, you are correcting the positioning of floated elements within the parent container, restoring its natural flow.

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

When the fullscreen modal is opened, the initial image displayed is not the same as the one that was clicked on

Seeking assistance: I've been struggling with a problem for quite some time now and could really use some help from you guys. My issue involves an 'AngularJS' webapp that retrieves posts from an 'FB page' via 'OpenGraph' ...

Tips for integrating ng2-dragula into an Angular 2 project

How can ng2-dragula be implemented in Angular 2? Here's the code snippet, ****viewer.component.ts**** import { Component, Input, Output, EventEmitter } from '@angular/core'; import { Injectable } from '@angular/core'; import { ...

Finding unique data stored in separate JSON files and loading them individually may require using different methods for

I have two JSON files named marker.json and marker.json0 that contain different latitude and longitude coordinates. To load them, I need to rename .json0 to .json (and vice versa), so that the new data from marker.json0 now resides in marker.json. This way ...

The functionality of $(this).data seems to be malfunctioning

I've spent the last couple of hours doing research but still can't seem to figure this out. I'm using ajax to load content, and for some reason $(this).data is not working as expected. If I replace this with the actual class, the content lo ...

Vertical Graph - Utilizing HTML and Cascading Style Sheets

My goal is to create a vertical bar chart that looks like this: However, the result I am currently getting is different: At the bottom of my vertical bar chart, both lines are connected together and I am trying to figure out how to separate them. I am a ...

What can be done to adjust the Height in this specific section?

Utilizing a fancy JQuery plugin called Quovolver, I integrated quotes and short messages into my web-based application without any issues. However, I encountered a problem with the quote display area, as I aim to set a fixed height for it rather than allow ...

The text does not automatically move to the next line

How can I make the content in this form section wrap to the next line in a list-item and overlap the width of the div content? The second line, particularly where it mentions Security Question two https://i.sstatic.net/5CVi2.png This is my HTML & CS ...

Is there a way to remove the entire row if I dismiss a bootstrap alert?

Hey there! I'm having a little issue with an alert in a row-fluid. Curious to see? Check out my fiddle. So, when I click the "x" button to dismiss the alert, the row is still visible. Any idea how I can make the entire row disappear when I dismiss it? ...

Retrieve Array Field from PHP CURL Response (Response Presented in HTML)

Currently, I am utilizing PHP CURL and receiving the data in HTML format as a response. The data is being returned in array format, so my question is how can I extract the necessary information from that array. I need to store the response in the $respo ...

Incorporating object into main function of VueJS root component

I have integrated VueJS into my HTML template for an application. When a button is clicked, it passes the object of a component to its root in the following manner: <button v-on:click="$root.savePlan(dataObj)"></button> The dataObj is passe ...

The Evolution of Alternatives to contentEditable

Related: ContentEditable Alternative I am curious about the timeline of online WYSIWYG editors prior to the existence of contentEditable. I remember using GDocs and GMail with rich-text features that functioned similarly to contentEditable. I would appre ...

Is there a way to incorporate CSS into an element utilizing jQuery when only a class is available for identification, and when the time in the innerHTML is within a 5-minute range from the current time?

I have some HTML code that I need help with: <td class="mw-enhanced-rc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;18:10&nbsp;</td> My goal is to use JavaScript to make the time bold. $('td[class^="mw-enhanced-rc"]').eac ...

What is the best way to trigger an onclick event for an input element with a type of "image"?

In the code I'm working on, there's an input of type "Image". <div class="icon" id="button_dictionary"> <form> <input class="buttonDictionary" type="image" src="icone_dicionario.jpg" value="" id="inputDictionary"> ...

Customizing Material-UI: A guide to overriding inner components

Looking to customize the styles of a Material UI Switch for the small variation? I have applied global styles but now want to override the styles of elements like track and thumb. Targeting the root element with the sizeSmall class is working, but unsure o ...

`how to showcase a collection of items in a horizontal layout`

My goal is to showcase Groups in a horizontal layout, with each group displaying its members. Here's an example: Group 1: Group 2: Group 3: 1. Joe Blo 1. Bob 1. etc.. 2. Joe smith 2. Billybob 3. Joe g ...

Is there a way to add styles to template literals?

Currently, I am utilizing template literals in my React project to display data. However, I am looking to style the email portion of the data. Is there a way for me to apply inline styles to this template literal? Any suggestions on how I can achieve thi ...

<p> The box is massive, and its size is a mystery to me

https://i.sstatic.net/xPoDz.png Why is the box around my paragraph tag so large? I suspect this could be why I am unable to move the <p> tag down with margin-top: 50px; .train p { margin: 0; font-size: 2.5vw; } <div class="train"> < ...

What steps should I take to troubleshoot the JavaScript dropdown list on my webpage

I'm having some trouble with my dropdown list code. My goal is to be able to select an option from the list and have it display an image with some text, but I seem to be missing something. Here's what I have so far: <form action=""&g ...

Incorporate a vertical scrollbar in the tbody while keeping the thead fixed for smooth vertical scrolling

I'm seeking a solution to implement horizontal and vertical scroll for my table. Currently, the horizontal scroll is working fine, but when trying to add vertical scroll, the table header also moves along with it. Is there a way to keep the table hea ...

Guide to organizing a Bootstrap grid with 4 varying sizes of boxes

I'm just starting out with Bootstrap and I want to create a grid that resembles this design: https://i.sstatic.net/AQj53.png Below is the code I've written, but it's not quite giving me the layout I want: <!doctype html> <html> ...