Effective methods for increasing the height of a column div upon hovering, while also maintaining the position of surrounding columns

Struggling to make this work for 48 hours with no success. Here's the challenge: there is a standard row with regular columns that have an additional product class:

<div class="row">

    <div class="col-lg-4 product">
        // Content
    </div>

    <div class="col-lg-4 product">
        // Content
    </div>

    <div class="col-lg-4 product">
        // Content
    </div>

    .....
</div>

And here is the CSS rule that adjusts the height on hover

.product:hover {
  height: 500px;
}

My goal is to prevent other column divs from moving when hovering over one. I want it to look like this:

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

However, what actually happens is (the columns below shift due to "height overload"):

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

I've attempted various solutions:

  • Setting the product class to have absolute position
  • Setting the product class to have relative position
  • Trying to wrap inner content in another product-wrapper div with different position types (absolute|relative)

Unfortunately, none of these methods worked.

Is it feasible to achieve this using Bootstrap's row columns? If so, how can it be done?

Answer №1

To enhance the presentation of your product div, encapsulate it within a new div that has a CSS property of position: relative. Afterward, configure the product div with position: absolute and utilize Z-index to ensure its visibility over neighboring divs.

<div class="row">
    <div class="product-wrap">
        <div class="product"></div> 
    </div>         
    <div class="product-wrap">
        <div class="product"></div> 
    </div>            
    <div class="product-wrap">
        <div class="product"></div> 
    </div>      
  <div class="product-wrap">
        <div class="product"></div> 
    </div>         
    <div class="product-wrap">
        <div class="product"></div> 
    </div>            
    <div class="product-wrap">
        <div class="product"></div> 
    </div>    
  <div class="product-wrap">
        <div class="product"></div> 
    </div>         
    <div class="product-wrap">
        <div class="product"></div> 
    </div>            
    <div class="product-wrap">
        <div class="product"></div> 
    </div>    
</div>


.row{
    position: relative;
    width:550px;
    height:500px;
    margin: 0 auto;
}
.product-wrap{
    position:relative;
    float:left;
    width:150px;
    height:150px;
    margin:10px;
}
.product{    
    background:black;
    position:absolute;
    top:0;
    left:0;
    width:150px;
    height:150px;
  transition: 0.2s;
}
.product:hover{
    z-index:100;
    width: 150px;
    height:200px;
    background: grey;
}

Answer №2

Another approach would be to utilize the transform scale feature as shown in the example below:

https://codepen.io/designerxy/pen/abc123

<link href='http://fonts.googleapis.com/css?family=Roboto:100,400,300,500,700' rel='stylesheet' type='text/css'>

<div align="center" class="background">
<div style="width:1000px;">

<div class="design_preview" style="background-color:#cb2025;"></div>
<div class="design_preview" style="background-color:#f8b334;"></div>
<div class="design_preview" style="background-color:#97bf0d;"></div>
<div class="design_preview" style="background-color:#00a096;"></div>
<div class="design_preview" style="background-color:#93a6a8;"></div>


<div style=" padding:5px; color:#b5e6e3; font-weight:300; font-size:30px; font-family:'Roboto';padding-top:20px;">CSS <font style="font-weight:400;">HOVER</font></div>
        <a href="http://www.designer.com/code" style="text-decoration:none;" target="_blank"><div style="  color:#b5e6e3; font-weight:300; font-size:20px; font-family:'Roboto';">www.designer.com/code</div></a>

</div>
</div>

