When hovering, both the div element and the text within it dynamically transform

I am facing a challenge with my stylesheet and I believe some JavaScript might be needed.

In one of my divs, there is an image and a text link that both direct to another page.
Currently, when hovering over the image, its opacity changes along with the text color, which is working perfectly.
However, when hovering over the text, only the text color changes but I would like the opacity of the image to change as well.

I have checked my CSS and HTML thoroughly but cannot seem to find the issue...

Below is my CSS code:

.artists_menu{
    width: 100%;
    margin-top: -120px;
    -webkit-filter: grayscale(100%);
    -moz-filter: grayscale(100%);
    -ms-filter: grayscale(100%);
    -o-filter: grayscale(100%);
    filter: grayscale(100%);
    filter: url(grayscale.svg); /* Firefox 4+ */
    filter: gray; /* IE 6-9 */
}

.bandeau{
    height:7px; 
    background-color: #eeeeee
}

.cartouche_crop{
    height: 240px;
    overflow: hidden;
    opacity:1;
    webkit-transition: opacity 0.3s ease-in-out;
    -moz-transition: opacity 0.3s ease-in-out;
    -ms-transition: opacity 0.3s ease-in-out;
    -o-transition: opacity 0.3s ease-in-out;
    transition: opacity 0.3s ease-in-out;
}

.cartouche_crop:hover{
    opacity:0.7;
    ilter: alpha(opacity=70);
}

h1{
    font-size: 36px;
    text-transform: uppercase;
    font-weight: normal;
    background-color: lightgrey;
}

h1 a:hover{
    color: magenta!important
}

a, a:active, a:visited {
    color: black;
    text-decoration: none;
    transition: 0.2s ease;
    -webkit-transition: color 0.2s ease-in;
    -moz-transition: color 0.2s ease-in;
    -o-transition: color 0.2s ease-in;
    transition: color 0.2s ease-in;
}

a:hover {
    color: magenta
}

And here is the corresponding HTML:

<a href="http://www.amsbooking.fr/mattieumoreau/artists/amine_edge_and_dance/" title="amine edge &#038; dance">
    <div class="bandeau"></div>
    <div id="parent-57" class="parent-page">
        <div class="cartouche_crop">
            <img src="http://www.amsbooking.fr/mattieumoreau/wp-content/uploads/amine_11.jpg" class="artists_menu">
        </div>
        <div class="bandeau"></div>
            <h1>amine edge &#038; dance</h1>                
        <div class="bandeau"></div>
    </div>
</a>

For a live demonstration, you can visit this jsFiddle link: http://jsfiddle.net/FkWxb/1/

If anyone has any suggestions or guidance on how to resolve this, I would greatly appreciate it.

Answer №1

violin: http://jsfiddle.net/FkWxb/3/

substitute:

.cartouche_crop:hover{opacity:0.7;filter: alpha(opacity=70);}

replaced with

a:hover .cartouche_crop{opacity:0.7;filter: alpha(opacity=70);}

and erase

h1 a:hover{color: magenta!important}

Answer №2

To enhance the visual effect, insert the following snippet to your CSS file:

.parent-page:hover{opacity:0.7;filter: alpha(opacity=70);}

For a live demonstration, visit this link: http://jsfiddle.net/XKe8L/

Answer №3

To create a hover effect for both text and image, try wrapping them in a div element.

I have enclosed the code within a div:

<div id="fancy_hover">
<div class="cartouche_crop">
    <img src="http://www.amsbooking.fr/mattieumoreau/wp-content/uploads/amine_11.jpg" class="artists_menu">
</div>

and added a CSS reference to it:

#fancy_hover:hover{opacity:0.7;filter: alpha(opacity=70);}

http://jsfiddle.net/cqVz4/

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

How can I center a Bootstrap modal vertically and make it responsive?

Is there a way to vertically center the bootstrap modal? I have been searching for a solution, but none seem to be responsive or effective. My website is using Bootstrap 3. The modal does not adjust properly on smaller screens or when the browser window i ...

How can we retrieve the value from a textBox using JavaScript in Selenium WebDriver?

https://i.sstatic.net/6ni0f.pngTrying to extract text from an input tag that is missing in the HTML code, leading to the need for JavaScript to retrieve the value. Unfortunately, running the code in Eclipse returns null as the result. The HTML and Seleni ...

Rotate the main container element without affecting the content of its children

I'm trying to keep the text centered inside a spinning div by using absolute positioning on the children. I haven't found a solution yet, but I attempted to position it absolutely and disable the transition in the child element. I've include ...

