How can I make a DIV grow taller without impacting neighboring DIVs?

I am working on expanding a specific DIV within a series of DIVs for an image gallery. However, I am facing an issue where when I expand the particular DIV, it affects all the following ones and causes them to shift positions, leaving a large blank space that is not desired.

I have tried using various CSS properties on the specific DIVs, such as setting the height to 250px and adding a margin-bottom of 100px, but none of them have yielded the desired outcome so far.

The CSS used:

.thumb {
  float: left;
  margin: 5px;
}

#gallery {
  width: 850px;
}

The HTML structure:

<html>
    <head>
        <title>asd</title>
    </head>
    <body>
        <div id="gallery">
            <div class="thumb">
                <img src="https://picsum.photos/155/155?image=0">
            </div>
            <div class="thumb">
                <img src="https://picsum.photos/155/155?image=100">
            </div>
            <div class="thumb" style="height:250px;"> <!-- specific DIV to expand vertically !-->
                <img src="https://picsum.photos/155/155?image=200">
            </div>
            <div class="thumb">
                <img src="https://picsum.photos/155/155?image=350">
            </div>
            // more images here
        </div>
    </body>
</html>
// include information about the result currently obtained and the desired end result

I have created a fiddle to demonstrate the issue: https://jsfiddle.net/537ayfwc/

In order to work around this issue, I have temporarily added an invisible DIV between every 5 pictures to act as a separator. However, I am looking for a solution that does not require this additional element as it may interfere with future JavaScript animations planned for the gallery.

Answer №1

Uncertain if this meets your needs.

.image{
  float:right;
  margin:10px;
}

#collection{
  width:900px;
  display: flex;
  flex-wrap: wrap;
}

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

Having trouble with CSS Transition functionality not functioning properly

I have set up a temporary page with a two-word message in the h1 tag. The h1 has a CSS3 infinite transition for shadow animation. The shadow is visible on all sides, but it does not transition smoothly. The shadow changes abruptly at regular intervals. I ...

Conditionally submit a form using JQuery

I need to implement a validation condition using jQuery for a form submit button. The requirement is that the form should only be submitted if the user enters a valid email address. HTML code : <form method="post" action="{% url sportdub.views.login ...

Determining the orientation of an image in JavaScript

Currently, I am attempting to determine the orientation of images using JavaScript in order to apply a specific class to them. This process seems to be functioning correctly on Firefox, but is presenting challenges on other browsers. It appears to work bet ...

Interactive Div that Adapts

Hello everyone, I'm new to this forum and seeking some assistance. I have a requirement where multiple div contents need to fade in and out dynamically. I found this jsfiddle example that works for 2 divs, but I want it to work for more, say 5 differ ...

Learn how to utilize interpolation within an *ngIf statement in Angular 2 in order to access local template

Consider the following scenario; <div *ngFor="item of items; let i = index;"> <div *ngIf="variable{{i}}">show if variable{{i}} is true</div> </div> Suppose I have variables named "variable0", "variable1",... Is there a way to ac ...

CSS for a Dropdown Menu with Multiple Layers

I've successfully implemented a dropdown menu, but now I'm facing the challenge of adding another level to it. Specifically, I want a second level to drop down when hovering over "Test3". What do I need to add or modify in the code to achieve thi ...

JsPlumb: Incorrect endpoint drawn if the source `div` is a child of a `div` with `position:absolute`

My current setup involves two blue div elements connected by jsPlumb. You can view the setup here: https://jsfiddle.net/b6phv6dk/1/ The source div is nested within a third black div that is positioned 100px from the top using position: absolute;. It appe ...

Code is not running in ReactJS

My challenge is to use canvas and script to draw a rectangle with one diagonal line. However, when I try to do so, only the rectangle appears on my browser. It seems like the script is not being executed. Here's the code: import React, { Component } ...

Retrieving the ID from the element that was clicked

Here is a code snippet that allows for the changing of color and text when an href link is clicked. /* Function to change the color of the button upon click */ function changeColor(element) { alert(element.target.id); if (element.innerHTML == "Selec ...

"Learn the steps to efficiently input multiple data entries with the same name from a single form into different rows within the same column of

How can I modify this form to insert four separate data entries in the same column upon submission? <form action="entry.php" method="post" > <table> <tr> <td> <input type="text" name="searchid[]" id="searchid" placeh ...

Ways to modify color while user moves the screen

I'm working with some jQuery code that changes the colors of elements as the user scrolls down, and I want it to revert back to the original color when scrolling back up. However, the script is not behaving as expected... Here is the original working ...

how to quietly change the focus of an element using jquery and css?

Whenever I modify the CSS of a scrolled-past element, the view abruptly jumps to that particular div (by scrolling up) upon applying CSS changes using .css(...). Something as simple as adjusting the background-color can trigger this effect. Is there a wor ...

Guide on implementing CSS modules in a WordPress plugin built with React

Within one of my tsx files, I included this line: import styles from "../../styles/buyTicket.module.css"; This resulted in the following error message: ERROR in /Applications/MAMP/htdocs/wp-content/plugins/tikex/tikexModule/components/BuyTicket/ ...

What is the best way to create a border that surrounds a collection of pictures?

I'm currently facing a challenge in getting a border to perfectly fit around a collection of images. The issue can be observed in this Jsfiddle I shared, where the border aligns with the top and left edges, but not with the bottom and right edges. Her ...

Creating a table with a static first column and vertical text positioned to the left of the fixed column

To create a table with the first column fixed, refer to this fiddle link: http://jsfiddle.net/Yw679/6/. You also need a vertical text to be positioned to the left of the fixed column in a way that it remains fixed like the first column. The disparities be ...

Utilizing JavaScript Callbacks in HTML Image Tags

Currently I am working on a small application and looking to include a YouTube section. I have come across a method for obtaining the user's YouTube icon: This is included in the head section of my code: <script type="text/javascript" src="http:/ ...

The responsive class seems to be malfunctioning within the Laravel 5.3 framework

I have a project that involves Laravel and Vue.js. In my Laravel project, I am importing Bootstrap CSS using the following line: // Bootstrap @import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap"; This import is done in the app.scss file. ...

What is the method for creating a HTML test report using Python incorporated into my code?

from selenium import webdriver import unittest, time, re import HTMLTestRunner class TestAutomation(unittest.TestCase): def setUp(self): self.errors = [] self.driver = webdriver.Chrome() self.driver.get("http: ...

What is the best way to horizontally center a div while ensuring the content within the div stays aligned?

I'm attempting to align a div in the center while maintaining the position of its contents. Check out my code snippet: <style> .wrap{ position: relative; } .character{ position: absolute; bottom: -10%; left: 0; heigh ...

Loading images in advance with AJAX for enhanced AJAX performance

My website is structured in a sequential manner, where page1.html leads to page2.html and so on. I am looking to preload some images from the third page onto the second page. After searching, I came across this amazing code snippet: $.ajax({ url ...