Using hover to show a block from a sibling parent step-by-step tutorial

My ScSS task involves displaying the block with the parent2 class when hovering over child 1 of the block with the parent1 class.

<div classname="main">
      <div className="parent1">
    
        <span>    Child 1    </span>
        <span>    Child 2    </span>
        <span>    Child 3    </span>
      </div> 
      <div className="parent2">
    
        <span>        Child 1    </span>
        <span>        Child 2    </span>
        <span>        Child 3    </span>
    </div>
</div>

Answer №1

In order to activate the hover effect, you need to nest parent 2 inside child 1 like this:

.parent2{
  display: none;
}
.child1:hover .parent2 {
  display: block;
}

<div class="main">
      <div class="parent1">
    
 <div class="child1"> Child 1 
        <div class="parent2">
        <span>        Child 1    </span>
        <span>        Child 2    </span>

   <span>    Child 3    </span>

    </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

Interactions of selecting dates in datepicker widget

Currently, I am working on developing my personal work website. One issue I have encountered is with the calendar feature. The "From" date can be selected before today's date, which is not ideal. Additionally, if a date 5 days from now is chosen as th ...

What is the best way to retrieve data from an Express endpoint within a React component?

I am working on integrating a React component with an Express endpoint that returns the string "sample data". The goal is to call this endpoint from my React app, store the text in state, and then display it on the screen. Here is my component: class App ...

Master React Native: Displaying Nested Objects with Hooks

Looking for a way to loop through the user data stored in my APIs. Can someone provide an example on how to achieve this? Below is a sample of my API data: { "data": { "__v": 0, "_id": "5edaa8cc76d6b20017", "createdAt": "2020-06-05T20:19:24. ...

Struggling to access your account on the Django website?

I'm having trouble creating a login page in Django. I have completed the views, HTML, and everything, but the problem is that when I try to log in, it doesn't work. After some debugging, I found that the user value is None, but I don't under ...

Choose the item to automatically reposition itself below once it has been opened

issue : The current behavior is that when the "other" option is selected, the input field appears. However, if I click on the select again, it covers up the input field. desired outcome : Ideally, I want the input field to show up when the "other" option ...

Click on the child element while it is already being clicked by manually implementing the 'declick' function in Javascript

Hey there, I'm looking for suggestions on a better title for this issue. I couldn't come up with the right wording myself. Problem I currently have a Google Maps element with pointer events set to none, preventing it from being scrolled when ho ...

Image retrieved from the REST API is consistently showing up as broken

Currently, I am in the process of developing a content management system that will be utilized for an art portfolio application using React. To achieve this, the client will send a POST request to the API, which then uses Mongoose to insert data into a Mon ...

Having trouble with Material UI select onChange function not functioning properly when using React testing library?

<Select inputProps={{ "data-testid": "change-form" }} multiple value={permissionsArr} onChange={handleChange} input={<Input />} ...

The custom styling in custom.css is not taking precedence over the styles defined in

My site is experiencing some element overwriting when I include css/bootstrap.min.css, such as 'a' tags, the .nav bar, and fonts used on the site. Load order: <link href="css/bootstrap.min.css" rel="stylesheet"/> <link rel="styleshe ...

How to remove the border of the MUI Select Component in React JS after it has been clicked on

I am struggling to find the proper CSS code to remove the blue border from Select in MUI after clicking on it. Even though I managed to remove the default border, the blue one still persists as shown in this sandbox example (https://codesandbox.io/s/autumn ...

Boxes that change and adapt to the user's input

Need guidance on a tricky problem! I am working on a form to input various cities that the user wants to visit. The form currently consists of one form box and a submit button. My goal is to allow the user to enter multiple cities by clicking an "Add 1 ...

What is the best way to customize the background color of MUI's select component?

I'm facing difficulties changing the background color of MUI's Select. I've experimented with different solutions like modifying the className property of <Select/> and adjusting it from Menu Prop's, but to no avail. It seems like ...

Displaying an image based on the selected dropdown using PHP, AJAX, and JQuery

This requires knowledge of PHP, AJAX, and JQuery. Hopefully, this question is straightforward. I have a dynamic dropdown menu that shows content when an option is selected. The content I want to display is an image. To achieve this, I am working with two ...

React JS and Webpack encountering issue 'Unable to locate module 'webpack-cli/bin/config-yargs'' while running 'npm run start'

I have recently embarked on creating a React JS project from scratch, utilizing Webpack to compile assets and aid in development. However, I am encountering some issues when attempting to execute "npm run start." Below is a snippet of my package.json file ...

Is there a way to add a <video> tag in tinymce editor without it being switched to an <img /> tag?

I am attempting to include a <video> tag within the tinymce editor, but it keeps changing it to an <img> tag. Is there a way to prevent this conversion and keep the <video> tag intact? I want to enable videos to play inside tinymce whil ...

I am having trouble with Mpdf's block absolute positioning feature not functioning correctly

I am trying to position my block using absolute, but it seems to be staying in the same place regardless of the left/top attributes I set. Here is the PHP code snippet: $mpdf = new \Mpdf\Mpdf(); $mpdf->WriteHTML($stylesheet,\Mpdf\HT ...

The NVD3 tooltip is being obscured by other divs

Attempting to make the NVD3 tooltip appear above all other divs has presented a challenge. With three charts lined up horizontally and tooltips that exceed the boundaries of their divs, adjusting the z-index creates a dilemma. Regardless of which side&apos ...

Boost Page Text Size Using CSS

Possible Duplicate: Allowing users to adjust font size on a webpage My goal is to create webpages where users can click an image to increase the font size of all content. Is this achievable? If so, how would I go about implementing it? I am aware that ...

Email confirmation section

I'm in the process of setting up a subscription newsletter page, and everything seems to be working correctly except for the part where I need users to enter their email address twice. The second email field is meant for confirmation purposes, but I&a ...

Unique logo loading exclusively on the landing page's navbar

I am currently developing a website using Bootstrap and Flask and have encountered an issue with the logo in the navbar. The problem is that the logo only displays on the landing (home) page and not on any other pages. The navbar code causing the issue is ...