Changing both image border and text at the same time when hovering- how can this be done

I have taken on the challenge of creating a Netflix Clone as a personal project.

In my version, I want the border around the image and the user's name to both highlight when hovered over in the Netflix Profiles section.

However, despite trying for over an hour, I can't seem to make the border and text change together. I know I must be missing something simple and probably just overthinking it. Should I approach this with a JavaScript function or adjust the CSS? (I struggle with adding JS to my projects, which is why I am attempting this clone!)

Any tips or hints would be greatly appreciated as I continue to troubleshoot.

body, html {
    height: 100%;
    margin: 0px;
    margin-top: -11px;
    margin-left: 22.5px;
    padding: 0px;
    color: white;
    font-family: 'Roboto', sans-serif;
    background-color: rgb(17, 17, 17);
}

.container {
    text-align: center;
    position: relative;
    top: 10%;
}

/* 
----------------
PROFILES SECTION
----------------
*/

.profiles {
    margin: 20px;
    padding: 20px;
    display: flex;
    justify-content: center;
}


.prfImg {
    margin: -6px;
    padding: 12px;
}

.prfImg > img {
    margin: 2px;
    padding: 2px;
    border: 0.5px solid rgba(255, 255, 255, 0.061);
    border-radius: 3px;
}

.prfImg > img:hover {
    color: rgba(255, 255, 255, 0.787);
    border: 3px solid rgba(255, 255, 255, 0.787);
    border-radius: 3px;
}

#user {
    font-size: 25px;
    color: grey;
}

/* 
----------------
BUTTON
----------------
*/

.btn {
    margin: 30px;
    padding: 30px;
    text-align: center;
}

button {
    margin-top: 30px;
    font-size: 22px; 
    color: grey;
    padding: 10px;
    background-color: transparent;
    border: 1.5px solid grey;
}

button:hover {
    color: rgba(255, 255, 255, 0.863);
    border: 1.5px solid rgba(255, 255, 255, 0.863);
}
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="profiles.css">
    <!-- google font -->
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300&display=swap" rel="stylesheet">
    <title>NETFLIX - Profiles</title>
</head>

<body>
    <header>
        <img src="Img_d.profiles/netflix_logo.png" alt="netflix logo TM" width="99.2px">
    </header>

    <div class="container">
        <div class="header-text">
            <h1 style="font-size: 50px;">Who's watching?</h1>
        </div>
        <div class="profiles">
            <div class="prfImg">
                <img src="Img_d.profiles/profile_one.png" alt="Profile One" width="75%" label="hello">
                <p class="prfImg" id="user">A name</p>
            </div>
            <div class="prfImg">
                <img src="Img_d.profiles/profile_two.png" alt="Profile Two" width="75%">
                <p class="prfImg" id="user">A name</p>
            </div>
            <div class="prfImg">
                <img src="Img_d.profiles/profile_three.png" alt="Profile Three" width="75%">
                <p class="prfImg" id="user">A name</p>
            </div>
            <div class="prfImg">
                <img src="Img_d.profiles/profile_four.png" alt="Profile Foud" width="75%">
                <p class="prfImg" id="user">A name</p>
            </div>
        </div>
        <!-- button class -->
    </div>

    <div class="btn">
        <button>Manage Profiles</button>
    </div>

</body>

</html>

by myself!*

Answer №1

To activate the hover effect, you can set it on the parent div element.

Transform this code snippet:

.prfImg > img:hover {
    color: rgba(255, 255, 255, 0.787);
    border: 3px solid rgba(255, 255, 255, 0.787);
    border-radius: 3px;
}

into the following:

.prfImg:hover {
    color: rgba(255, 255, 255, 0.787);
    border: 3px solid rgba(255, 255, 255, 0.787);
    border-radius: 3px;
}

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 showcase the data of each table row within the tr tag in an Angular 8 application?

I have been developing an application using Angular 8. The employee-list component is responsible for presenting data in a table format. Within the employee-list.component.ts file, I have defined: import { Component } from '@angular/core'; impo ...

What is the best way to choose a child element that has been clicked using jQuery?

How can I make only the child of the clicked element slideToggle? I tried implementing a solution, but it ended up sliding all divs with the .description class. Can anyone provide some guidance? HTML: <div id="container"> <div class="row"> ...

Troubleshooting: Why is Spring MVC failing to return results on ajax call?

