Is there a problem with animation in Css?

https://i.sstatic.net/OINsU.png

Issue with Animated Div I am working on an animated div where the red background expands to the left, then shrinks to reveal an image and text. However, I am facing a problem where at the end of the animation, the right column (red background) shrinks again unexpectedly. I can't seem to figure out where this behavior is coming from in the CSS/SASS code. Due to this issue, there is a momentary display of the second image before it adjusts properly on mobile screens.

.masthead-img-left {
  overflow: hidden;
}
.masthead-img-left .text-content-right:before {
  background-color: red;
  -webkit-animation-name: mastHeadanimateTextRight;
  -webkit-animation-duration: 1.5s;
  animation-name: mastHeadanimateTextRight;
  width: 100%;
  height: 100%;
  content: "";
  position: absolute;
  left: 0;
  z-index: 1;
  transition-property: right, left;
  transition-property: right, left;
  margin: 0 auto;
  display: block;
  transition: all 5s linear;
}
@-webkit-keyframes mastHeadanimateTextRight {
  0% {
    width: -1140px;
    -ms-transform: translateX(-1140px);
    /* IE 9 */
    -webkit-transform: translateX(-1140px);
    /* Safari */
    transform: translateX(-1140px);
  }
  25% {
    width: -1140px;
  }
  50% {
    width: 1140px;
  }
  75% {
    width: -1140px;
  }
  100% {
    width: -555px;
    -ms-transform: translateX(0px);
    -webkit-transform: translateX(0px);
    transform: translateX(0px);
  }
}
.masthead-img-left .text-content-right-texts h1 span {
  color: black;
}
.masthead-img-left .text-content-right-texts h1,
.masthead-img-left .text-content-right-texts p {
  color: white;
  z-index: 2;
  position: relative;
  -webkit-animation: mastHeadAnimateMovingText 3s;
  animation: mastHeadAnimateMovingText 3s;
  transition: all 3s linear;
}
.masthead-img-left .content-right-image {
  -webkit-animation-name: mastHeadanimateImageLeft;
  -webkit-animation-duration: 1s;
  animation-name: mastHeadanimateImageLeft;
  transition: all 1.5s linear;
}
@-webkit-keyframes mastHeadanimateImageLeft {
  0% {
    opacity: 0;
  }
  25% {
    opacity: 0;
  }
  50% {
    opacity: 0;
  }
  75% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}
<html>

<head>
  <title>Products Slider</title>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">


  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
    crossorigin="anonymous">
  <link rel="stylesheet" type="text/css" href="css/style.css">
  <link href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" rel="stylesheet">

  <script src="https://code.jquery.com/jquery-3.3.1.js" integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
    crossorigin="anonymous"></script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
    crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
    crossorigin="anonymous"></script>


</head>

<body>

  <div class="container masthead-img-left my-5">
    <div class="row no-gutters d-flex justify-content-center">
      <div class="col-lg-6">
        <img src="https://www.dropbox.com/s/xy33pol9ctj24wt/" alt="image goes here" class="content-right-image img-fluid">

      </div>

      <div class="col-lg-6 p-3 text-content-right d-flex justify-content-center align-items-center">
        <div class="text-content-right-texts">
          <h1>Heading Title Here</h1>
          <p>
            Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consectetur in quos possimus quaerat ex deserunt
            provident. Quae accusamus explicabo quia aperiam esse. Non ipsum, quidem quisquam alias atque velit
            voluptatem!

          </p>
        </div>
      </div>
    </div>
  </div>

</body>

</html>

https://i.sstatic.net/millg.png

Answer №1

In my opinion, the solution to this issue is quite straightforward. All that needs to be done is:

< div class="container masthead-img-left my-5" >

should be changed to:

< div class="container masthead-img-left my-5" style="padding: 0px;" >

I believe this should resolve the bug. Thank you!

Answer №2

Is it possible that instead of padding, you should consider trying:

p, div { box-sizing:     border-box }

...to see if that resolves the issue?

Another potential factor could be the

margin: 0 auto

which may be occupying some space on the page.

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

Printing content from a web page using window.print() function in a form using javascript and angular

Within my HTML code lies a form, complete with a variety of fields: <div class="card-body" id="print"> <form [formGroup]="form"> <div class="text-muted" *ngFor=" ...

Create an input field that limits the user to typing only three unique characters

How can I restrict the user to input only three characters in a text field? Specifically, I want to limit it to either 3, 6, or 9. ...

Creating a table in HTML using the innerHTML property

