Incorporate a dynamic fading effect for text and images using JQuery

I successfully implemented a Crossfade effect using Jquery:

function doAnimationLoop(o, n, t, i, a) {
        fadeInOut(o, n, t, i, function() {
            setTimeout(function() {
                doAnimationLoop(o, n, t, i, a)
            }, a)
        })
    }
    
    function fadeInOut(o, n, t, i, a) {
        return $(o).animate({
            opacity: 1
        }, n).delay(t).animate({
            opacity: 0
        }, i, a)
    }
    var duration = 20,
        fadeAmount = .3;
    $(document).ready(function() {
        var o = $("#slideshow img"),
            n = o.size(),
            t = 3000 * duration,
            i = t / n,
            a = i * fadeAmount,
            e = i - i * fadeAmount * 2,
            u = e * (n - 1) + a * (n - 2);
        o.each(function(o, n) {
            0 != o ? ($(n).css("opacity", "0"), setTimeout(function() {
                doAnimationLoop(n, a, e, a, u)
            }, e * o + a * (o - 1))) : setTimeout(function() {
                $(n).animate({
                    opacity: 0
                }, a, function() {
                    setTimeout(function() {
                        doAnimationLoop(n, a, e, a, u)
                    }, u)
                })
            }, e)
        })
    });
.home h1 {
    font-family: 'Open Sans';
    font-size: 5em;
}

.main {
    text-shadow: 0px 0px 10px #696969;
    position: absolute;
    top: 2em;
    color: #f6f6f6; 
    font-weight: 900;
    z-index: 999;
}

.sub-main {
    font-weight: 100;
    position: absolute;
    top: 3em;
    color: white;
    text-shadow: 0px 0px 50px #696969 !important;
    z-index: 999;
}

#slideshow img {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  
}
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>

<!--- Home --->
    <div class="container-fluid home" id="home">
        <div id="slideshow">
        
        <img src="http://assets1.ignimgs.com/2017/01/25/kingdomhearts28-1280-1485381321286_1280w.jpg" />
        
        <img src="http://s2.glbimg.com/C4MoBvLkWM9NFo8gtXNd9-mP-I8=/850x446/s.glbimg.com/po/tt2/f/original/2016/02/04/kingdom-hearts-4.jpg" />
        
        <img src="http://static.zerochan.net/Kingdom.Hearts.II.full.873765.jpg" />
        
        <img src="http://www.geekgirlauthority.com/wp-content/uploads/2016/10/Kingdom-Hearts.jpg" />
        
        <img src="http://2.bp.blogspot.com/-HS5t27V1LYw/UBGLg9eBDII/AAAAAAAABmY/A0U6fCuyDFc/s1600/Kingdom_Hearts_Wallpaper_by_Wightwizard8.jpg" />
        
        <img src="http://www.hardcoregamer.com/wp-content/uploads/2017/01/Kingdom-Hearts-Saga-747x309.jpg" />
        
      </div>
      <section class="row">
        <div class="col-lg-offset-1 col-md-offset-1 col-sm-offset-1 col-xs-offset-1">
          <h1 class="main" style="z-index: 100;">Title</h1>
          <h1 class="sub-main" style="z-index: 100;">Tagline</h1>
        </div>
      </section>
      </div>

I have encountered an issue I haven't faced before...

I now aim to include text on top of these images, each with their respective title/tagline that fades along with the image!

How can I achieve fading text along with the fading images?

Thank you!

Answer №1

Include the following in your stylesheet:

.animation{
    animation: fade-in 2s infinite;
}
@keyframes fade-in{
    from {opacity:0} 
    to {opacity:1}
}

Next, apply the animation class to your heading, slogan, and let me know if this meets your expectations or not?

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

After deploying to Firebase, animations suddenly cease to function

After running npm run-script build and deploying my React app to Firebase hosting with firebase deploy, I encountered an issue where my animations stopped working. I'm puzzled as to why this is happening, especially since I've included keyframes ...

What steps should I take to generate a 2-Dimension Input Array from scratch?

I am working on a project that involves creating a 2-Dimensional array of text-based numerical inputs. I aim to use the standard HTML input type box for this purpose: <input type="text"> The number of rows and columns in the array will depend o ...

What is the best way to perfectly align an SVG inside its container?

Is there a way to horizontally center this SVG within .svg_wrapper? .svg_wrapper { border: 1px solid grey; width: 200px; } <div class="svg_wrapper"> <svg viewBox="0 0 600 425"> <path d="M 175, 175 m 0, -75 a 75,75 0 1,0 ...