Utilizing Padding Effectively Within an <a> Tag in HTML/CSS

Is there a way to make it so that clicking on the padding with the grey background color and orange rollover will also open the link, in addition to clicking on the text as expected? https://i.sstatic.net/AJ9Fy.png The JavaScript code is shown below: so ...

Troubleshooting Unresponsive Dropdown Menu Using JQuery

My attempt to integrate the Dropdown Menu feature into my Navbar using base.html and navbar.html files has hit a snag. Although the menu is visible, it remains non-responsive upon clicking. Despite my efforts to rectify the issue by referencing other resou ...

The use of pattern fill in fabric.js is causing a decrease in rendering speed

I recently attempted to create a clip mask effect on a large image by using the picture as a pattern and setting it to the svg paths that support the desired shape. You can view the slow-loading jsfiddle example here: http://jsfiddle.net/minzojian/xwurbw ...

Tips for Making a Div 100% Width While Hiding Another Div Using jQuery

I am looking for a solution to adjust the width of the blue div to 100% when hiding the red div. Can anyone help with this? Here is my JavaScript code <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script> ...

Hide the popup by clicking anywhere outside of it

I need help with a code that involves a button triggering a popup, and I want the user to be able to close the popup by clicking outside of it when it's open. My goal is to assign the method "Close()" to the event listener that detects clicks outside ...

CSS: Can pseudo elements be combined with the plus sign?

When looking at the markup below: <div> <p>hello world</p> </div> <div> <h4>hello world</h4> </div> Is it possible to achieve the following styling using CSS: div:after { content: ""; display ...

Implementing dynamic styles for a checked mat-button-toggle in Angular 6

How can I customize my button-toggle when it is checked? The current code I have doesn't seem to be working... This is the code snippet: <mat-button-toggle-group #mytoggle (change)="selectoption($event)" value="{{num}}"> <mat-bu ...

Is it possible to align the scrollbars of two separate divs using JavaScript/jQuery?

In my index.html page, I have two divs where I load different content into each one by selecting the div and injecting the content using jQuery. As a result, each div ends up with a horizontal scrollbar to display its content. My goal is to synchronize the ...

Position text on the background image without using positioning techniques

I need to center my text precisely on top of my background image without resorting to the use of relative or absolute positioning. Many solutions online rely on using absolute positioning for the text along with a specified top value, but I prefer not to e ...

Grab an HTML table and store it in a JavaScript variable using jQuery

I need help with backing up and filtering an html table using jquery. $('.row').closest('td').not(':contains(' + v + ')').parent('tr').remove(); Because of the remove() function, I want to create a backup ...

Sort columns using drag and drop feature in jQuery and AngularJS

Utilizing the drag and drop feature of jquery dragtable.js is causing compatibility issues with AngularJs, hindering table sorting functionality. The goal is to enable column sorting by clicking on the th label and allow for column rearrangement. Currentl ...

Include a hyperlink in an email using PHP

I am currently using an HTML form textarea along with PHP to send emails through my website. My question is, how can I successfully insert a link into the email message body? I attempted to do it like this: <a href="http://www.xxxxx.com/">Visit the ...

When the button is clicked, HTML buttons toggle and collapse information while toggling all other buttons

As a beginner in HTML and CSS, I've successfully created buttons that display more information when clicked. However, I'm struggling to figure out how to collapse the information being shown by other buttons when a new one is clicked. I've t ...

Button that toggles colors

I tried creating a JavaScript code that would change the background color of the body when a button is clicked. However, when I checked the console, it showed an error saying that body.style.background is not a function. Can someone help me identify the ...

Flyer - Chart "dimmed" and unselectable when dimensions are specified as a proportion

I am currently working on displaying a map within a container. I have successfully been able to display the map by setting its size to a specified number of pixels. However, my goal is to have the height of the map adapt to the size of the container dynami ...

Can you propose a different approach to creating the "word stack" that overcomes the limitations of my current method?

I am attempting to convert a set of two radio buttons into a stack of two labels, one blue and one gray, to represent the selected radio button and the unselected one. Clicking on this stack will toggle which label is blue (and consequently which radio but ...

Place the div in an absolute position relative to the body, not its

I am facing a challenge with positioning multiple child divs to the body element using absolute positioning. Unfortunately, I cannot use `position: absolute` because the divs are not direct children of the body. Using `position: fixed` is also not an opt ...