Why is my inline-block property causing my elements to stack vertically instead of aligning them horizontally from left to right?

Working on a dynamic layout using divs with display:inline-block to accommodate varying content heights. However, the displayed order of my divs is not as expected.

1357
2468

I would like them to display as:

1234
5678

My code snippet:

article{
 -moz-column-width: 13em;
 -webkit-column-width: 13em;
 -moz-column-gap: 1em;
 -webkit-column-gap: 1em; 

}

section{
 display: inline-block;
 margin:  0.25rem;
 padding:  1rem;
 width:  100%; 
 background:  #efefef;
}

Link to my JSFiddle

Answer №1

The reason for this is the column CSS property, which arranges elements in vertical "columns".

If you want a horizontal layout, you can utilize display: inline-block or opt for an JS plugin like masonry.

Try out inline-block alignment here

Answer №2

Have you experimented with inline-flex display? Check out the demo I built on jsFiddle here

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

Utilize jQuery to extract URL parameters and incorporate them into a script

I have a unique link: http://mywebsite.org/product/page?var_one=result1&var_two=result2&var_three=result3&var_four=result4 The values can vary, meaning the parameters are not fixed. My example includes 4 parameters, but there could be more ...

Exploring ngModel components with a specified class

In my HTML code, I've assigned many elements with ngModel defined as ng-model = "object.[something]". For example: <div class="form-group row" ng-model="object.askUser"> I use this method to keep my purpose clear for these elements. My questi ...

CSS Trouble with Stacking Order

Seeking assistance with my learning/practice journey, any help is greatly appreciated. Please feel free to point out errors or inefficiencies. I currently have four layers in place: .body .main .main-side .sidebar Here is the design I'm trying to r ...

Retrieve information from an HTML table on a website and transfer it to a spreadsheet in Excel

I'm looking for assistance with extracting data from a website using VBA. I have an Excel table with ETF tickers, links, and prices, and I'm attempting to retrieve the previous day's closing price from each link using VBA. The challenge I&ap ...

Is there a way to display data in a checkbox field using PHP and JQuery Mobile?

I am currently working on a challenge in viewsessions.php. My goal is to retrieve multiple values from a database and group them into checkbox fields (such as typeofactivity, employer, date, time, amount as one combined checkbox field) using <input type ...

When using Vue.js, binding may not function properly if it is updated using jQuery

Link to JsFiddle Below is the HTML code: <div id="testVue"> <input id="test" v-model="testModel"/> <button @click="clickMe()">Click me</button> <button @click="showValue()">Show value</button> </div& ...

Experimenting with jQuery in a .php file on a local server but experiencing issues with functionality

Currently, I am working on a login page that involves a specific functionality. When the user clicks on the "I'm a Student" button, I want to achieve a slideDown effect to hide one div and show another div with a slideUp effect. While I have confidenc ...

Achieve seamless transitions between animations when hovering with CSS3

I am facing an issue with an element that has a CSS3 animation. When the element is hovered over, the animation changes to another infinite one. While everything is functioning correctly, the transition between animations sometimes feels too abrupt and b ...

Manage your video playback by tracking the movement of your mouse on the screen

Is it possible to use mouse position on screen to control a video? Imagine, if I have my cursor on the left side of the screen, the video starts from the first frame. But as I move my cursor to the right side, the video progresses until the cursor reaches ...

Extract the date and time information from the API response

I have received a response array from an API that I need to work with. Take a look at the response below: [{createdBy:"user1", updatedDttm: "2022-01-20T07:31:35.544Z"}, {createdBy:"user2", updatedDttm: "2022-02-20T09:31:3 ...

Could a jquery slick carousel be used to modify the body background of a webpage?

Is it possible to have one of the divs in a carousel change the background of the page, while the carousel is active on that specific div? if ($('.carousel').slick('slickGoTo', 1)){ //if slick is on slide index 1 //change to another pag ...

Display or conceal div based on chosen options

I am working on a feature that involves three dropdown select boxes, each containing different sets of demographic attributes. My goal is to show a score based on the combination of selections made by the user. For example, if a user chooses Male, 18-24, A ...

Identifying the validity of specific conditions and proceeding with additional actions if confirmed

I'm working on a game for a class assignment and I need help creating a function that can determine whether the main hero character is within a specified boundary. If the hero character is within the bounds, the function should trigger a series of con ...

Wowslider is functional, however it fails to show the images

As a brand new user with limited knowledge, I am determined to figure things out on my own and make progress. Currently, I am using Wowslider on my website to showcase images. Although the slider (carousel) is functioning properly, it is not displaying a ...

What is the best way to add animation to a button within a form using CSS?

Creating a Form in index.html: <form id="mc-embedded-subscribe-form" class="validate" name="mc-embedded-subscribe-form" method="post" action="mailing.php"><pre> <fieldset> <div class="mc-field-group"> <div class="input-cont"> ...

Learn the method for switching between exclusive visibility using Bootstrap class toggles

I've set up a jQuery function that toggles the visibility of different divs when clicking on folder icons: $(document).ready(function() { $("#techfolder").click(function(){ $("#txt").toggleClass("d-none"); }); $("#persfolder").click(functio ...

Step by step guide to creating individual counter sections

I have set up a counter section where the numbers go from 0 to a specific value. However, currently all three counters start counting simultaneously. Is there a way for the first counter to count up first, then once it's done, move on to the second c ...

Data bindings encapsulated within nested curly braces

I am currently utilizing Angular2 in my application. Within my html file, I have a *ngFor loop set up like so: <div *ngFor="let element of array"> {{element.id}} </div> Next, I have an array containing objects structured as follows: some ...

What is the best way to link CSS files from libraries that are downloaded using npm?

For instance, let's say I installed a package: npm install --save package and it gets saved in ./node_modules/package/ Inside that folder, there might be a directory named styles and within that directory, you could find style.css. How can I link ...

Having Issues with jQuery UI Date Picker?

Recently, I customized a stylish skin for my date picker. However, when the "run" button is clicked, a black bar appears underneath it. Strangely enough, once you click on the input and then on the page, the bar disappears. Is there a way to remove this ...