I am trying to retrieve user data through an ajax request, but I am facing an issue where the success part of the request is not being reached and no logs are being generated. This is the controller code: @Controller @RequestMapping(value = "/api/profile ...

Equivalent of SQL Select in MongoDB with node.js

As a newcomer to node.js and mongodb, I find it frustrating that querying data with 'SELECT * FROM table' in php produces an array or array of objects, while in node and mongo, it requires so much unnecessary code. To simplify this process, I cre ...

Is it possible that CSS is causing the links to be unclickable?

I'm experiencing an issue where the links in my navigation bar are unclickable unless I remove some of the CSS styling I added. Here is the specific CSS snippet that needs to be removed for the links to work: .main-nav { float: right; list-style ...

Load a section of the webpage without using AJAX technology

I am creating a website and I would like the left menu to remain fixed while loading the content of the clicked option. Currently, each menu link uses AJAX to return the requested content. Although it works well, I would like to find an alternative to avo ...

Using Vue.js to toggle rendering based on checkbox selection

Struggling to conditionally render form elements in Vue based on user input. I can do this with VanillaJS or jQuery, but struggling to implement it with Vue's built-in conditional directives. Using single-file components with the webpack template from ...

Refresh data with Axios using the PUT method

I have a query regarding the use of the HTTP PUT method with Axios. I am developing a task scheduling application using React, Express, and MySQL. My goal is to implement the functionality to update task data. Currently, my project displays a modal window ...

Tips for enabling simultaneous input focus on both TextField and Popover components

I am working on a popover component that appears below a textfield component. The goal is to trigger a menu when the user types a specific key, like :, into the textfield. The user can then select an option from this menu to autocomplete the textfield. A ...

Discover the files in the web directory using TypeScript

I am working on a TypeScript web application that has a specific folder structure. Here is how it looks: - assets |- a.png |- b.png |- c.png |- d.png |- ... - app.ts My question is: In the app.ts file, how can I programmatically list all the files wi ...

Use JavaScript to Generate a hash Table

Take a look at my code below, it's supposed to extract data results and display them in an HTML Table. However, I can't seem to get it working: <html> <head> <script type="text/javascript"> data = { d : { resu ...

Use Onblur and Onfocus events in an input field that is read-only

Here is an input field: <input class="" type="text" id="Name_11_1" name="Name" value="Your name:"> I would like to modify it as follows: <input class="" type="text" id="Na ...

The presence of a Bootstrap addon is resulting in horizontal scrolling on mobile devices within the webpage

I am encountering a peculiar issue with an input-group in my cshtml file which features a Bootstrap addon. The problem arises on mobile devices, where upon focusing on the input field, the page scrolls horizontally to the right, revealing the right margin ...

Perfectly Positioned Overlay and Text on Top of an Inline SVG Element

Within my inline SVG code, there are circular icons representing different user progress stages, each customized with CSS styling. The SVG contains 5 stages of progress in total and is utilized within an Angular app. For any active stage, a corresponding ...

Toggle jQuery slide effect showing all elements and not hiding other list items

I'm utilizing this to display a sub list: function showSublist(element) { $(element).find('ul.joinus_subtext').slideToggle(); } and below is the HTML markup: <ul class="joinus"> <li onclick="showSublis ...

What could be causing my array to be misconverted into JSONP data?

let defaultPosts = new Array([]); defaultPosts[0] = "first post"; defaultPosts[1] = "second post"; defaultPosts[2] = "third post"; The array in the console is showing ["first post", "second post", "third post"]; let jsonString = JSON.stringi ...

What is the best way to make my navbar reach the edges of the screen?

Currently working on a regular navbar, but aiming to have the logo and links span the entire container instead of starting in the middle. I'm seeking an easy solution that won't push out my links when applied. https://i.sstatic.net/nTFJ6.png ...

Error: null value cannot be scrolled into view - testing with react, jest, and enzyme

Utilizing react version 16.3.1, jest version 16.3.1, and enzyme version 3.3.0. Inside my React Class component, I have implemented a react ref to ensure that upon mounting the component, the browser scrolls back to the top of the page. class PageView ext ...

What are the steps for sending a POST request with custom headers?

Currently, I am attempting to make a post request: For this request, I require a body that looks like this: { "listSearchFields": { "email": "sample" } } When testing this in Postman, it works fine. However, when trying to implement this code in ...

What is the best way to tally jsonObject instances within the same array based on their id or value

I have a jsonDataArray that contains two nested arrays with objects. My goal is to calculate the number of "duty" parentIds based on the teams' "value" as they have a one-to-one match. For instance, Team A with a value of 500 will have duties such as ...