Implementing a dual hover effect on a Div element

I am working with HTML code that includes an image and text

<div class="subcontainer1">
    <img src="a.png" alt="" class="imgcolumn">
     <h3 class="header3">Hello</h3>
</div>

This setup places the content above the image.

I'm attempting to apply two different CSS effects on a single hover event.

Specifically, when hovering over a div with the class subcontainer1, I want the image to shrink and the text to grow.

CSS for shrinking and growing elements:

.grow {
  display: inline-block;
  -webkit-transition-duration: 0.3s;
  transition-duration: 0.3s;
  -webkit-transition-property: transform;
  transition-property: transform;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  box-shadow: 0 0 1px rgba(0, 0, 0, 0);
}
.grow:hover, .grow:focus, .grow:active {
  -webkit-transform: scale(1.1);
  transform: scale(1.1);
}

/* Shrink */
.shrink {
  display: inline-block;
  -webkit-transition-duration: 0.3s;
  transition-duration: 0.3s;
  -webkit-transition-property: transform;
  transition-property: transform;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  box-shadow: 0 0 1px rgba(0, 0, 0, 0);
}

Is it possible to achieve this effect on hover, or am I setting my expectations too high?

Answer №1

Is this the type of solution you were looking for?

.box:hover img { transform: scale(1.2); }
.box:hover h4 { transform: scale(0.8); }

Try it out: http://jsfiddle.net/6hLcs/

Answer №2

When hovering over .subcontainer1, you can apply a style to img or h3 like this:

.subcontainer1:hover img{
      -webkit-transform: scale(1.1);
      transform: scale(1.1);
    }


    .subcontainer1:hover .header3{
       /*Your style*/
    }

Check out the demo here!

Answer №3

In html, the .grow and .shrink classes are not built-in, so to implement them, you need to add the following code:

.subcontainer:hover{
    /* css rules */
}

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

Accessing Microsoft SQL Server Data in Cordova Application utilizing PHP

While I have experience creating simple mobile apps in Cordova, I am now looking to delve into the world of creating database apps. A database app for me means integrating MSSQL Server, HTML, and PHP. In my quest for information on this topic, I scoured v ...

Border Effect Resembling Windows Tiles

When you hover your mouse over a tile in Windows, a cool effect happens: Hovering outside the tile, but within the container area: Hovering inside a tile: Hovering outside a tile at its mid point, causing opposite sides to light up: I'm lookin ...

Creating a see-through effect for dijit.Dialog as it appears

Utilizing the dijit.Dialog library, I have implemented a Dojo Dialog box that appears on a Rowclick event of a Dojo grid. I am looking to make the Dialog box transparent or reduce its opacity so that the background is visible and it looks visually appealin ...

What is the best way to manage a batch of files in a response from an Ajax POST request?

Currently, I am utilizing the OGRE web client to convert GeoJSON text data into ESRI shapefiles by making a POST request with Ajax. var data = { "type": "FeatureCollection", "features": [{ "type": "Feature", "geometry": { "type": "Point", "coord ...

React 15 is found to be incompatible with React-redux due to certain compatibility

I'm currently working on upgrading to the newest version of [email protected] in my project, which also utilizes the react-redux@^4.4.0 package. However, I encountered issues when attempting to follow the upgrade instructions provided in the documenta ...

Utilize Mapbox-GL.JS to animate several points along designated routes

I'm encountering issues with the following example: Animate a point along a route My goal is to add another point and routes in the same map container. Here's what I've tried so far: mapboxgl.accessToken = 'pk.eyJ1IjoicGFwYWJ1Y2t ...

When Css is incorporated within a text, it prevents the use of " " from functioning properly

I am currently developing a GUI application using Qt 4.8. I have a label that displays text in white (the stylesheet has already been set up for this) and I want to change the color of the word "UPDATE" to red. Here is my initial code: //all text in whit ...

Steps for modifying material-ui timepicker to display time in a 24-hour format

Presently, I am utilizing a Timepicker from material-ui. It is currently configured with type="time", allowing me to select times throughout the day in 12-hour increments with an AM / PM choice. However, I wish to adjust my picker to a 24-hour format, elim ...

Guide to establishing accurate $key=>$value connections in a JSON document using PHP or jQuery

Looking for assistance on reformatting my JSON file to transform a value within an array into the key for that array. Initial format { "ID": "M-420", "ProductName": "example product name ", "ProductDescription": "example description", "Co ...

Troubleshooting SDK Integration with Axeptio in Nuxt3

I am currently developing a Nuxt3 project and I'm looking to integrate a script provided by Axeptio, a cookie platform. To achieve this integration, I created a custom plugin in Nuxt3. export default defineNuxtPlugin((useNuxtApp) => { ;(<any ...

My initial experience with vue.js has been complicated by issues with routers

I've recently dipped my toes into the world of Javascript and vue.js. After following a tutorial on creating a single page shopping application, I decided to incorporate routers into my learning project. However, I encountered some interesting error ...

Expandable full-width JavaScript accordion for seamless navigation

Currently, I am working on a simple on-page JavaScript application that consists of multiple data pages within one main page. My goal is to create a horizontal accordion effect where clicking on headers on either side will smoothly switch between the diffe ...

Leverage Express JS to prevent unauthorized requests from the Client Side

Exploring the functionalities of the Express router: const express = require("express"); const router = express.Router(); const DUMMY_PLACES = [ { id: "p1", title: "Empire State Building", description: "One of the most famous sky scrapers i ...

Transform a list of file directories into a JSON format using ReactJS

I am developing a function that can convert a list of paths into an object structure as illustrated below; this script will generate the desired output. Expected Output data = [ { "type": "folder", "name": "dir1& ...

Executing JavaScript code from an external link

Currently, I am in the process of developing a horizontal parallax website. The functionality is working seamlessly; when I click on the menu, the slides smoothly transition horizontally and display the corresponding content. However, I have encountered a ...

Combine values in CSS without any spacing

Currently, I am attempting to create a LESS mixin that can take a numerical value (degrees for rotation) and generate the appropriate CSS code to rotate an element. However, I am facing difficulties trying to handle both "270deg" and the integer "3" (which ...

Having Trouble with Typescript Modules? Module Not Found Error Arising Due to Source Location Mismatch?

I have recently developed and released a Typescript package, serving as an SDK for my API. This was a new endeavor for me, and I heavily relied on third-party tools to assist in this process. However, upon installation from NPM, the package does not functi ...

Utilizing the jQuery autocomplete plugin in a Rails application

I am encountering an issue with the auto complete plugin in my rails application. I have tried setting it up but it doesn't seem to be functioning correctly. Can someone please assist me with this problem? Below is a snippet from the view file: %td. ...

Having trouble with the image not showing up using the code <img src="">

UPDATE :: I recently discovered that there is a permission error preventing me from accessing images in the images folder. It seems that I do not have the necessary "permission" to retrieve the image files ... * A few days ago, I posted a question regardi ...

Refreshing a component in React when a prop changes

My understanding is that React components update when their props or state change. For example, I declare a variable like this: let percentage = { width: '10%', }; Then, I have a function using setInterval to upd ...