.background{position:absolute;padding-top:85px;top:0;left:0; right:0;bottom:0;
 background-color:#00506b;}

.design_preview
{
    display:inline-block;
    border:0;
    width:196px;
    height:210px;
    position: relative;
    -webkit-transition: all 200ms ease-in;
    -webkit-transform: scale(1); 
    -ms-transition: all 200ms ease-in;
    -ms-transform: scale(1); 
    -moz-transition: all 200ms ease-in;
    -moz-transform: scale(1);
    transition: all 200ms ease-in;
    transform: scale(1);   

}
.design_preview:hover
{
    box-shadow: 0px 0px 150px #000000;
    z-index: 2;
    -webkit-transition: all 200ms ease-in;
    -webkit-transform: scale(1.5);
    -ms-transition: all 200ms ease-in;
    -ms-transform: scale(1.5);   
    -moz-transition: all 200ms ease-in;
    -moz-transform: scale(1.5);
    transition: all 200ms ease-in;
    transform: scale(1.5);
}

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

`Is there a way to manage date formats across all components using a single method in Angular?`

I need assistance with controlling the date format of dates displayed in different components using one typescript file. How can I achieve this? app.ts import { Component } from '@angular/core'; @Component({ selector: 'app-root', ...

Adding a div dynamically in AngularJS based on a certain condition

I am facing a challenge with appending the next message content to an existing div in my messages array. I want to avoid creating a new div if the next message id is the same as the previous one. Although my code logic attempts this, it's not quite t ...

What causes certain div content to be absent from ZoneTemplate within an ASP.NET web part?

Check out this snippet of code: <asp:WebPartZone ID="Zone1" runat="server" Width="100%" PartChromeType="None" Padding="0" PartStyle-CssClass="NoPadding" PartStyle-BackColor="Transparent" BackColor="Transparent" PartChromeStyle-BackColor ...

Utilize React Native to showcase JSON data in a visually appealing way by organizing it into titles and corresponding lists for both

I created a live code on Expo.io to showcase JSON data categories as titles and the subs as a list. This code utilizes .map() to retrieve data from an array. import React, { useState } from 'react'; import { Text, View, StyleSheet, Button, FlatLi ...

What is the best way to trigger a javascript modal to open automatically after a specific duration

Let's take an instance where my modal has the ID #modal1. It usually appears through a button-based action. ...

jQuery replacing spaces in id names

I'm encountering an issue with the following HTML and jQuery code. The problem seems to be related to the space in the ID name. HTML <span id="plus one">Plus One</span> jQuery $("#plus one").hide(); Since I'm unable to change the ...

The instance is referencing "greet" during render, but it is not defined as a property or method

At the same time, I encountered another error stating "Invalid handler for event 'click'". <template> <div id="example-2"> <!-- `greet` is the name of a method defined below --> <button v-on:cli ...

What is the best way to align isotope and organize its components?

I have searched for solutions to my issue with centering isotope on my project, but none of the existing answers were sufficient. I am facing challenges trying to center isotope without creating extra space between its elements and arranging them in a spec ...

What steps can I take to ensure that the text content stays within the borders and does not overlap with the photo?

click here for the image description Html <p><img src="index-foto1.jpg" align="left" width=65% style="border-radius: 10px;" margin-right: 2px> <div class="tant"><h3>More detailed inform ...

Submitting an HTML form to a PHP file for processing before returning to the original HTML page for further interaction

I am looking to figure out how I can send a <FORM> from an HTML page to a PHP file that will retrieve data from a database and then return the results to the same HTML page without any redirection. What I aim for is to avoid redirecting users. Take ...

Animate CSS Grid to dynamically fill the viewport on top of current grid elements

Please note that I am specifically seeking vanilla JS solutions, as jQuery is not compatible with this project I have a grid structure that is somewhat complex: body { margin: 0; height: 100vh; text-align: center; } .grid-container { ...

Tips for properly linking external JavaScript files to HTML documents

I decided to delve into the world of HTML and stumbled upon this interesting js fiddle link http://jsfiddle.net/xfkeM/ Now, I am attempting to construct a basic webpage, but unfortunately, the desired output seems to be eluding me. Below is a snippet of ...

Adjusting the size of a division element to match the dimensions

Currently, I am still in the process of finalizing the remainder of the page, but I have encountered a minor issue. The problem lies in my image div not matching the height of the container. Although the image itself is the correct size, the image div appe ...

What is the best way to split an input field into distinct fields for display on the screen?

Take a look at this image: https://i.stack.imgur.com/LoVqe.png I am interested in creating a design similar to the one shown in the image, where a 4 digit one-time password (OTP) is entered by the user. Currently, I have achieved this by using 4 separate ...

No spaces are being retrieved from the input field

After entering "test data" in the first input box and clicking the submit button, only "test" is displayed in another input box. The goal is to have "test data" appear in the script-generated input box as well. Sample HTML Code <input name="" type="te ...

Node.js script encounters errors fetching static files

My HTML index.html file has multiple containers, and I have included the bootstrap and font awesome folders in the <head> section like this: <link href="../bootstrap/css/bootstrap.css" rel="stylesheet"> <link href="../bootstrap/css/bootstra ...

Understanding the hierarchy of LESS css class structure is crucial for

In my chat contact list, each contact can have a different state represented by classes: .online .offline .online .selected .offline .selected Here are the corresponding styles (example): .online { background-color: #fff; p { color: #000; } } . ...

Adjusting the header and unordered list on resize

I need help with my portfolio website. I can't seem to figure out how to make my header and navigation menu stack on top of each other when the page is small, and then go back to their normal layout when the page is larger. Below is the HTML code I&a ...

Achieving navigation bar functionality in Bootstrap using jQuery

Is there a way to make the navbar active when it is clicked? Below is the jQuery code I am currently using: $(document).ready(function () { $('.navbar li').click(function(e) { $('.navbar li').removeClass('acti ...

I've been attempting to adjust the currentTime of an HTML5 video element within a React JS environment, but for some reason it keeps reverting

Need help updating the currentTime of an HTML5 video element with a slider in React JS. My issue is that whenever I adjust the slider, the value resets to 0. The problem seems to be related to the handleChange function which updates the videoRef.current.cu ...