Incorporate a dynamic opacity effect to vertical scrolling text

Currently, I am working on the following CSS:

figure p {
opacity:0;
}

figure:hover p {
 opacity:1;
 -webkit-transition: opacity 0.35s;
transition: opacity 0.35s;
 margin: 0;
 line-height: 50px;
 text-align: center;
 /* Starting position */
 -moz-transform:translateY(100%);
 -webkit-transform:translateY(100%);    
 transform:translateY(100%);
 /* Apply animation to this element */  
 -moz-animation: scroll-up 5s linear infinite;
 -webkit-animation: scroll-up 5s linear infinite;
 animation: scroll-up 5s linear infinite;
}
/* Move it (define the animation) */
@-moz-keyframes scroll-up {
 0%   { -moz-transform: translateY(100%); }
 100% { -moz-transform: translateY(-100%); }
}
@-webkit-keyframes scroll-up {
 0%   { -webkit-transform: translateY(100%); }
 100% { -webkit-transform: translateY(-100%); }
}
@keyframes scroll-up {
 0%   { 
 -moz-transform: translateY(100%); /* Browser bug fix */
 -webkit-transform: translateY(100%); /* Browser bug fix */
 transform: translateY(100%);       
 }
 100% { 
 -moz-transform: translateY(-100%); /* Browser bug fix */
 -webkit-transform: translateY(-100%); /* Browser bug fix */
 transform: translateY(-100%); 
 }
}

Even though the scrolling effect of the text works smoothly, I am encountering difficulty in achieving a gradual opacity transition. Despite adding the necessary code snippet to the hover state as shown above, the outcome is not meeting my expectations. Instead of a gradual change in opacity, the text simply appears abruptly. This is disappointing because my objective was to create a dynamic opacity effect where the higher the text scrolls, the more transparent it becomes. Ideally, when it reaches the peak of the vertical scroll (bottom to top motion), it should be completely transparent (0 opacity). Since I'm struggling with a basic opacity transition implementation, I am hesitant about creating a complex one.

Query: Given my current vertical scroll style, is there a way to achieve the desired opacity transition effect?

Answer №1

Give this a shot

p {
  opacity: 0;
}

.figure:hover p {
  margin: 0;
  line-height: 50px;
  text-align: center;
  /* Starting position */
  -moz-transform: translateY(100%);
  -webkit-transform: translateY(100%);
  transform: translateY(100%);
  /* Apply animation to this element */
  -moz-animation: scroll-up 8s linear infinite;
  -webkit-animation: scroll-up 8s linear infinite;
  animation: scroll-up 8s linear infinite;
}


/* Define the movement animation */

@-moz-keyframes scroll-up {
  0% {
    -moz-transform: translateY(100%);
    opacity: 0;
  }
  50%,60%{
    opacity: 1;
  }
  100% {
    -moz-transform: translateY(-100%);
    opacity: 0;
  }
}

@-webkit-keyframes scroll-up {
  0% {
    -webkit-transform: translateYsa(100%);
    opacity: 0;
  }
  50%,60%{
    opacity: 1;
  }
  100% {
    -webkit-transform: translateY(-100%);
    opacity: 0;
  }
}

@keyframes scroll-up {
  0% {
    -moz-transform: translateY(100%);
    /* Browser bug fix */
    -webkit-transform: translateY(100%);
    /* Browser bug fix */
    transform: translateY(100%);
    opacity: 0;
  }
  50%,60%{
    opacity: 1;
  }
  100% {
    -moz-transform: translateY(-100%);
    /* Browser bug fix */
    -webkit-transform: translateY(-100%);
    /* Browser bug fix */
    transform: translateY(-100%);
    opacity: 0;
  }
}
<div class="figure">
  Hover here
  <br>
  <br>
  <p>
    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. It has
    survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularized in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing
    software like Aldus PageMaker including versions of Lorem Ipsum.
  </p>
</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

Dealing with href problems while parsing HTML in a React application

I'm currently facing a challenge with parsing HTML received from an API. Despite trying dangerouslySetInnerHTML, react-html-parser, and html-react-parser, all three methods are adding unwanted line breaks before and after <a href. Here is an examp ...

Issue with THREE.meshphongmaterial: Causing Objects to Appear Black

Attempting to implement THREE.meshphongmaterial from a tutorial found at: Encountering issues as it is resulting in a black color. Link to the jsfiddle code: http://jsfiddle.net/8hrk7mu6/12/ The problem seems to be on line 32: var material = new THREE.M ...

Match rooms using Socket.io

I am utilizing the opentok and socket.io packages in an attempt to establish 2 distinct "groups". Successfully, I have managed to pair up individual users in a 1-to-1 relationship. However, my goal is to create two separate groups of users. For instance, ...

