Having trouble getting the overflow property to behave correctly in Bootstrap's card-columns? Looking for some pointers on how

When setting a transform scale effect on images in cards within the 'card-columns' of Bootstrap, I noticed that the effect is visible during scaling and then adjusts to fit the card size. The use of 'overflow: hidden' does not seem to have any impact on this issue.

I attempted using 'display:inline-block' as well but found that changing the parent card from 'card-columns' to 'card-deck' achieved the desired behavior. I am hoping to combine the masonry effect of card-columns with the desired overflow effect.

css
.card {
  overflow: hidden;
}

.card .card-img {
  transition: all 0.5s ease;
}

.card:hover .card-img {
  transform: scale(1.2);
}
<div class="container">
  <div class="card-columns">
    <div class="card bg-dark text-white">
      <img class="card-img" src="https://cdn.pixabay.com/photo/2019/03/05/12/26/toque-macaque-4036088_1280.jpg" alt="Card image">
      <div class="card-img-overlay">
        <h5 class="card-title">Card title</h5>
        <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content.</p>
        <p class="card-text">Last updated 3 mins ago</p>
      </div>
    </div>
    <div class="card bg-dark text-white">
      <img class="card-img" src="https://cdn.pixabay.com/photo/2019/06/04/21/53/airplane-4252410_1280.jpg" alt="Card image">
      <div class="card-img-overlay">
        <h5 class="card-title">Card title</h5>
        <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content.</p>
        <p class="card-text">Last updated 3 mins ago</p>
      </div>
    </div>
  </div>
</div>

The goal is to achieve the transform scale effect without the image visibly scaling and then fitting to the container.

Answer №1

When utilizing overflow, it is important to specify the height and Width. See the code snippet below for an example.

.card {
  overflow: hidden;
  width:500px;
  height: 500px;
}

.card .card-img {
  transition: all 0.5s ease;
}

.card:hover .card-img {
  transform: scale(1.2);
}
<div class="container">
  <div class="card-columns">
    <div class="card bg-dark text-white">
      <img class="card-img" src="https://cdn.pixabay.com/photo/2019/03/05/12/26/toque-macaque-4036088_1280.jpg" alt="Card image">
      <div class="card-img-overlay">
        <h5 class="card-title">Card title</h5>
        <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content.</p>
        <p class="card-text">Last updated 3 mins ago</p>
      </div>
    </div>
    <div class="card bg-dark text-white">
      <img class="card-img" src="https://cdn.pixabay.com/photo/2019/06/04/21/53/airplane-4252410_1280.jpg" alt="Card image">
      <div class="card-img-overlay">
        <h5 class="card-title">Card title</h5>
        <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content.</p>
        <p class="card-text">Last updated 3 mins ago</p>
      </div>
    </div>
  </div>
</div>

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

Another element concealing an element underneath

I am currently working on a website and could really use some assistance. Being new to web design, I find myself puzzled by this particular issue. The problem I'm facing is with a sawtooth pattern that should be displayed over a header, similar to the ...

Issue with Scrollspy Functionality in Bootstrap 4

Scrollspy feature isn't working in my code. <nav class="navbar navbar-expand-lg fixed-top navbar-dark" role="navigation"> <div class="container"> <a class="navbar-brand" href="#featured"><h1></h1></a> < ...

Please enter only numerical values using jQuery

