Display a div when hovering over another div

I have a menu that looks like this:

https://i.sstatic.net/WqN33.png

and I want to create a hover effect where another div shows up over each item, similar to this:

https://i.sstatic.net/JRaoF.png

However, I can't seem to figure out how to implement it. I've experimented with placing the div inside each router-link and setting its z-index, as well as changing the display using CSS from "display: none" to "display: block" on hover, but nothing has worked so far.

This is the current code for the menu:

        <div class="ml-auto p-3 d-none d-lg-flex align-items-center">
          <div class="d-flex">
            <router-link
              class="
                routerlink
                text-gray-600
                hover:text-gray-400
                fs-13
                mx-2
                font-weight-500
              "
              to="/beer-universe"
              >Beer Universe</router-link
            >
          </div>

          <div class="vl mx-2"></div>
          <div class="d-flex position-relative justify-content-center">
            <router-link
              class="
                text-gray-600
                hover:text-gray-400
                fs-13
                mx-2
                font-weight-500
              "
              to="/ambassadors"
              >We Are Ambassadors</router-link
            >
          </div>
          <div class="vl mx-2"></div>
          <div class="d-flex">
            <router-link
              class="
                text-gray-600
                hover:text-gray-400
                fs-13
                mx-2
                font-weight-500
              "
              to="/linkedin-learning"
            >
              Train
            </router-link>
          </div>

          <div role="button" class="d-flex mx-2" @click="showSearchBox()">
            <span
              class="icon-buscar fs-20 mx-2"
              :class="showSearch ? 'text-red-400' : 'text-gray-600'"
            ></span>
          </div>
          <div role="button" class="mx-2" @click="showHideMenuProfile()">
            <img
              v-if="user.prof_picture !== null"
              class="rounded-circle m-2"
              :src="uriResources + '/' + user.prof_picture"
              title="Profile"
              width="34"
              height="34"
              style="object-fit: cover"
            />
            <img
              v-else
              class="rounded-circle m-2"
              title="Profile"
              width="34"
              height="34"
              :src="imgVideo"
            />
          </div>
        </div>

Answer №1

<!DOCTYPE html>
<html>
  <head>
    <style>
      #main {
        position: relative;
      }
      .hide {
        display: none;
        position: absolute;
        left: 40%;
        background: rgb(90, 13, 13);
      }

      .myDIV:hover + .hide {
        display: block;
        color: red;
      }

      .myDIV {
        border: 2px solid;
        background: rgb(202, 100, 100);
        cursor: pointer;
        height: 15vh;
        width: 97px;
        display: block;
        margin: auto;
        text-align: center;
      }
    </style>
  </head>
  <body>
    <div id="main">
      <div class="myDIV">Hover over</div>
      <div class="hide">
        <p>Lorem ipsum dolor sit.</p>
        <hr />
        <p>Lorem ipsum dolor sit.</p>
      </div>
    </div>
  </body>
</html>

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

What is the process for retrieving randomized data using mongoose?

I recently came across the mongoose-random package which allows for retrieving a JSON array of random records using mongoose. My goal is to retrieve three random records with a specific field. Despite reviewing the documentation, I have yet to find a work ...

Listening for select elements that have remained unchanged

My current situation involves a select box with predetermined options. One of these options is preselected when the page loads: <select name="select" class="js-choice-select"> <option value="option-1">Option 1</option> <option ...

Adjust the size of H1, H2... tags based on their own specifications, rather than the surrounding element

I have run into a bit of a conundrum with my code and cannot seem to find the right solution. Here is what I currently have: <div id="bloquetexto4" class="bloquetexto"> <H2><b>TITULO</b></H2> <p>Texto bla bla bla.</p ...

Is there a way to prevent Prettier from automatically inserting parentheses for a single argument in an arrow function?

Currently, I've integrated Prettier into my workflow, but I've encountered an issue with arrow functions in JavaScript. For example: arg => console.log(arg) However, Prettier automatically formats it as: (arg) => console.log(arg) This for ...

blurring out of an input field and a division element

I am currently working on creating a dropdown suggestion box that hides when the input field and dropdown box are no longer in focus. My HTML code: <input type="text" id="user_address"> <div id="user_address_sg">SUGGESTION</div> <di ...

