HTML/CSS - Troubleshooting Animation Issues

I am currently experimenting with different website animations and implementing responsive design.

However, I encountered an issue when trying to apply these changes to my header, which also affects the .heading element. It seems that there is a problem with the height of the #main container, where its height appears to be 0.

This issue could possibly be due to a structural problem in the code.

Can someone assist me with this? I hope my explanation is clear enough.

Here is the code snippet I'd like to share:

@keyframes moveInLeft {
                0% {
                    opacity: 0;
                    transform: translateX(-10rem);
                }
                80% {
                    transform: translateX(1rem);
                }
                100% {
                    opacity: 1;
                    transform: translate(0);
                }
            }

            *,
            *::after,
            *::before {
                margin: 0;
                padding: 0;
                box-sizing: inherit;
            }


            /* Animations */

            header {
                float: left;
                top: 0;
                left: 0;
                width: 100%;
                animation-name: moveInLeft;
                animation-duration: 2s;
                animation-timing-function: 1s;
                overflow: hidden;
            }

            #container {
                overflow: hidden;
            }

            html {
                font-size: 62.5%;
                font-family: 'Ubuntu', sans-serif;
            }

            body {
                font-size: 2rem;
                box-sizing: border-box;
            }

            .options {
                background-color: #777;
                width: 100%;
                display: block;
                z-index: 1;
                height: 3.5rem;
                margin-bottom: 3rem;
            }

            .select-active {
                background: green;
            }

            .options ul {
                list-style-type: none;
            }

            .options ul li {
                float: left;
                transition: all 1000ms;
            }

            .options ul li a {
                display: block;
                padding: 0.55rem;
                color: white;
                text-decoration: none;
            }

            .submenu {
                width: 15%;
                float: left;
                background-color: white;
                margin-top: 1.3rem;
            }

            .body {
                width: 80%;
                float: left;
                padding: 1.5rem;
            }

            .heading {
                color: black;
                text-align: center;
                font-size: 5rem;
                padding: 0.6rem;
                background-image: linear-gradient(to right bottom, rgba(0, 0, 0, 0.8), rgba(255, 255, 255, 0.8)), url(/images/logo.png);
                margin-left: 5rem;
                width: 95%;
            }                                                                           

            h2 {
                text-align: left;
                padding-right: 1rem;
                margin-top: 4rem;
            }

            .footer {
                background-color: grey;
                float: left;
                width: 100%;
                color: white;
                padding: 4.2rem;
                margin-top: 7rem;
            }

            .submenu ul li {
                list-style-type: none;
                border: solid 2px white;
                padding: 1rem;
                background-color: rgb(220, 220, 220);
                margin-left: 2rem;
                font-size: 1.5rem;
                transition: all 1000ms;
            }

            ul li {
                cursor: pointer;
            }

            .submenu ul li:hover {
                background-color: rgb(0, 150, 255);
                border-radius: 30px;
            }

            .options ul li:hover {
                background: black;
                transform: translate(5px, 5px);
            }

            .picture {
                float: right;
                position: relative;
                top: -6.5rem;
                left: -11rem;
            }

            .logo {
                width: 2.5rem;
            }

            .footer .bg-video__content {
                object-fit: fill;
                height: 15rem;
                 opacity: .5;            
            }

            @media screen and (max-width: 992px) {
                header,
                .submenu {
                    display: none;
                }
            }
<link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet">

                <div id=container>
                <header id="header">
                <nav class="options">
                <ul>
                <li class="select-active"><a href="">CSS</a></li>
                <li>
                <a href="">
                SASS
                </a>
                </li>
                <li><a href="">Javascript</a></li>
                <li span style="word-spacing: 0px"><a href="">Front End vs Back End</a></li>
                </ul>
                </nav>
                <div class="picture">
                <img class="logo" src="https://seeklogo.com/images/C/css3-logo-8724075274-seeklogo.com.png" alt="">
                </div>
                </header>

                <main id="main">
                <aside class="submenu">
                <ul>
                <li>Introducción</li>
                <li>Styling block</li>
                <li>Selectores</li>
                <li>Propiedades</li>
                <li>Cascada y herencia</li>
                <li>The Box Model</li>
                <li>Responsive</li>
                </ul>
                </aside>
                <section class="body">
                <header class="heading">CSS
                </header>
                <article class="text">
                <h2>Styling Blocks</h2><br><br>

                <p>...[large text content]...</p><br>
                                ...[additional large text content]...

                <p>...[more large text content]...</p> <br>
                </article>
                </section>
                </<main>

                <footer class="footer">

                <div class="bg-video">
                <video class="bg-video__content" autoplay muted loop>
                <source src="vid.mp4" type="video/mp4">
                <source src="vid.webm" type="video/webm">
                Your browser is not supported!
                </video>
                </div>
                </footer>
                </div>

Answer â„–1

If your #main div contains floats, the height will be 0. To fix this issue, you should use a 'clearfix' (Learn more about it here). Here's how to implement it:

#main:after {
  content: "";
  display: table;
  clear: both;
}

Check out this helpful resource for more information.

Consider utilizing flexbox for your layouts instead of floats, as they are becoming outdated and not considered best practice for page layouts anymore.

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

In Chrome, there is a conflict between the screen width when using `position: absolute` and `position: fixed` if there is vertical