Currently, I am facing a slight issue. My goal is to only run the code when the input characters are numbers. This is the snippet of code I have been working with: $(".jq-sales, .jq-variablecosts, .jq-fixedcosts, .jq-additional-sales, .jq-sales-units, .j ...

Is there a way to include a button within the Rails code that would allow users to add a present using the <%= link_to_add_fields "Add A Gift", f, :presents %> function

I'm having trouble figuring out how to insert a button into a link_to_add_fields, like this: <%= link_to_add_fields "Add Another Item", f, :items %> while working on my Rails App. I've attempted to include class: "btn btn-mini btn-info" ...

What is the recommended way to handle passing props to child components in React - should all props be passed down, or only specific props

When it comes to passing props to child components, which approach is more efficient: Method 1. Utilize {...props} to pass all props, for example: ParentComponent = (props) => { return <ChildComponent {...props}> } Method 2. Explicitly pa ...

Methods to prevent images from spilling over into divs?

I am looking to implement a unique functionality that involves three images sliding out of the page to the right, fading in the process, and not overflowing. Simultaneously, three other images slide in to take their place. If you want to see the Framework ...

Why is my CSS and Bootstrap full-page image not displaying properly?

I've been struggling to get a full-page image to display on my website and resize responsively across different screens. I've searched through w3schools and Stack Overflow for solutions, but no matter what I try, it just doesn't seem to work ...

Issue with displaying images in Bootstrap carousel

I'm facing a challenge with integrating a bootstrap carousel into a website project I'm customizing for a client. Despite my efforts to add photos and captions, the images are aligning in a list format and the captions are stacking on top of each ...

Is there a way to navigate through the content of a table without causing the header of the table to shift?

Is there a way to make the tbody scrollable while keeping the thead fixed in place? I attempted the following code but it did not produce the desired results: tbody { height: 200px; overflow: auto } I also experimented with using overflow:scroll; wit ...

Applying a specified style to a pseudo element using the ::after selector to display an

Can anyone help me with adding a pseudo element ::after containing an icon (from FontAwesome) to my Bootstrap Vue ProgressBar? I want this icon to be dynamic and move along the progress bar line when I click. Here is my current implementation, where the Pr ...

In the development environment, assets are concealed from view

In the HEAD block of my code, I have the following: {% stylesheets filter='yui_css' output='css/base.css' '@MutualContratosBundle/Resources/public/css/ui/south-street/jquery-ui.css' '@MutualCo ...

What is the best way to transform this into an HTML readable code?

While browsing through a template, I came across this code and I'm unsure of how to get it functioning. I've tried removing the comments, but unfortunately it doesn't seem to be working as expected. li.dropdown.navbar-cart ...

Prevent the content within a Bootstrap "row" from moving to a new line

My website appears differently in desktop and mobile view. https://i.sstatic.net/MGJSk.png While the tags align perfectly on desktop, they overflow onto a new line in the mobile view. Specifically, #pytorch and #tensorflow are pushed to a new line which ...

Is it possible to use rounded divs and buttons exclusively on iOS devices? Leveraging jQuery, AJAX,

Recently, I have been developing a client application that consumes an API and dynamically generates buttons. The project has been running smoothly on various platforms, with Chrome dev tools indicating no issues on any device. However, after testing it on ...

absence of a scrollbar on smaller window display

My website is experiencing an issue: everything displays properly when the window size matches or exceeds the background image, but on a smaller window, there is no scroll bar which causes the footer to disappear. Here is an image showing what happens wit ...

Issue with Dependent Drop Down functionality

I am a beginner explorer diving into the world of PHP & MySQL, and I am currently working on creating a dependent drop-down list. The first drop-down seems to be working fine, but I am facing issues linking the second drop-down with the first one. Can anyo ...

Center the navbar menus at the bottom

Trying to position two menus on a webpage can be challenging. One needs to show at the center bottom, while the other should appear in the top right corner. When attempting to achieve this layout, it's important to ensure that both menus are displayed ...

buttons for displaying a slideshow using jquery

I've been struggling with a problem for a while and I'm trying to find a solution. Here's the link to my slideshow: http://jsfiddle.net/Jtec5/33/ Here are the CSS codes: #slideshow { margin: 50px auto; position: relative; width: ...

Utilizing the React.js Bootstrap grid system

I've been diving into React, but I'm facing an issue with the bootstrap grid/reactstrap. Instead of getting horizontal columns as expected when using the grid system, I seem to be stuck with a vertical layout. Film.js import React from "react"; ...

"Enhance Navigation: Sublevel Dropdowns with the Power of Twitter

Here is a link to my fiddle: http://jsfiddle.net/xkXdy/ I am trying to create submenus for the dropdown input box in my project. Currently, it only shows the category, but I want it to display subcategories when hovered over. The dropdown functionality wo ...