Expanding the ul height with animation when the page loads

Hi there, I am a beginner looking to create a ul list that increases its height with animation when the page loads. Can this be achieved with CSS? Any assistance would be greatly appreciated.

<ul>
    <li><a href="/">title 1</a></li>
    <li><a href="/">title 2</a></li>
    <li><a href="/">title 3</a></li>
    <li><a href="/">title 4</a></li>
    <li><a href="/">title 5</a></li>
</ul>

Answer №1

It is possible to achieve this effect using just CSS, ensuring a clear and defined separation of concerns where all styling remains within the realm of CSS:

ul {
  max-height: 0;
  overflow: hidden;
  animation-name: grow;
  animation-fill-mode: forwards;
  animation-duration: 2s;
  -webkit-animation-name: grow;
  -webkit-animation-duration: 2s;
  -webkit-animation-fill-mode: forwards;
}
@keyframes grow {
  from {
    max-height: 0
  }
  to {
    max-height: 200px
  }
}
@-webkit-keyframes grow {
  from {
    max-height: 0
  }
  to {
    max-height: 200px
  }
}
<ul>
  <li><a href="/">title 1</a>
  </li>
  <li><a href="/">title 2</a>
  </li>
  <li><a href="/">title 3</a>
  </li>
  <li><a href="/">title 4</a>
  </li>
  <li><a href="/">title 5</a>
  </li>
</ul>

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

Implementing jQuery function to hide or show content upon page load

Is there a way to have the content hidden when the page is first opened, but then revealed once a button is clicked? Any suggestions? <script> $(document).ready(function(){ $("#rooms").click(function(){ $("#rooms_box").show(); }); $("#faciliti ...

Having issues with ReactJS - function not functioning properly when invoked within componentDidMount() and componentDidUpdate() lifecycle methods

I have encountered an issue that has left me puzzled, and I'm hoping someone can provide some guidance on how to solve it. The task at hand involves implementing a function that adds .active classes to li elements within a navigation bar if they cont ...

What steps can be taken to modify this jQuery code so that any changes made are also saved to localStorage

I have successfully used jQuery to change the background color of all my divs with the same class (userNumber1) when I check its checkbox. However, I am now looking for a way to save these changes to localStorage, so that they persist each time the page is ...

Implementing child components rendering in a React application using TypeScript

Just a little background information: I am attempting to build a carousel with pagination using ReactJS. Here is the code snippet I currently have: interface HTMLCarouselT { children: Array<JSX.Element> size: number; } const HTMLCarousel = ({ch ...

Refresh the current page's div content dynamically using jQuery

Is there a way to refresh just one specific div or element using jQuery AJAX? What we're aiming for is to reload only that particular div on our page without affecting the rest of the content. We attempted the following: $('#mydiv').load ...

Utilizing next/image as a backgroundImage in a div container

Currently, I am working with nextjs and I am trying to set a background Image for a specific div using next/image. Most of the sources I found only explain how to implement full screen background images with next/image, not for a single div. I stumbled upo ...

Transforming button hues and passing a property to a subcomponent when clicked using vue.js

Just starting out with vue.js, I am attempting to create a component that functions in the following way: I have four buttons and when I click on one button, I want to change the colors of all four buttons and send a prop to a child component indicating w ...

Checkbox input with alphabetical ordering

I am currently facing an issue with a form that has checkboxes, but the text is not in alphabetical order. While there are plenty of examples for lists, finding examples for checkboxes has been challenging. http://jsfiddle.net/fG9qm/ <form> < ...

Incorporate seamless integration by using the npm install command

I am currently facing an issue where I need to identify and remove unused dependencies from my package.json file every time I run npm install for my app. Is there a method to automatically include the npm package https://www.npmjs.com/package during the n ...

Arranging the data in the table by alternating rows using Datatables

I need to organize my data in a way that includes an additional row for descriptive information, but this particular row should not be sorted. It is crucial for understanding the rest of the data, so hiding or showing it is not an option. Is it possible t ...

Is there a simple method to submit to a URL without relying on ajax?

When it comes to using jQuery, the $.ajax() function is typically used for POST requests to a URL. However, in my particular situation, I am unable to use this function. I need the client to send a POST request to a URL and have the server redirect the use ...

Ways to implement a personalized button in place of jquery ui buttons

Is there a way to replace the standard jQuery dialog buttons with custom images? I have created new buttons in Photoshop with a .png extension and would like to use them instead of the default dialog buttons. I think this can be done through CSS, but if y ...

The specified project directory was not detected. Please restart Next.js in your updated directory

I am facing a challenge with running my NextJS web app on a VPS server with PM2 as the Process Management tool. Despite trying different approaches, I am unable to get it to run properly. I have a deploy.js file that successfully deploys my other NextJS an ...

Tips for inhibiting default behavior in a modal login form

I am currently working on integrating a login form using the Spring Framework MVC, but I am relatively new to ajax development. Below is a snippet of my index.jsp code: <!-- The Modal --> <div id="modal1" class="modal2"> <span onclick= ...

Ways to calculate the total number of keys within a JSON object at a certain level

I need to process a JSON file by extracting values from keys located at a specific depth. The initial value I want to access is situated here: json.children[0].children[0].children[0] Is there a method to navigate through the JSON object at a particular ...

What is the proper way to invoke a variable-function in Node.js?

I have a function called `findPeopleByName` that queries the database for a specific username, but I'm not sure how to call it in my Node.js code. Here's what I have so far: // Retrieve user_name from POST request. app.post("/api/exercise/new-u ...

Exploring the functionality of the JavaScript Date constructor in relation to

Will using new Date('2015-01-01') provide me with the exact moment equivalent to 2015-01-01T00:00:00Z? ...

Is the function for identifying the polygon in which a coordinate is located not functioning correctly?

Seeking a function to identify which polygons a coordinate falls within? Check out this function in the GitHub project: https://github.com/mikolalysenko/robust-point-in-polygon. Testing the function with the provided syntax gives the correct result (retur ...

Tips for personalizing checkbox group in a Zend framework-2 form

Could someone please help me understand how Zend Framework 2 generates HTML for a form element? Here is an example: $others = new Element\MultiCheckbox('others'); $others->setLabel('Others') ->setAttribute('name ...

Convert h264 video to GIF using Node.js

Currently, I'm utilizing the "pi-camera" library to successfully record video in a raw h264 format on my Raspberry Pi. However, I am encountering an issue with the node.js library "gifify" which keeps throwing the error "RangeError: Maximum call stack ...