Creating a heading transition that moves from the bottom to the top with CSS

I am looking to add an animation effect to the H1 element in my program. I want it to smoothly appear from the bottom hidden position using a CSS transition when the page loads. How can I achieve this? Additionally, I need the height of the bounding element to remain fixed while the text pops up from the bottom in CSS. What would be the most effective method to accomplish this task? Below is the code snippet:

import "./styles.css";

export default function App() {
  return (
    <div className="App" id="heading">
      <div className="bounding">
        <h1 className="boundingelem">Product</h1>
      </div>
    </div>
  );
}

The corresponding CSS code is provided below:

.App {
  font-family: sans-serif;
  text-align: center;
  font-size: 9vw;
  text-transform: uppercase;
  font-weight: 900;
  line-height: 1;
}
.bounding {
  width: fit-content;
  background-color: orange;
  overflow: hidden;
  height: 150px;
}
.bounding .boundingelem {
  transform: translateY(10%);
}
.bounding .boundingelem::before {
  content: "Product";
  position: absolute;
  color: white;
  top: -4px;
  left: -4px;
  -webkit-text-stroke: 2px red;
}

Answer №1

If you want to create a smooth animation for transform, you can use transition property:


.bounding {
  ...
  position: relative;
}

.bounding .boundingelem {
  ...
  position: absolute;
  top: 150px;
  transition: transform 0.25s ease-in-out;
}

.bounding .boundingelem .show {
  ...
  transform: translateY(-150px);
}

To trigger this transition on load, simply add the class show to h1.

-> However, keep in mind that your transform CSS is conflicting with itself - setting transform: translateY(10%) without considering the fixed height of the container element bounding. By using top: 150px and then transitioning to translateY(-150px), you are essentially hiding and revealing the element upon loading.

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

I am experiencing an issue where localhost is not displaying the JSON output for the Router and controller that I have

Recently delving into the world of NodeJS, I find myself facing a roadblock. While attempting to manage requests, my localhost appears to be endlessly loading or throwing an error. Error: cannot GET/ I aim to showcase the JSON data on my local site. Wh ...

The functionality of ClickMarker is malfunctioning in the XY Amcharts

Recently, I encountered a situation where I had to incorporate custom legends in XY Amcharts. After managing to implement them successfully, I came across an issue. Despite adding event listeners to the legends, the associated function failed to trigger. ...

Unable to retrieve Vuex state within a function

Currently, I am developing a Laravel+Vue application where Vuex is used for state management. While working on form validation, everything seems to be progressing smoothly except for one particular issue that has me stuck. The problem arises when I attempt ...

What is the most efficient way to enable seamless communication between sibling components in Vue.js 2?

Just starting out with Vue.js 2 and I'm really enjoying it so far despite being new to it. Currently using the latest version. I've begun working on my first larger application and ran into a scenario right off the bat where I have a main app co ...

Encountered an error in Pytorch LSTM conversion to ONNX.js: "Uncaught (in promise) Error: LSTM_4 node does not recognize input ''

I am attempting to execute a Pytorch LSTM network in the browser, but I am encountering the following error: graph.ts:313 Uncaught (in promise) Error: unrecognized input '' for node: LSTM_4 at t.buildGraph (graph.ts:313) at new t (graph.t ...

How to Insert a Background Image into Advanced Custom Fields (ACF) using CSS

Hey there, I'm facing a bit of a challenge with this particular section. In the past, I've only included ACF PHP within HTML when the background image was directly in the HTML code. Now, however, I have two shapes specified in my CSS using pseudo ...

Why does this inner HTML table always adjust its width based on the content within it? Is there a way to make it match the width of its container instead

I'm not very familiar with HTML and CSS, and I've come across a problem. Here is the CSS structure in question: <!-- TECHNICAL REFERENCE: --> <div id="referenteTecnicoTab"> <table width="800px" class="standard-table-cls table-he ...

trigger the focusout event within the focusin event

I am attempting to trigger the focusout event within the focusin event because I need to access the previous value from the focusin event, but the focusout event is being triggered multiple times. $('tr #edituser').focusin(function(){ var ...

Click on the dropdown item in the Bootstrap btn-group dropdown

I am interested in clicking the dropdown item within the btn-group and triggering an alert message. This is the HTML code I have: <td> <div class="btn-group" role="group"> <button id="btnGroupVerticalDrop2" type="button" class= ...

Angular directive preventing default action but Chrome still loading image on drag

Has anyone encountered an issue with an angular directive that is not successfully preventing Chrome's default action? Below is the code for the directive in question: app.directive('fileDrag', function () { return { restrict: ' ...

What is causing the delay in starting to play an audio track when it is clicked on?

I am facing an issue with my application and have created a minimum code example on StackBlitz to demonstrate the problem. The problematic code is also provided below. My goal is to have the Audio component play a track immediately when the user clicks on ...

Preventing variables from reinitializing in express.js

Within my app.js file, I invoke a search function that communicates with an LDAP server. Upon doing so, the server sends back a cookie which is essential for my subsequent queries. My intention was to save this cookie as an app.local variable in my app.j ...

Retrieve tabs according to the value selected in the dropdown menu

When a value is selected from a dropdown with options 1 to 5, I want to display a corresponding number of tabs. Below is the HTML code for the select box: <select id="Week" name="Week"> <option value="1">1</option> <option val ...

JSON and autocomplete feature causing performance problems

Developing an application that functions both online and offline using technologies like application cache and local storage is my current project. Utilizing jQuery mobile along with a jqm autocomplete solution from , I aim to create a seamless user experi ...

Utilize Custom Field to incorporate background videos from websites like Youtube or Vimeo into your content

I've been working on implementing a video background for my website. I came up with a custom code to embed URL links from Youtube and Vimeo using "oEmbed". The process is functioning well, but I'm facing some challenges in setting the background ...

Utilize ajax to send both images and text simultaneously

I'm utilizing javascript's 'formData' to transmit image files through ajax. Is there a way to append extra data to formData, like a text string? JS: $("#post-image").on("click", function(){ $.ajax({ url: "../../build/ajaxe ...

Issue: the size of the requested entity is too large

Encountering an error message while using express: Error: request entity too large at module.exports (/Users/michaeljames/Documents/Projects/Proj/mean/node_modules/express/node_modules/connect/node_modules/raw-body/index.js:16:15) at json (/Users/ ...

The issue of execution order in JavaScript Recursion with promises

In the process of developing a method for creating markup to be used in a web app's off-canvas navigation. One of the challenges I am facing is making an asynchronous callback to another service that provides children nodes for the parent menu node (r ...

Unordered calling of functions in JavaScript - is it possible?

I'm currently working on a project that involves extracting data from an SQL database and converting the output of a query (which is a number) into a corresponding color, which is then passed to a JavaScript variable. Essentially, I am using ajax to ...

Utilizing Regex Patterns to Manipulate CSS Attributes

I am dealing with a string containing CSS properties and their values: str = "filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#cccccc', endColorstr='#000000'); background: -webkit-linear-gradient(top, black, wh ...