Make your grid easily expandable with full width capabilities using the power of Bootstrap 4

I am currently working on creating a grid for a gallery that features an expanding preview to showcase more details. I found some helpful code in this informative article: https://tympanus.net/codrops/2013/03/19/thumbnail-grid-with-expanding-preview/ Everything is functioning well, but I am interested in making the design responsive by integrating Bootstrap 4. The challenge I'm encountering is that the expansion feature is confined within the column, restricting it to the same width instead of spanning the entire page width. Is there a way to extend the expansion to full width or position it outside the column?

<section class="films">
    <div class="container-fluid"> 
        <div id="og-grid" class="og-grid row">
          <div class="movie col-md-4">
            <a class="portfolio-box" href="http://cargocollective.com/jaimemartinez/" data-largesrc="images/portfolio/fullsize/1.jpg" data-title="Azuki bean" data-description="Swiss chard pumpkin bunya nuts maize plantain aubergine napa cabbage soko coriander sweet pepper water spinach winter purslane shallot tigernut lentil beetroot.">
              <img class="img-fluid" src="images/portfolio/thumbnails/1.jpg" alt="img01"/>
            </a>
          </div>
          <div class="movie col-md-4">
            <a class="portfolio-box" href="http://cargocollective.com/jaimemartinez/" data-largesrc="images/portfolio/fullsize/1.jpg" data-title="Azuki bean" data-description="Swiss chard pumpkin bunya nuts maize plantain aubergine napa cabbage soko coriander sweet pepper water spinach winter purslane shallot tigernut lentil beetroot.">
              <img class="img-fluid" src="images/portfolio/thumbnails/1.jpg" alt="img01"/>
            </a>
          </div>
          <div class="movie col-md-4">
            <a class="portfolio-box" href="http://cargocollective.com/jaimemartinez/" data-largesrc="images/portfolio/fullsize/1.jpg" data-title="Azuki bean" data-description="Swiss chard pumpkin bunya nuts maize plantain aubergine napa cabbage soko coriander sweet pepper water spinach winter purslane shallot tigernut lentil beetroot.">
              <img class="img-fluid" src="images/portfolio/thumbnails/1.jpg" alt="img01"/>
            </a>
          </div>
        </div>
     </div>
</section>

The initial CSS styling can be found here: https://github.com/codrops/ThumbnailGridExpandingPreview/blob/master/css/component.css

And JavaScript resources are available at: https://github.com/codrops/ThumbnailGridExpandingPreview/blob/master/js/grid.js

Answer №1

The example from Codrops is intricate, making it a challenge to ensure responsiveness.

To achieve the desired responsiveness using Bootstrap, you can utilize the Collapse component along with some JavaScript logic to organize the details column as needed. This approach simplifies the jQuery/JS code and works seamlessly with Bootstrap's grid breakpoints. No additional CSS (besides Bootstrap) is necessary...

// initialize all cols with their natural order
$('.col-md-2').each(function(i,ele){
    let idx = $(ele).index('.col-md-2')
    $(this).css('order',idx)
})

// set the flexbox order of the details col in each row
var calcOrder = function(perRow){
    $('.collapse').each(function(i,ele){
        var idx = $(ele).index('.collapse')
        var modIdx = idx % perRow
        var posi = parseInt((perRow-modIdx) + idx)
        $(this).css('order',posi)
    })
}

// determine number per row based on window width
var breakpoints = function(width) {
      if (width >= 776) {
          //md
          calcOrder(6)
      }
      else if (width >= 567) {
          //sm
          calcOrder(3)
      }
      else {
          //xs
          calcOrder(2)
      }
}

// reset order on window resize
$(window).on('resize', function(){
    var win = $(this)
    breakpoints(win.width())
})

Demo:


Further reference: Bootstrap Expanding Grid

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

Error encountered when attempting to insert data into database due to incompatible data types

I am experiencing an issue with Vue multiselect. I am trying to save the id of selected options in a database, but it seems that I am encountering an error related to Array to string conversion. I have declared both site_id and administrator in fillables. ...

A different approach to splitting strings

After receiving a GET request, I am presented with a string that has the following format: <?xml version="1.0" encoding="utf-8"?> <string xmlns="http://myUrl.com">you said:This is a test --&gt;SHA1:7d9d2886509cfd1dfd3c693fff43b82561ec00a18 ...

Slightly puzzled by the declaration of `var app = express()`

After going over the documentation, I'm still struggling to grasp why we store express() inside an app variable. I attempted to call methods using express().get and .post directly, but was unsuccessful. Why is that? Why doesn't it function in t ...