Utilizing CSS variables and HSLA, create a distinctive linear gradient styling

I am encountering an issue with a CSS variable: :root{ --red: hsl(0, 100%, 74%); } Despite defining the variable, it does not work in the following code snippet: .page-wrapper{ background-image: linear-gradient(hsla(var(--red),.6), hsla(var(--red),.6 ...

MQTT Broker specialized in Typescript

I'm looking to create a MQTT Broker using TypeScript and Angular. I've attempted a few examples, but I keep encountering the following error: Uncaught TypeError: http.createServer is not a function Here's a simple example of what I'm c ...

Guide to displaying the output of a JS calculation in a Bootstrap modal dialog box

I have a HTML and JavaScript code that determines the ideal surfboard for the user based on their input data (style, experience, height, weight) and displays the recommended surfboard type. Here is the initial code snippet I attempted to use: function c ...

Is there a way to retrieve the text from THREE.TextGeometry?

I recently generated a new Mesh using TextGeometry and added it to an array of meshes: var text3d = new THREE.TextGeometry( "Hello!", { font: "Helvetica" }); text3d.computeBoundingBox(); var textMaterial = new THREE.MeshBasicMaterial({ color: 0xb0bca7 ...

What is the best way to customize the appearance of an Angular tree component?

I'm attempting to incorporate the style of the ACE Admin theme into the angular-tree-component. Currently, my tree looks like this: https://i.sstatic.net/ktiEf.png However, I desire to apply styles from the Angular tree guide in order to achieve a ...

The constricted styles are causing the whole page to bounce (scroll) up and down

On my SPA frontend, I have a parent div with a height of 580 containing 9 smaller divs (about 190px in height each). The parent div has an overflow set to hidden so that only 3 elements are visible at one time. Every 5 seconds, I change the styles by addin ...

Instantiate a fresh Date object in JavaScript by passing in my specific parameter

Check out this code snippet: $(function () { var timestamp = 1443563590; //Tue, 29 Sep 2015 21:53:10 GMT var today2 = moment.unix(timestamp).tz('America/New_York').toString(); alert(today2); //var dateinNewYork = new Date(wh ...

The persistent bar that refuses to abide by z-index rules in the Google Chrome browser

While working on a website, I decided to add a navigation bar in ribbon style. To ensure it sticks to the top of the viewport when the user scrolls, I used the jQuery Sticky Plugin. Everything was running smoothly in Firefox, but unfortunately Chrome star ...

Adjust the color of the chosen <li> item to a different shade

I want to change the text color of the "Sale" item, but not a phone number using only CSS. Unfortunately, I am unable to modify the HTML code. https://i.stack.imgur.com/PPnna.png .menu.left a:first-child { background: yellow; color: red; } https ...

Increase the day count by 1 on every third cycle

I've been working on a code to increment the days in a date variable every third iteration using modulus. While I have managed to get the logic for every third iteration right, the day doesn't seem to increase by 1. I searched online and found s ...

Angular 2 - Error: Unable to access the property 'createMessage' as it is undefined

I want to import a JavaScript file into my Angular 2 project without having to rewrite it in Typescript. However, when everything is connected correctly, I encounter the following error... "EXCEPTION: TypeError: Cannot read property 'createMessage&ap ...

The time-out counter fails to detect the input field

After writing a method to reset the timeout on mouse click, keyup, and keypress events, I realized that it does not account for input fields. This means that when I am actively typing in a field, the timeout will still occur. Below is the code snippet: ...

Angular Material (8) error code S2591: The variable 'require' is not defined in the current scope

Currently, I am attempting to record the date and time in the JavaScript console. Despite the code successfully logging the dates, an error message persists: Note: The code is functioning properly, with the dates being displayed in the console. It is only ...

Dealing with the overflow issue on Android 4.1 using position: relative and position: absolute

I have a question regarding creating a dynamically filling rounded button. I have successfully created an inner div inside the button with absolute positioning at the bottom. It works perfectly on Chrome webview, but I'm facing issues on Android 4.1. ...

Utilizing a search bar with the option to narrow down results by category

I want to develop a search page where users can enter a keyword and get a list of results, along with the option to filter by category if necessary. I have managed to make both the input field and radio buttons work separately, but not together. So, when s ...

Reading and storing HTML source code in Python line by line

Recently, I embarked on the journey of learning Python 3. As I delved into my Python book, I found myself pondering some questions... One of my challenges is to extract key words from HTML source code. I managed to write code that allows me to open a URL ...

After installing the npm package, use browserify to bundle the bs58 library

I am trying to bundle the bs58 module using browserify by following the instructions provided on this website: npm install --save bs58 npm install -g browserify browserify < /mypath/lib/bs58.js > /mypath/lib/bs85.bundle.js In my HTML + JS file, I ...