document.getElementById("outputDiv").innerHTML = ""; document.getElementById("outputDiv").innerHTML += "<table border=1 width=100%><tr>"; for(j=1;j<=10;j++) { document.getElementById("outputDiv").innerHTML += "<td align=center>"+St ...

Having trouble with clicking on an icon link within a list

Seeking assistance with creating a social media icon/link list for the first time on this platform. Any help is appreciated! <div class="social-links"> <ul> <li class="m-link"> <a href="&q ...

Column of Flexbox showcasing items that have been translated

I'm having an issue with positioning items in a div of 11 elements divided into 2 columns. The first row and the last item are positioned correctly, but the items in between are shifted to the left. I've been using flexbox for a while, but I can& ...

How to automatically embed a p5.js canvas into an HTML canvas with the drawImage() method

Whenever I attempt to draw the p5.js canvas into an HTML canvas using drawImage(), I always encounter this error: Uncaught TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The provided value is not of type ' ...

How can you spot the conclusion of different lines that refuse to remain in place?

Currently, I am facing a jquery issue that has left me stumped. The website I am working on is structured as follows: <div class="Header"></div> <div class="main"><?php include('content.html'); ?></div> <div clas ...

Tips for refreshing a specific div element at set intervals using JQuery AJAX?

I need to make updates to a specific div element without refreshing the entire HTML page. The code below currently works, but it reloads the entire HTML page. Additionally, I am working with different layouts where I have separate files for the header, l ...

Styling a fixed sidebar in Vue.js

I am currently working on a layout design that includes a fixed sidebar on the left side, positioned beside a container with its own grid structure. Utilizing Vue.js means each template contains <div> elements where I attempt to incorporate additiona ...

The positioning of border-radius is off-center when the screen size is adjusted

After ensuring that everything on the laptop screen is centered and aligned properly, I encountered an issue when switching to tablet/mobile screen using dev toolbars. The top border-radius seemed shifted towards the left and the bottom 3 circles were not ...

How can JavaScript be used to parse an HTML string and convert it into tabular data in the form of a 2D array

My goal is to parse an HTML string client-side using React with TypeScript as our frontend framework. During the parsing process, I need to extract the styles associated with each element, whether it be inline styles, inherited styles, or styles defined wi ...

Different ways to manipulate the CSS display property with JavaScript

Having trouble changing the CSS display property to "none" using JavaScript. Check out my code: <div class="mydiv" onClick="clickDiv1()">hello</div> <div class="mydiv" onClick="clickDiv2()">hi</div> <div class="mydiv" onClick=" ...

Show a pop-up form when a user focuses on it using React

Hello, I have been looking for a way to create an overlay with a form that appears when a specific input field is clicked. I am trying to achieve this using React. Can someone please advise me on how to accomplish this? Here is my code import React, { Co ...

Display or conceal the nearest element that was clicked

http://jsfiddle.net/KevinOrin/xycCx/1/ jQuery('.happening-main-text .readmore').click(function() { jQuery('.divmore').toggle('slow'); return false; }); ...

Exploring Bootstrap navigation bars with customizable fixed content heights

I recently implemented Bootstrap navs into a dialog, but encountered an issue - every time I switch to another nav option, the dialog resizes due to the changing content height. To see the issue in action, you can visit this CodePen link: https://codepen. ...

A guide on iterating and accessing Vue data in a loop

I am looking to iterate through my code in order to extract the value of each form input. This is to ultimately display a total score and severity score based on the user's inputs. The total score will count the number of symptoms present (0-3), while ...

Signature incorporating visual elements in emails

I am attempting to create an HTML + Images Signature in Mozilla Thunderbird. I understand that this may not be the most ideal software for designing email signatures, but I am looking for a free alternative. While my image is attached to the email itself ...

JavaScript code to modify a table row

I have a dynamic table that increases with Firebase data, and I am trying to incorporate a delete and edit button on each row. While the remove button is working fine, I am facing issues with implementing the edit functionality. Although I came across some ...

Creating grid layouts in Bootstrap 4 with buttons

Recently, I've delved into Bootstrap 4 and HTML5/CSS. My goal is to design a text area with two buttons located on the side (horizontally centered) like this: https://i.sstatic.net/TnHSy.png Below is the code snippet that I have so far: <link ...

Utilizing AJAX and PHP to update an input field by returning a variable to the initial AJAX script

One of the measures I've implemented to secure my forms is adding a captcha code to deter bots from submitting an excessive amount of forms. The form operates using AJAX, eliminating the need for page refreshing upon submission. I have configured eve ...