Tips for hiding the bottom bar within a stackNavigator in react-navigation

I am facing a challenge with my navigation setup. I have a simple createBottomTabNavigator where one of the tabs is a createStackNavigator. Within this stack, I have a screen that I want to overlap the tab bar. I attempted to use tabBarVisible: false on th ...

Every time I try to reload the page in my comment app, all the comments mysteriously

I've noticed that my comment app is functioning properly, but the issue arises when I refresh the page and the comments disappear. Upon checking the log, it seems that the body is inserted into the comments table (it is saved). What could be going wro ...

What is the best approach to connecting a listener to a date selection in the Django admin interface?

My Django admin page features a model with a DateField called 'date': # models.py class Article(models.Model): date = models.DateField( help_text="Article publication date" ) # admin.py @admin.register(Article) class ArticleAdm ...

Leverage Pinia store in Vue helper functions

I have been working on my Vue.js application and I am looking to implement some helper functions that will utilize a Pinia store within the app. These functions need to be accessible by multiple components. Should I define these helper functions directly ...

Conceal a Tag with CSS

Looking to conceal a label using CSS <p class="half_form "> <label for="property_bathrooms">Bathrooms (*only numbers)</label> <input type="text" id="property_bathrooms" size="40" class= ...

Flexbox: Arrange two items horizontally without setting a maximum width

I'm not sure if it's possible with flexbox, but I am looking to create a list with two items displayed side by side where the width of each item adjusts based on the content. Here is an example: <div class="items"> <div class="item"&g ...

Struggling to update local state with response data when utilizing hooks in React

I am a beginner using Functional components and encountering an issue with setting the response from an API to a local useState variable. Despite receiving the response successfully, the variable remains empty and I am struggling to figure out how to resol ...

Issue with jQuery function not recognizing escaped double quotes in PHP script

Greetings! I am currently utilizing a custom control with PHP code. $parentLinkCombo = '<select name="ParentComboLink" onchange="changeChildCombo(\"LICENCE\");" id="ParentComboLink" >'; In order to handle the onchange event, I ...

Removing White Spaces in a String Using JavaScript Manually

I have created my own algorithm to achieve the same outcome as this function: var string= string.split(' ').join(''); For example, if I input the String: Hello how are you, it should become Hellohowareyou My approach avoids using ...

What steps should I take to fix an error in my code?

My current objective is to write a program that generates a square with dimensions of 200 pixels by 200 pixels. The square should be colored using specific RGB values: red (red value of 255), green (green value of 255), blue (blue value of 255), and magent ...

Issue with ngModel being undefined after data has finished loading in Ionic 3

As a newcomer to Angular 4, I've been struggling to find a solution for a seemingly simple issue related to an Ionic app. Whenever a user logs in, the entire user object is saved to localStorage. Despite trying various plugins, I settled on a straight ...

Why is my "npm install" pulling in unnecessary libraries that I didn't even mention?

I've listed my dependencies in package.json as follows: { "cookie-parser": "~1.0.1", "body-parser": "~1.0.0", "express": "~3.5.0", "socket.io":"1.0", "mongodb":"2.2.21", "request":"2.79.0", "q":"1.4.1", "bcryptjs":"2.4.0", "jsonw ...

"Encountering a "404 Error" while Attempting to Sign Up a New User on React Application - Is it a Routing or Port Problem

While working on my React-Express application, I'm facing a "404 (Not Found)" error when attempting to register a new user. It seems like there might be an issue with routing or configuration of the Express server. Being new to React and Express, it&a ...

Generating a fresh instance of a class that mirrors an already existing instance, all without relying on eval()

I have an object named uniqueObject of an unspecified class and I am in need of creating a duplicate object from the same class. Here's my current approach: I extract the class name using uniqueObject.constructor.name. Then, I generate a new object o ...

Sending information from React JS to MongoDB

I am currently facing a challenge in sending data from the front-end (react js) to the back-end (node js), and then to a mongodb database for storage. While I have successfully called the server with the data, I am encountering an issue when attempting to ...

Vue is refusing to display information for a certain API call

Within my next component, I have the following structure: <template> <div class="home"> <div class="container" v-if="data" > <Card v-for="result in data" :img="result.links[0]&q ...

Tips for inserting a jQuery snippet into a universal file

Seeking some advice on integrating jQuery code into my JavaScript file, which is located at . The code snippet I am attempting to add looks like this: $(document).ready(function() { queue = new Object; queue.login = false; var $dialog = $ ...