I'm in the process of developing a website with a video banner set to fixed positioning in the background, and a div that has absolute positioning covering part of the video on the bottom half. However, I've encountered an issue - when I add this ...

Adjust the dimensions of a button in Jquery Mobile using a designated class

I am in the process of creating a Mobile App using Jquery Mobile, I'm aiming for a result like this: Unfortunately, what I end up with is this: I prefer not to utilize .ui-btn in my CSS, as I have already specified custom-btn. Here's the code s ...

Displaying both items upon clicking

Hey there, I'm having an issue where clicking on one article link opens both! <span class='pres'><img src='http://files.appcheck.se/icons/minecraft.png' /></span><span class='info'><a href=&apo ...

Tips for employing Flex-grow alongside the behavior of "justify-content: start"

I am working with a flex container setup like this: .container { display: flex; flex-flow: row wrap; justify-content: start; width: 100%; } .item { border: 1px solid red; flex: 1 1 33%; height: 100px; } <div class="container"> <d ...

Leveraging the :has pseudo-class in Tailwind along with adjacent sibling selectors

My CSS code is working perfectly as intended. [data-type='transfer']:has(+ [data-type^='sale_']) { opacity: 0.25; } This CSS snippet targets elements with data-type="transfer" that are next to elements containing data attri ...

Tips for extracting information from JSON data in the provided API example

{"Dina-Kar":{"com":"available"},"DinaKarPool":{"com":"available"},"DinaKarStore":{"com":"available"},"DinaKarOnline":{"com":"available"},"DinaKarParts":{"com":"available"},"DinaKarJack":{"com":"available"},"DinaKarTunes":{"com":"available"},"DinaKarSmart": ...

Show an image based on a query parameter

Currently, I am developing a PHP project and I am facing an issue with loading an image from a query string. Here is the code snippet I am using: <img src="load_image.php?name=Profile_Photo_Small" /> Is there anyone who can help me out with this pro ...

Is there a way to enable data-add-back-btn using jQuery script?

Currently, I am utilizing jQuery 1.9.1 and jQuery Mobile 1.3.1 to define multiple pages within my project setup: <div id="q1" data-role="page" data-add-back-btn="false" data-back-btn-text="Home"> <div data-role="header" data-position="fixed" ...

Attempting to transfer a string variable into a JavaScript scope within an HTML document using handlebars-express

Struggling to pass a variable from server-side to client-side using handlebars-express... After searching through the content here for some time, I realize I might need some help. I've confirmed that the object passed is indeed of string type, but h ...

The transparency of an image is being lost when it is used in a modal

I am facing an issue when trying to append a modal that contains only a transparent gif. The problem arises when the transparent background of the gif is not displayed properly. There seems to be no issue with the transparency settings of the gifs themselv ...

Columns that adapt to different screen sizes while maintaining a fixed aspect ratio, limited to a maximum of two columns

I'm facing a challenge trying to blend a few elements together: My goal is to have two columns take up 100% of the browser width with a height that adjusts relative to this width. I want these columns to switch to one column when the viewport is sma ...

Is it possible for Susy to output a pixel-based span?

As a newbie to Susy, I hope you don't mind if I ask a seemingly silly question... I'm trying to figure out how to calculate responsive padding within a Susy grid. The standard formula is: (target / context) x 100. Is there a way for Susy to pr ...

Displaying a different background color on a colgroup element in CSS when a scroll is

My webpage contains one or more large and complex tables, where I use JQuery to add background-color to tr and colgroup elements when hovering over the table(s). An issue arises when there are multiple tables on a page that extends beyond the viewport wit ...

Why @font-face doesn't display on older versions of Internet Explorer like IE 7 and IE

Our website has the following CSS code. The use of a smiley face is to ensure compatibility with IE 7 and IE 8. However, while the site's fonts display correctly on IE 9, Chrome, Firefox, etc., there seems to be an issue with IE 7 and 8. @font-face { ...

Using jQuery to target the element before

Is there a way to determine the width of elements located before an element when it is hovered over? I attempted to achieve this using the following code: $('ul li').hover(function() { $(this).prevAll().each(function() { var margin = $(this ...

Unable to send messages through contact form - Issue with HTML/CSS

I had successfully achieved the desired outcome before, but now I am facing difficulties replicating it. The linked image displays my intended result versus what is currently happening. https://i.stack.imgur.com/QUCuN.png What could be causing this issue ...

Prevent users from selecting elements on the mobile site

Hey there! I'm currently working on preventing users from selecting items on my mobile site. While I've been successful in doing so on a regular website using the CSS class below .unselectable { -moz-user-select: -moz-none; -khtml-user-s ...

Maintain scrolling at the bottom with React.js

Is there a way to make a div element increase in height through an animation without extending beyond the viewable area, causing the window to automatically scroll down as the div expands? I am looking for a solution that will keep the scroll position lock ...

How can I showcase API information on a website with the help of Node.js?

Hello everyone, I'm a beginner at creating websites and I am eager to explore nodejs. Currently, I am utilizing an API to retrieve data in node: request(options, function (error, response, body) { if (error) throw new Error(error); console.log(b ...

Incorporate Multiple Choice Queries into your PHP Online Form

My PHP web form consists of text fields, dropdowns, and radio buttons. When submitted, the information is sent to me via email. I am trying to implement a multiple choice question with checkboxes. Although I can create the form field, I'm struggling t ...