Tips for adjusting the height of an animated div to 100%

I am currently experimenting with CSS animations because I find them extremely cool.

My current project involves creating a navigation bar on the left side of the page. I want the bar to stretch to 100% of the page's height. However, when I set this property for the height, the bar disappears from view. Is it possible that CSS animations do not support % based height and width?

Here is my CSS:

body{
    overflow: hidden;
    padding: 0;
    overflow-x: hidden
}
div {
-webkit-animation:myfirst 4s; /* Safari and Chrome */
-webkit-animation-fill-mode: forwards;
font-size: .2px;
padding-left: 5px;
}
@-webkit-keyframes myfirst /* Safari and Chrome */{
    0% {
        background:orange;
        width: 100px;
        height: 100px;
        -webkit-transform:rotate(360deg);
        opacity: 0.7;
    }
    100% {
        background:orange;
        width: 100px;
        height: 100%;
        -webkit-transform:rotate(360deg);
        opacity: 0.7;
        font-size: 16px;
    }

The HTML:

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/reset.css">
<link rel="stylesheet" type="text/css" href="css/sidebar_left.css">
</head>
<body>

<div></div>

</body>
</html>

Link to jsFiddle

Answer №1

To ensure an element's height is set as 100% of the page height, the body element should be its direct parent and both the body and html elements must also have a height of 100%. If the element is nested further down in the DOM, you can maintain the chain of setting each parent and grandparent to 100% height.

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

Is it possible to retrieve siblings using PHP's DOMDocument?

After using PHP's DOMDocument to retrieve h3 references, I am now seeking a way to access the next elements following these h3 tags. Rather than resorting to a regular expression for HTML parsing, I want to utilize proper DOMDocument methods. The cur ...

Exploring the Art of CSS Design

I am trying to create a design using HTML Graphics, but it is not working as expected. Can someone guide me on how to achieve this design using CSS and HTML? https://i.sstatic.net/WwtXJ.jpg ...

"Utilizing Bootstrap to create a visually appealing image and text combination in the

I need to arrange the image, first span, and second span in a vertical stack for xs devices. The alignment should be centered for xs devices. If you want to see my code: CLICK HERE <div class="row"> <div> <div class="col-md-9 c ...

How can I replicate Firefox's behavior for HTML5 validation in Chrome by displaying red borders around required or invalid input elements?

Is there a way to add red borders around the input element in Chrome for HTML5 validation similar to Firefox? I've been searching extensively but have yet to find a definitive answer. Any guidance on how to achieve this using CSS would be highly appr ...

Tips for creating a square HTML element

Looking to customize my react calendar with square tiles. Currently, the width is determined by the overall calendar width, but I want the height to match. https://i.sstatic.net/3vVrq.png Sample HTML: <button class="react-calendar__tile react-cal ...

"Resizing a Javascript file resulting in the creation of a faulty base64

I have been attempting to resize images on the client side using HTML5 before uploading. However, it seems that the base64 string is broken as it contains spaces, line breaks, and other unexpected characters. Even after removing them, the string remains br ...

Utilize the entire width for header elements

I have implemented four header elements: home, about, portfolio, and contact. I want these elements to stretch across the entire navigation bar with each taking up 25% of the space. How can I achieve this? Additionally, I specified that the home element sh ...

The difference between using an event listener directly in HTML vs. using the add

Looking to customize the behavior of an HTML element using event listeners? There are two ways to accomplish this: <form class="my-form"> <input type="submit"/> </form> <script> document.querySelectorAll(&quo ...

What is causing my animation to jump when using the Web Animation API reverse() function?

I've come across various sources stating that when you call reverse() while an animation is playing, it should have the same effect as setting playbackRate to -1. However, in my case, using reverse() makes my animation behave erratically and jump arou ...

JavaScript for rotating an element upon button click

My webpage design <div id="yabanner"> <img src="img/ok.jpg"> </div> <button>Click Me</button> <button>Click Me</button> <button>Click Me</button> My script code var button = document.getElementsBy ...

How can I make sure that the inset box-shadow completely covers the text inside a div?

I've been struggling to figure out how to get the inset box-shadow (#shadow-overlay) to properly cover the text inside #text-container. Despite my efforts, which included experimenting with z-index and different positioning techniques, I still haven&a ...

What is the best way to combine the average hours, minutes, seconds, and milliseconds in JavaScript?

I am seeking guidance on how to calculate the average of three different times in JavaScript. In the scenario presented below, the average of the three times is calculated as 01:42:22:566. <form action="/action_page.php"> <label for= ...

Fashionable selection form

I'm having trouble with styling my select form to have a background-color and border. I've tried applying CSS properties, but it doesn't seem to be working as expected. Here is the code snippet in question: <select class="size"> ...

What is the best way to prevent a website from continuing to scroll past a specific point?

Here is the code I'm working with: Link to my Codepen I need to figure out how to prevent the website from scrolling beyond the end of the content. I've tried using overflow-y:hidden; in the body element, but that stops the page from scrolling a ...

HTML/CSS Challenges: Dealing with Play Button Alignment Issues

Having a header on the left side and wanting to insert a button in line with the header on the right side has me facing some issues. Setting "position:relative" and "top:400px" moves the button perfectly, as does adding "left:200px". However, upon hoverin ...

Utilizing Javascript to Open a New Tab from Drupal

I'm attempting to trigger the opening of a new tab when a specific menu link is clicked within a Drupal website. My initial approach was to incorporate JavaScript directly into the content of the page, but unfortunately this method has not been succes ...

Place an image in a div so that it is centered both vertically and horizontally

I have been trying to center an image both horizontally and vertically, but it seems like my code is not working properly. Here is what I have so far: #parent { position: relative; float: left; width: 700px; height: 400px; overflow: hi ...

How can Bootstrap be utilized for Image Overlay?

I'm currently using bootstrap and have a 3x3 grid of 200x200 images. I've searched everywhere for a solution to add an overlay, but haven't had any luck so far. I'm still new to coding and trying to figure things out. I saw on Serenbe. ...

Displaying a list within a circle that elegantly animates, and then, after two full rotations, magically morphs

Can icons be displayed in a circle and after 1,2 rotations, revert back to the list view? https://i.sstatic.net/p4Jxm.png If so, when it forms after 1,2 rotation, it should resemble a line. https://i.sstatic.net/uJW24.png In summary, looking for a CSS3 ...

I've encountered an issue where my React website functions correctly on the development server but not on the live website. Where should I start investigating to find the cause of this discrepancy?

I am trying to embed a Datawrapper map using the following code: import InnerHTML from 'dangerously-set-html-content' export function Map1(){ const htmlFile = `<div style="min-height: 374px"> <script type="text ...