What techniques can I utilize to generate this animation using CSS or jQuery?

Here is some HTML code that I have:

<div class="translate-bar"> 
  <div class="icon">
    <img src="images/translator-icon.png">
  </div>
  <div class="contents">        
    <p>translate contents</p>
  </div>
</div>

I would like to create an animation using CSS with this Markup. The animation involves positioning the "translate-bar" using absolute and right:0.

The goal is to initially display only the "icon" image in the browser, and then when a user clicks on or hovers over the icon DIV, the "contents" DIV should be displayed. Both the Icon and Contents DIVs should display inline.

I attempted this using CSS transitions, but unfortunately, I was not successful in achieving the desired effect.

This is how I styled my CSS:

.translate-bar {
    position: absolute;
    right: 0;
    z-index: 9999;
    display: table;
}

.icon {
    height: 50px;
}

img {
    width: 50px;
}

.contents {
    display: table-cell;
    vertical-align: middle;
    background: #ebebeb;
}

Answer №1

My solution involved making adjustments to your CSS code in the following manner:

.box {
    display: flex;
    align-items: center;
    background-color: #f0f0f0;
    visibility:hidden;
}
.icon:hover + .box { visibility: visible; }

You can see a demonstration of this on this JSFiddle example

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

The interaction of a horizontal scroll bar on a CSS Grid layout triggers the appearance of a vertical scroll bar

I am facing a challenge with my HTML layout. In Chrome, when the horizontal scroll bar is visible, a vertical scroll bar also appears. However, in Firefox, everything works fine. This issue seems to be related to the height of the div not auto-scaling prop ...

`Changing the background according to the page URL in React JS: A guide`

Looking to enhance my simple app with a few pages by changing the background color based on page URL using React.js. What I aim to achieve: If the pathname is /movies, I want the background color to be red. This is my current progress: import React, { ...

Ways to utilize two distinct XPATH values for a single key

When dealing with Xpath for the same object in two different portals, the paths can be: //*[@id="abc"]/fieldset/div/div/div[1]/label //*[@id="xyz"]/fieldset/div[1]/fieldset/div/div/div[1]/label In order to use both values in the same key and have Seleni ...

Retrieving checkbox values from HTML and storing them in a temporary JavaScript/HTML variable

My form has multiple checkboxes all with the same id "cbna". When I submit the form, I want the JavaScript code to check if at least one checkbox is checked. If no checkbox is checked, an alert should appear. If a checkbox is checked, the value stored in ...

Is it possible to organize and filter a dropdown menu in JQuery based on a secondary value (new attribute)?

Can the drop-down list be sorted by value2? <select id="ddlList"> <option value="3" value2="3">Three</option> <option value="1" value2="1">One</option> <option value="Order_0" value2="0">Zero</option> </sele ...

Unable to retrieve the child value using getJSON

I am currently retrieving data from an API that provides information in a specific format. Here is an example of the JSON data I receive: { "total":1, "launches":[ { "name":"Falcon 9 Full Thrust | BulgariaSat-1", "net":"June 23, 2017 1 ...

jQuery dynamically updating calculations on a single row consecutively

Currently, I am in the process of developing a small table to calculate potential winnings from betting on a rubber duck race with specific odds for each duck. I have managed to get most of it working but have encountered an issue... Upon loading the pag ...

Matching Heights for Carousel Images

My image/video carousel is causing trouble as the content within doesn't maintain a consistent height. Clicking on the thumbnails highlights a mismatch in the main image heights. Is there a way to ensure that all elements have the same height while k ...

What sets apart the two jQuery AJAX calls with 'GET' and 'POST' methods?

There are different types of jQuery AJAX calls in PHP Mysqli Programming, such as type:'GET' and type:'POST'. However, I have a doubt: When and where should we use these two different types? In which scenarios should we use type:' ...

Alignment issues with bullets in Outlook versions 2007, 2010, and 2013

Below is the code I am using to generate bullet points: <tr align="left"> <td valign="top" width="40" style="text-align:left; line-height:26px; padding: 0px;"> &bull; </td> <td height="20" style="text-align:left;li ...

Looking for and changing 'input tags' using regex

I am new to regular expressions and I have been experimenting with trial and error testing. I am trying to figure out how to replace the following: <input name="token" type="text" id="test" value=""> In a way that it first checks for the existence ...

Refresh the page when the dropdown selection is changed and send the new value

I'm currently working on a page that includes a dropdown menu. My goal is to have the page reload after selecting an option from the dropdown so that it returns to the same page with the selected value passed through. Here's the PHP code for th ...

Triggering an event when text is unselected or highlighted

Does jQuery have an event called "deselected" that is triggered when text is no longer selected? ...

Using jQuery to alter the background position of multiple backgrounds in CSS

I'm using jQuery to dynamically adjust the background image position of an element based on screen resolution. Here's the code: var pwwidth = $(window).width(); var pwheight = $(window).height(); var bg1posx = pwwidth - $('h1.portofolio&ap ...

Tips for Transmitting Images with jQuery in ASP.NET

Greetings! I am a newcomer to ASP and I have been contemplating on how to utilize jQuery ajax in order to transmit an image from the input file. My goal is to transfer the path and acquire the image on the server side. Is this achievable? Alternatively, a ...

Unable to save cookies using AngularJs

Currently, I am immersed in a small project utilizing AngularJs. The main objective of this project is to save a user's username and password within browser cookies. Here is my snippet from app.js where you can observe ngCookies being injected as a d ...

Steps for inserting an image onto a blank page

Struggling with HTML and javascript - need help with displaying an image on a new page: Creating a new page and want to show an image on it: thepage= window.open('', '', 'height=700,width=800,left=100,top=100,resizable=yes,scroll ...

Tips for managing a Yes No dialogue box that appears when a button is clicked with JavaScript

When the user clicks on the update button in my form, I want to prompt them with a message asking if they want to delimit the record using Yes and No buttons. If they click on Yes, then the code to delimit the record should be executed; otherwise, just upd ...

Load an image dynamically within a JavaScript function

I'm currently utilizing a Javascript photo viewer plugin (found here: http://www.photoswipe.com/). My goal is to dynamically update the photos connected to the plugin as the user swipes through different images. To achieve this, I am using a Javascri ...

Issue with React select dropdown not properly updating selected value

My website has a form with the default value of ethExperienceLevel set to "BEGINNER". I have a function that is supposed to update the selected state when switching between options in a dropdown list, triggered by an onChange handler. However, I noticed ...