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

The headline box is displaying CSS code instead of the content. How can this issue be resolved?

Having an issue with a WordPress template that features a blue "headline" box that I need to change the color of to #333399. I tried inspecting the element, browsing through the code, and identified the code below as what needed modification: #headline, # ...

What is the best method to implement a loading spinner within a React and Node application while using Nodemailer?

Is it possible to implement a functionality where clicking the Send button triggers a spinner next to the button, followed by changing the button text to "Message Sent"? I managed to change the button text, but there is no loading time, it happens instantl ...

Guide to assigning a value to a label in Razor's Html.DropDownList

I'm trying to assign a specific label value to the dropdownlist instead of the default value, but it seems like I might be making a mistake. @Html.DropDownList("cboCategoria", new SelectList(Model, "ID", "Nome"), new { @id = "cboCategoria", @label = ...

What does the HTML and JS code look like when using Next.Js?

Here's an illustration of the desired result: codepen.io/j0be/pen/jWGVvV How can I implement this HTML and JS in Next.js? I am looking to customize this code using TypeScript and SCSS in Next.js. However, I am unsure about how to convert the HTML an ...

Switch the menu state to closed when we click outside of it while it's open

I'm currently working on a scenario involving a menu that toggles when a button is clicked. The issue I'm facing is that when I click on the menu button, it opens correctly. However, the problem arises with the following code: Whenever I click ...

Scalable Vector Graphics Form Field

I'm looking to enable user input in one of my SVG text fields when they click on it. Any ideas on how to achieve this? const wrapper = document.getElementById('wrapper'); const text = document.getEl ...

Deactivate a specific button within a row on a Primeng table by clicking on it

I'm trying to modify my primeng table so that each row has a button, and when I click on a button, only that specific button should be disabled. However, in my current code, all buttons are getting disabled with a single click. Can someone please help ...

Use a CSS rule only if the element is not nested by using the :not selector

Could use some assistance with this coding issue: .element { border: 1px solid red; display: block; } I want to exclude this rule when .element is a descendant of .no-border using the :not pseudo-selector. For example: <div class="element">I ...

Determine the specific table entry that was clicked on

Currently, I am working on developing a dynamic table that includes a button in one of its columns, which triggers a bootstrap modal. I'm a bit unsure on how to determine which button was clicked and how to populate the table accordingly. Admittedly, ...

What is the best way to create a view that caters to both administrators and regular users?

Currently, I am developing a system in Django which displays different fields and options based on whether the user is an administrator or a Jefe from the table. The administrator can access the panel in Django. class UsuarioCrear(SuccessMessageMixin, Crea ...

Issue encountered while attempting to remove a row from a table (JavaScript)

I'm encountering an error when attempting to delete a table row: "Uncaught ReferenceError: remTable is not defined index.html:1:1". When I inspect index.html to identify the issue, I find this: remTable(this) This is my code: const transact ...

Error: The property 'length' cannot be read from an undefined parent causing Uncaught TypeError

Hey there, take a look at this cool stuff http://jsfiddle.net/J9Tza/ <form class="validation"> <div> <input type="email" class="form-control" id="inputEmail" name="email" placeholder="Email" pattern=".{3,200}" title="3 to 200 characters" r ...

The location of the footer is not aligned correctly

Recently, I encountered an issue that has left me puzzled. The problem is that the footer on my webpage is appearing between the calendar button and the calendar itself. Here is a snippet from my calendar.html file: {% extends 'base.html' %} {% ...

Struggling to make a basic ajax request function correctly

I've been experimenting with this code snippet in my browser's console. $.ajax({ type: 'GET', url: 'http://stackoverflow.com/', dataType: 'html', success: function() { console.log("Yes, t ...

Solid white border encasing the full page

While I know there have been similar questions asked before, I believe mine is unique because I haven't found a solution anywhere. Recently, I started a new project in React. I decided to remove App.css and index.css, and created a single component wh ...

Unable to locate a resolution for the error message "Warning: Task "uglify" not found"

Below is the content of my Gruntfile.js: module.exports = function(grunt) { require('load-grunt-tasks')(grunt); grunt.initConfig({ uglify: { start: { files: { 'js/script.min.js': ['js/script.js&a ...

What could be the reason for esbuild not being included in the installation process of a fresh Rails 7 application that

After initiating a fresh Rails 7 app, I utilized the command line syntax: $ rails new app_name --css=bootstrap An error occurred during app creation specifically when including --css=bootstrap: Install esbuild run yarn add esbuild from ".& ...

Using javascript, hide or show a div without using jquery or the display:none property

I am looking for a way to show/hide a div up and down, but I have some requirements: I cannot use jQuery: toggle(), slideToggle(), fade, animate, etc. all use display: none, and I need the div to still occupy space in the DOM (I will be processing things ...

Unable to apply text decoration to a floating element

Why is text-decoration not applying to a span inside a div after floating the span, and how can this be fixed? To see the issue in action, visit: http://jsfiddle.net/wtBDX/2/ div { color: red; text-decoration: line-through; } div span { float: rig ...

What could be the reason for the lack of responsiveness in my input box?

http://jsfiddle.net/4ws3L6kn/1/ Can anyone help me figure out why this isn't responsive? What mistake did I make? <div id="DIV_1"> <div id="DIV_2"> <div id="DIV_3"> <button id="BUTTON_4"> ...