What causes the image within a resized div to decrease in size rather than resizing proportionately with the parent element?

I'm experimenting with creating a hover effect on a div that scales the entire element slightly. It's working well, but I noticed that when I insert an image inside the div, it shrinks instead of scaling along with its parent.

To better demonstrate the issue, I've set up a fiddle: Check it out

<main>
  <div class=" w-100 row">
    <div class="col-6">
      <div class="base square clickable">
        <div class="content">
          <div class="d-flex align-items-center justify-content-around flex-column h-100">
            <img src="test.jpg" alt="Company" width="50%">
            <h4 class="mt-2">Company Name</h4>
            <h5 class="mt-2">Zusatz info</h5>
          </div>
        </div>
      </div>
    </div>
  </div>
</main>
.base {
    background-color: grey;
    border-radius: 30px;
}

.square {
    padding-bottom: 100%;
    margin: 10px;
}

.content {
    position: absolute;
    top: 15px;
    bottom: 15px;
    left: 15px;
    right: 15px;
    text-align: center;
}

.base img {
    border-radius: 50%;
    height: auto;
}

.base.clickable {
    transition: transform 300ms;
}

.base.clickable:hover {
    cursor: pointer;
    transform: scale(1.05);
}

Can anyone figure out why the image isn't scaling properly in this scenario?

Answer №1

style{position: fixed;}

detach the element from the regular document layout to prevent it from resizing based on parent size

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

Attempting to implement real-time AJAX search feature in the sidebar

I am fairly new to AJAX searching and still getting the hang of Rails. My goal is to add a search form to the sidebar of my app that appears on every page, with search results displaying on the current page only when a search query is entered. Currently, ...

The Angular 6 watcher fails to compile the imported less files within the main.less file

Currently, I am developing in Angular version 6 and utilizing Less for styling purposes. In previous Angular versions, I utilized the angular_cli.json file to include the main Less file, which functioned properly. Now, in the latest Angular 6 version, I ...

JavaScript - identifying specified tags within a given string

I have created an array containing some tags: var myArray = [ "mouse", "common", "malcom", "mountain", "melon", "table" ]; Now, I need to extract these defined tags from a given string. For instance, from the string: the mouse is ...

"Aligning the logo and navbar links to appear on the same line

I'm looking to align the logo and the navigation bar links on the same line. The logo should be displayed alone when viewed on a mobile device. Here's how it currently appears: Currently shown on two lines. This is the HTML code for it: ...

As I resize my browser window, the navigation on my webpage gracefully transitions to multiple rows

As a newcomer to this, I'm wondering how I can keep everything in place regardless of how much I resize the window. Any tips? ...

Adjust the width of the offcanvas menu to display on the right side of the screen

I am currently working with zurb-foundation 5.3 and, since I am not familiar with scss, I have opted to use the css version of foundation 5.3. Following a basic example for an offcanvas menu from the foundation docs, I noticed that the default width did no ...

Trouble with jquery function checking for 'active' class on ul#navigation li upon page load

$(document).ready(function(){ $("li").click(function(){ if ($(this).hasClass("active") ) $(this).fadeTo("slow", 1.0); }); }); Creating a navigation bar and utilizing code to implement a transparency effect on hover: $(document).rea ...

What is the best way to transfer a request parameter from a URL to a function that generates an object with matching name in JavaScript?

I need to figure out how to pass a request parameter from an express router request to a function that should return an object with the same name. The issue I'm facing is that the function is returning the parameter name instead of the object. Upon c ...

Are you sure all of your statements have been successful? This is the problem

Implement a selection sort algorithm that swaps values at a given position with the minimum value index. Use the swap and indexOfMinimum functions provided below. Despite following the logic, there seems to be an issue preventing the code from successful ...

What is the best way to handle the rows that have been checked in the table?

Imagine you have the given table structure: <table> <thead> <tr> <th>Column 1</th> <th>Column 2</th> <th>Column 3</th> </tr> </thead> <tbody> <t ...

Add CSS properties to child elements that are not of a specific selector, while styling their descendants without any restrictions

Seeking assistance for an Angular application, but the query also pertains to CSS principles in general. In my Angular project, I have a main component containing several child components, all with standard view encapsulation. Specifically, I am looking t ...

Unable to include checkout and clear cart buttons in popover within bootstrap 5

I am currently working with BootStrap version 5.0.0 beta-2 and facing an issue when attempting to dynamically add a button within my popover. I have ensured that the scripts are included in the following order: <script src="https://ajax.googleapis. ...

Is there a way to avoid choosing based on incomplete attributes?

If .animal {background: yellow} applies the styling rule to any elements with a class that includes the word animal, even if it has other words such as... <li class="toy animal">Toy Bear</li> then why use the below syntax for selecting by p ...

Adjusting the display property using the CSS plus symbol operator

I am currently in the process of designing a dropdown menu using CSS. The focus is on utilizing the following code snippet: #submenu_div { display: none; } #li_id:hover + #submenu_div { display: block; } UPDATE: Here is the corrected HTML structure ...

Having issues with Thymeleaf template not functioning properly when using inline JavaScript

I've encountered an issue when attempting to extract my function into a script within HTML. When written as shown below, it works perfectly: <input type="text" id="myInput" onkeypress="return confirm('Are you sure you want to delete ...

Fast screening should enhance the quality of the filter options

Looking to enhance the custom filters for a basic list in react-admin, my current setup includes: const ClientListsFilter = (props: FilterProps): JSX.Element => { return ( <Filter {...props}> <TextInput label="First Name" ...

iOS - Embedding text into a UIWebView input field

Just a quick question - if a textfield in a webform does not automatically have the focus set by the form, meaning you have to press the field before the keyboard pops up, am I correct in assuming that the field cannot be edited? In simpler terms - is it ...

angularjs determining the appropriate time to utilize a directive

I have been delving into JavaScript and AngularJS for approximately a month now, but I still find myself unsure of when to use directives. For example: I am looking to display appointments in a table with the date as the table header. I envision having bu ...

What is the best way to group data by a specific value within a nested object when using ReactJS material-table?

I have a unique scenario where I possess an array of individuals featuring a nested object known as enterprise. My objective is to effectively group these individuals by the value of company.name within the confines of the Material-Table. const people = [ ...

Using async-await to handle an array of promises with the map method

I have come across several discussions on the same error but none of them solved my issue. Here is the code I wrote: const userOrganizationGroups = (organizationGroupsList) => { if (Array.isArray(organizationGroupsList) && organizationGroupsLi ...