Unattended HTML and head tags found unexpectedly

As a new programmer tackling my first RoR site with an integrated bootstrap theme, I've encountered some issues with the HTML code that are causing problems with image sharing on Facebook. The error message from the debugger indicates that there are m ...

Sending data to Layout for customizable routes (App Router) in Next.js version 13

Looking to pass props to the Layout component for dynamic routes in my project structure: /app -/(site) --/layout.tsx --/page.tsx --/[slug]/page.tsx --/[slug]/layout.tsx In the site layout: export default async function IndexRoute({ children }: { chil ...

Disregard the sorting of rows in the MUI Datagrid

Any advice on excluding the "TOTAL" row from sorting in MUI library? onSortModelChange={(test, neww) => { neww.api.state.sorting.sortedRows = [14881337, 2, 3] neww.api.setState({...neww.api.state}) } } Review ...

The Reliability of Using CSS Pixel Font Sizes

Imagine I need to display two capital 'T's, each exactly one inch tall. One 'T' appears on a Macbook Pro with Retina Display (220 DPI, CSS pixel ratio 2), and the other on an iPhone 4S (326 DPI, CSS pixel ratio 2). To achieve this, I se ...

Display all dependents associated with a dependency in the lock file

Is there a way to identify all dependents of a specific dependency from a lock file (npm/pnpm/yarn)? This is the opposite of using yarn ls I would rather not parse the lock file if there is an existing command in npm/pnpm/yarn for this I am aware that I ...

The checkbox will be automatically checked whenever there is any modification in the textbox

I'm currently working on a Grid view with a checkbox and two textboxes. What I want is for the checkbox to be automatically checked whenever there is a change in one of the textbox values, for example switching from 0 to 1. This project is being devel ...

Assistance Needed with XPATH and CSS for Selenium Automation

Can anyone assist me in finding the appropriate XPATH/CSS locator to extract text from the structure below? <div class="page-header song-wrap"> <div class="art solo-art"> <div class="meta-info"> <h1 class="page-title"> Zehnaseeb I ...

Use PHP to highlight the row that has been selected in an HTML table

I am currently working on a project where I have styled multiple HTML tables on my website using alternating gray and white bands. Now, my goal is to highlight the selected row in a darker shade of gray. I have experimented with various solutions, and the ...

React js web application facing excessive content problem

I am encountering an overflow issue with the styles sheet I'm using on mobile and tablet views, but it works fine on desktop view. Can anyone provide a solution to this problem? I am developing a ReactJS web app hosted on Firebase. When I include fewe ...

Pagination in Datatables

Here is the code snippet I am working with: $('#ldap-users, #audit-users').dataTable({ "sDom": "<'row'<'span6'l><'span6'f>r>t<'row'<'span6'i><'span6'p& ...

How can I use TypeScript to wrap a component in Vue 3?

Looking to customize a PrimeVue component (Calendar) by styling it differently and then re-exporting it. Here's an example in React: const WrappedCalendar: React.FC<CalendarProps> = (props)=> <div style={{background:'green'}}&g ...

Ways to accomplish n levels of nested dynamic routes within Vue.js

Is it possible to create multiple levels of dynamic nested routes in Vue.js without knowing the exact number? For example: abc.com/ctx-path/component/1/2/...../n In this URL structure, where 1, 2, ..., n represent different levels, how can I implement th ...

jquery-ui allowing to resize child divisions as well

Currently, I am in the process of developing a website that includes resizable divs with jQuery. However, I have encountered an issue where only the width of the child divs is being resized when I adjust them. For reference, you can view the site and its c ...

Exploring the functionality of the JavaScript switch statement across various condition scenarios

switch (true) { case (angle<20): console.log("case1") break; case (angle<70): console.log("case2") break; case (angle< ...

Can anyone help with displaying a PNG image in Vue/Node/Express? I am struggling to show the image that I sent from a Node.js server to a Vue app client

In my Node/Express application, I've set up a route like this: app.get('/get-image', function(req, res) { ... res.sendFile(path.join(__dirname, '..', account.profileImg)); }) Now in my client-side Vue app, I'm tryi ...