Is it possible to create this design using Masonry?

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

I have been attempting to create a grid layout like so:

.grid {
  width: 99%;
  border: 1px solid #ccc;
}
.grid a, .grid .grid-sizer {
  display: inline-block;
  width: 20%;
  padding-bottom: 20%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.grid a.wx2, .grid .grid-sizer.wx2 {
  width: 45%;
}
.grid a.hx2, .grid .grid-sizer.hx2 {
  padding-bottom: 66%;
}
.grid a.wx2.hx2, .grid .grid-sizer.wx2.hx2 {
  padding-bottom: 33%;
}

Here is my jQuery code:

$(function () {
    $('.grid').masonry({
        columnWidth: '.grid-sizer',
        itemSelector: '.grid-item',
        percentPosition: true,
        isFitWidth: true,
        gutter: 10
    });
});

However, the grid is not utilizing the entire available width.

Do you have any insights into what I might be overlooking?

For reference, here is a link to the jsfiddle:

https://jsfiddle.net/6dL7x8uk/1/

Answer №1

Absolutely, it's completely doable. The code snippet is lacking several components. I suggest implementing it as follows:

<div class="container">
<div class="content">

http://example.com/mycode

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

Utilizing a JQuery plugin in WordPress: A beginner's guide

I have been attempting to utilize a jquery-plugin on a WordPress site, specifically on a single page. I have been following the instructions on this GitHub repository: https://github.com/almightynay/jQuery-Sakura However, despite my efforts, it seems like ...

What are some alternative methods to achieve the same styling in CSS for IE6 without using

Can you please provide the standard equivalents for the following IE6 css hacks? .header { zoom: expression(runtimeStyle.zoom=1); z-index: 1; } .hmenu ul li { float: left !important; } ul.hmenu li { margin-left: expression(this.previousSibling= ...

Using jQuery to submit an array within a form - a comprehensive guide

My goal is to accumulate form data each time the user clicks add_accommodation and add it to an array that will be sent to the endpoint http://server/end/point. <form action="http://localhost:3000/a/b/c" method="post"> <div> <input ...

Place the written content within a spinner on a Bootstrap framework

I have successfully implemented a Bootstrap 4.3 spinner on my website, but I am encountering an issue where I want to add additional text below the spinner. Here is the HTML code I am using: <div class="d-flex justify-content-center"> <d ...

Enhanced Firefox functionality with support for multiple columns

It has come to my attention that Internet Explorer 9 and older versions do not support multiple columns. However, even with the latest version of Firefox, I am experiencing issues with this website loading correctly. Do you have any insight into what might ...

Searching for the most recent selected element from a multiple select tag in jQuery

Incorporating a <select multiple="multiple" id="multi"> on my website, I've implemented a jQuery script with the following function: $("#multi").on("change", function(){}) My goal is to retrieve the most recently selected item from the select ...

Achieving a layout with content above the navigation bar in Bootstrap 4

Could you help me with having the contact information displayed above the navigation? I'm facing an issue where it keeps floating to the left, but I want the content to collapse along with the navigation on mobile devices. Any suggestions on what migh ...

Interactive cascading dropdown selection with ajax and jquery

I'm currently working on setting up a search feature with Dynamic dependent dropdown selection. The first dropdown menu fetches all the regions from the database, and the second one displays the cities corresponding to the selected region. However, I ...

Executing javascript function after the successful completion of 4-5 Ajax requests

My task involves conducting 4-5 Ajax calls and only when all of them are successful, I need to trigger a JavaScript function. Currently, I am using ExtJS for this purpose, although I could also achieve the same with JQuery. What is the best approach to ca ...

Transforming the responsive design of Twitter Bootstrap 2.0 into a fully fixed layout

The GitHub repository for Twitter Bootstrap's 2.0-wip branch now features an innovative responsive layout system. While it's ideal for applications requiring a high degree of responsiveness, I am currently working on a web-exclusive app that dema ...

Choosing individual div elements to assign attributes using event listeners

I've developed a Tic-Tac-Toe game but now I'm trying to figure out how to add colors to the winning squares or draw a line. The CSS for creating the square or line is simple, but I'm unsure about selecting only the winning squares when my wi ...

Employing jQuery UI Dialog to generate a pop-up confirming deletion with a YES/NO option - are you absolutely certain you want

I am currently utilizing jQuery UI Dialog for a popup confirmation message when attempting to delete data. The process involves triggering the dialog upon clicking a specific link, followed by a function to determine if deletion is permitted. If allowed, t ...

Place the child atop the stacked blocks

I need the .square div to always remain at the top, creating a visual effect where it appears as if the following section with its own .square is sliding up and the .square halts precisely at the position of the previous section's square. The code sn ...

The submit button click does not trigger the execution of ajax code

I'm faced with a challenge when trying to implement an ajax call in my form. My goal is to display a spinner on the screen to indicate that the form is processing and submitting information. However, it seems that the ajax call is not being triggered ...

Navigation bar limited to text links only

I've checked out similar inquiries, but I couldn't find a solution that fits my situation. I'm looking to make the boxes around each text link clickable, as opposed to just the text itself. HTML <div class="container"> <ul cla ...

Bizarre IE7 float bug disrupting child elements

<div style="float:right;"> <a href="#" class="button2" title="Upgrade now">Upgrade now</a> <a href="#" class="button2" title="Buy more credits">Buy more credits</a> </div> When the float:right|left property is ...

How to Hide Validation Messages Automatically Using Knockout on Page Load

I have been facing a persistent issue where error messages are displaying onload and I want them to appear only on save. Although I have been successful in many cases and can adjust my code accordingly, this particular bug seems to be causing continuous pr ...

Utilize Jquery, Web Api, and Sql Server to easily store and access PDF and DOC files on your server in binary format

To achieve the task of uploading PDF or DOC files to a server using jQuery, Web API, and SQL Server, we must store them in Binary format in the database. Additionally, we need to be able to retrieve these files and download them onto the client system. ...

Dynamic change of table cell text color based on condition utilizing ng-if and ng-style

I am looking to create a table cell with alternating color combinations based on specific conditions. Here is the code snippet: <tr ng-repeat="x in data"> <td> <span ng-if="((x.time2 < x.time1) || (x.time2 < x.time3))" ng-style="colo ...

The NgbTypeahead element is not able to scroll when placed within a scrollable container

Currently, I am utilizing the NgbTypeahead component from ng-bootstrap. The issue I am facing is that when I place the typeahead component within a scrollable element and proceed to scroll down, the position of the dropdown container remains unchanged. &l ...