What is the method to retrieve the string value from a JavaScript String object?

Is there a way to extend a method to the String prototype and manipulate the string value? I'm facing some difficulty in accessing the actual string value, as this, the current object context, seems to refer to the string object instead. String.pro ...

Is it possible to update labels on an AngularJS slider using a timeout function?

I recently started implementing an AngularJS slider to navigate through various date and time points. Specifically, I am utilizing the draggable range feature demonstrated in this example - https://jsfiddle.net/ValentinH/954eve2L/ The backend provides the ...

Angular ERROR: Trying to access rating property of an undefined value

I'm encountering an issue on a website where users can vote for their favorite animal. Whenever I try to select an animal to vote for, I receive an unclear error message that has been difficult to resolve even after searching online for a solution. A ...

Refreshing a webpage is not necessary when using a JQuery form within a div

I need help with some code I have. In my index.html file, there is a div: <div id="logindiv"> <?php require_once('login.php'); ?> </div> This div is utilized with jQuery: <script type="text/javascript"> $(document ...

What is the process for including CSS in the .ashx.cs code-behind file in ASP.NET?

How can I insert a css class in the .ashx file while the .aspx UI page displays it as a string? What is the method to include css in the code behind of the .ashx page? I would like the text "Cook" to be displayed in red. Problem: https://i.sstatic.net ...

Using jQuery's AJAX function to redirect upon successful completion to a specific URL stored

After making an ajax call successfully, I want the current page the user is on to refresh. However, despite trying multiple approaches, nothing seems to be working. There are no errors or network activity showing in the Chrome debug. get[1] = "module=tick ...

React JS makes it simple to create user-friendly cards that are optimized

I have a collection of objects that include a name and description. The name is short and consists of only a few characters, while the description can vary in length. I am looking to showcase this data within Cards in my React project, and have tried using ...

What is the best way to fetch a UniqueID using document.getElementById()?

I am looking to utilize the __doPostBack JavaScript function. __doPostBack(obj.UniqueID,''); The challenge I'm facing is that I only have the ClientID of my object - ctl00_cpholder_myObjId document.getElementById("ctl00_cpholder_myOb ...

Loop through each item in order to modify the text within the pop-up using a for loop

Goal Upon clicking a .player, a popup should display with relevant data about that player fetched from players.js Issue: When clicking on a player, the event seems to trigger multiple times instead of just once. This results in retrievi ...

The functionality of the Jquery mobile panel ceases to work properly when navigating between pages within a multi-page

Within a multi-page template setup in a jQuery mobile application, an issue arises after navigating away from the first page using panel navigation. Upon returning to the first page through another form of navigation, the panel appears "hanged." Upon clos ...

Glitchy/Crazy CSS3 Animations

Currently, I am developing a website at . One of the features I have implemented is CSS3 transitions for route changes, but this feature only works in Chrome. Here's how the animation works: I apply the .preanimate class to rotate the phasing out di ...

Preserve present condition following a jQuery click event

I'm facing a challenge where I need to hide a button upon clicking another button, but the problem is that when the page refreshes, the hidden button becomes visible again. My objective is to keep it hidden even after refreshing the page and only reve ...

Unexpected Visual Basic Web Label Formatting

I am facing an issue with the styling of a complex label. The CSS code doesn't always apply as expected. Interestingly, when I ran this code on two different machines, the styles were inconsistent. The code seems messy and disorganized to me, but al ...

How can TypeScript leverage the power of JavaScript libraries?

As a newcomer to TypeScript, I apologize if this question seems simplistic. My goal is to incorporate JavaScript libraries into a .ts file while utilizing node.js for running my program via the console. In my previous experience with JavaScript, I utilize ...

Markdown Custom Parsing

Every week, I create a digest email for my university in a specific format. Currently, I have to manually construct these emails using a cumbersome HTML template. I am considering utilizing Markdown to automate this process by parsing a file that contains ...

Creating a bot that will only respond once when a user sends multiple photos simultaneously

I'm currently working on a Telegram bot using nodejs. I am utilizing the node-telegram-bot-api library and have implemented the on('photo') method to handle when a user sends a photo to my bot. However, I am facing an issue where if a user ...

Identifying a specific field in a dynamically generated React.js component: Best practices

Currently, I am in the process of developing a form with an undetermined number of sensor fields. The front end has been successfully implemented and now my focus is on extracting user information from these dynamically generated component fields. Here is ...