Hovering over a Div tag to slide it out

I need help creating an animation that makes a div slide out when the mouse hovers over it, and stay out until the mouse moves away. I'm new to React so any guidance would be appreciated. Here is my code snippet:

return (
    <div id="homeDiv">
        <div>
            <Navbar />
        </div>

        <div className="portStyle">
        </div>

        <div className="cvStyle1">
        </div>

        <div className="nameStyle">
            <h1 >Lin</h1>
            <h1 >Edmund</h1>
        </div>
    </div>
)

And here's the related CSS:

#homeDiv {
    overflow-y: hidden;
    overflow-x:hidden;
}
.nameStyle  {
    height: 100vh;
    width: 30%;
    display: flex;
    justify-content: flex-end;
    flex-direction: column;
}

.portStyle  {
    height: 100vh;
    width: 20%;
    position: relative;
    float: right;
    background-color: #000;
}

.cvStyle1 {
    height: 100vh;
    width: 20%;
    position: relative;
    float: right;
    background-color: #ccc;
}

I'm unsure whether to use CSS animations or React animations for this task. Since CSS does not directly support onMouseOver events, I'm wondering if there's a workaround. The Navbar element is simply a navigation bar aligned to the right of the screen with 20% width and 100vh height.

Answer №1

Do you want to achieve a similar effect?

.container {
  position: relative;
  width: 70%;
}
.image { 
  width: 100%;
}
.overlay {
  position: absolute;
  bottom: 0;
  left: 100%;
  right: 0;
  background-color: darkcyan;
  overflow: hidden;
  width: 0;
  height: 100%;
  transition: .5s ease;
}
.container:hover .overlay {
  width: 100%;
  left: 0;
}
.text {
  color: white;
  font-size: 20px;
  position: absolute;
  padding: 10px;
  white-space: wrap;
}
<div class="container">
  <img src="https://pixlr.com/photo/image-design-11-1-pw.jpg" alt="Avatar" class="image">
  <div class="overlay">
    <div class="text">What is Lorem Ipsum?
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</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

Understanding how to fetch predictions from a REST API using the fetch function in ReactJS

I'm currently working on an application that involves using a Flask REST API to predict a floating value based on two input strings. My next step is to integrate this functionality with a React app in order to display these predictions on a webpage. ...

There is a mismatch in the host name: please consider using a domain name (e.g., https://myname.myorg.com) instead of https://localhost

My current setup involves an HTML application that sends an AJAX request to a Qt C++ HTTP Server running on my local computer, hosted at "https://localhost:8081". However, I am facing an issue with a host name mismatch causing the AJAX request to fail. Is ...

Introduce a default value feature within the select tag

Within my application, I've implemented a select tag with the following code snippet: <Select showSearch={false} defaultValue={["Lucy"]} mode="multiple" style={{ width: 200 }} placeholder="Select a person" optionFilterProp=" ...

Having trouble converting my form data into an array for table display

My website has a form for entering dummy patient information, with a table to display the submitted data. However, I'm facing an issue where the data is not being stored in the array when the user clicks the "Add Patient" button. Upon checking the arr ...

Incorporate jQuery into your MVC view by including Html.BeginForm

Using Ajax, I have info boxes that are loaded by calling a function in my controller and generating the HTML dynamically. Now, I want to implement an edit functionality for these info boxes where the static text will be replaced with a form. I am familiar ...

Tips for maintaining real-time data accuracy with Socket.io for a substantial dataset

In my current project, I am developing a system that handles multiple user types with varying levels of access to interact with the database resources. It is essential for me that these resources are displayed in real-time to ensure a seamless user experie ...

Seeking assistance with HTML coding to incorporate an image into a website

I am currently customizing a pre-written code to finalize my project. The project involves a game where a snake eats an apple and grows in size. One of the tasks I need to complete is replacing the red blob, representing the apple in the game, with an imag ...

How to implement scrollIntoView in Vue 3 with script setup

Having some trouble with scrolling to a specific element when clicked. I keep getting this error message. Uncaught TypeError: element.scrollIntoView is not a function Here is my script <script setup> import { ref } from 'vue' function goT ...

I am struggling to extract data from the spawned Node.js child process. What am I overlooking?

Trying to utilize a spawned command-line process for lzip in order to expand an lzipped data stream due to the lack of suitable native JavaScript tools. Succeeded in achieving this by working with files and file descriptors, although cumbersome to handle ...

What steps do I need to take to get this route parameter to function correctly

//jshint esversion:6 const express = require("express"); const bodyParser = require("body-parser"); const ejs = require("ejs"); const { redirect } = require("express/lib/response"); const { forEach } = require(" ...

Adding input fields that change dynamically along with their corresponding radio buttons using AngularJS

Hello, I am struggling with implementing a feature in my HTML and AngularJS files (using Bootstrap ui). I want to create a new input field (td) along with three corresponding radio buttons when the user clicks on an add button. I have attempted to modify t ...

What is causing it to give me 'undefined' as the result?

Trying to execute a script, test.al(); and within test.al, it calls getcrypt.php();. The php script is hosted on a webserver, and it is functioning properly. Here are the current scripts being used: JS var getcrypt = { php: function () { $.a ...

Switching between languages dynamically with Angular JS using $translateProvider and JSON files

I currently have a collection consisting of 6 different JSON files. en.json es.json fr.json it.json ja.json zh.json An illustration of the data present in each file is as follows (in this instance, considering en.json): { "SomeText": "Test in Englis ...

Tips for updating an Observable array in Angular 4 using RxJS

Within the service class, I have defined a property like this: articles: Observable<Article[]>; This property is populated by calling the getArticles() function which uses the conventional http.get().map() approach. Now, my query is about manually ...

Utilize dynamic global variables in React that are provided during runtime, making them unpredictable during the build process

I am currently developing an application for Overwolf, which you can find more information about at For this platform, applications are built using html/js and run in the Overwolf Browser. The browser provides access to the Overwolf API through a global v ...

Is there a way to incorporate an "else" condition in a TypeScript implementation?

I am trying to add a condition for when there are no references, I want to display the message no data is available. Currently, I am working with ReactJS and TypeScript. How can I implement this check? <div className="overview-text"> < ...

In Angular/Typescript, dynamically add a class to a `td` element when it is clicked. Toggle the class on and off

My problem arises when trying to individually control the arrow icons for each column in my COVID-19 data table. By using Angular methods, I aim to show ascending and descending arrows upon sorting but run into the challenge of changing arrows across all c ...

Guide to utilizing JavaScript and JQuery for retrieving a PDF from a specific URL and subsequently uploading the file to another website

I have a link to a PDF file: http://www.example.com/HelloWorld.pdf My objective is to download the file using JavaScript/JQuery/AJAX and temporarily store it in the browser, without saving it on the user's machine. Then, I want to POST it to . To ac ...

Transitioning from embedded browser to system browser in a Next.js / React.JS application

I'm currently dealing with an issue on my Next.js payment page and could really use some expertise. Here's the situation at hand: My payment page has a QR code that directs users to the payment page created with Next.js. When users scan this QR ...

Has the binary search operation not been executed?

My attempt to implement the binary search algorithm in my code example is not producing the expected result. I'm unsure of the cause. Can someone please explain it to me? var array = [1, 4, 6, 8, 9, 12, 15, 17, 19, 34, 55, 78, 80]; function binarySe ...