Click here to Skip to main content
15,886,822 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi how can i set a fadein animation for hr in my page ?
like this site hr sample animation
Posted
Comments
Sergey Alexandrovich Kryukov 8-Dec-15 22:30pm    
What have you tried so far?
—SA

1 solution

This is the simplest example I managed to craft:
CSS
hr { width: 10%; transition:width 1s; }
hr:hover { width: 100%; }

In my example, the animation starts by hover. If you want to do something on the event when your page is loaded, you will need to use JavaScript. For example:
HTML
<html>
   <head>
      <title>HR transition demo</title>
      <style>
         hr { width: 10%; transition:width 1s; }
      </style>
   </head>
<body>

<hr id="hr"/>

<script>
   
   document.body.onload = function() {    
      var hr = document.getElementById("hr");
      hr.style.width = "100%";
   }
 
</script>

</body>
</html>

—SA
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900