Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4610802
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:10:57+00:00 2026-05-22T01:10:57+00:00

Could someone please check my code? Thank you Here is the fiddle site if

  • 0

Could someone please check my code? Thank you

Here is the fiddle site if you want to test:
http://jsfiddle.net/66QYr/

I would like to have the first 3 text to appear on the left (vertically)
and then the next 3 text appear on the right (vertically)
then the next 2 text appear on the lower right bottom (vertically)
and the last 2 text appear on the lower left bottom (vertically)

http://i197.photobucket.com/albums/aa253/tintingerri/Test/pic001.png

<html>
<head>
    <title>tintin</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">


        #tintin{
        position: relative;
        top: 211px;
        left: 12px;
        font-size:14pt;
        font-weight:bold;
        font-family: Calibri;
        color:red;
        filter:alpha(opacity=0);
        opacity:0;}


        .image{
        height:350px;
        width: 855px;}


    </style>
    <script type="text/javascript">



        var txt=['text1','text2', 'text3', 'text4', 'text5', 'text6', 'text7', 'text8', 'text9', 'text10'], init=0,i=0,k=0,speed=20,el;



        var loopCount=1000;
        var j=0;
        //var padd = 20; //set this to an approriate increment
        function fade(){
        init==0?i++:i--;
        el.filters?el.style.filter='alpha(opacity='+i+')':el.style.opacity=i/100;
        el.firstChild.nodeValue=txt[k];
        if(i==100)init=1;
        if(i==0) {init=0;k++;j++;
        el.style.paddingLeft=20*k;
        }
        if(k==txt.length)k=0;
        if (j<loopCount) setTimeout('fade()',speed);
        }
        window.onload=function(){
        el=document.getElementById('tintin');
        fade();
        }
        </script>
        </head>
        <body>
            <div id="tintin">&nbsp;</div>

            <div class="image" style="background-image:url('pic007s.jpg')">;



            </div>
        </body>
        </html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T01:10:58+00:00Added an answer on May 22, 2026 at 1:10 am

    There are two problems you’re trying to solve here:

    1. Positioning the text in the appropriate places
    2. Getting them to fade in

    Step One

    The first problem can be solved with some simple CSS. Start out with a container:

    #container {
        position:relative;
        width:150px;
        height:150px;
    }
    
    <div id="container"></div>
    

    The width and height can be anything, but you do have to tell it something. We’re going to be putting our text in this container, but then use position:absolute. This will take them out of the normal document flow, and collapse the container if we have told it an explicit height.

    The next step is the text. You’re going to want four divs, with the text inside as paragraphs:

    <div class="text" id="text1">
        <p>text 1</p>
        <p>text 2</p>
        <p>text 3</p>
    </div>
    

    Do this for each of the four blocks of text that you want to have. Use the same class name on each one, but give each their own, unique ID (text2, text3, etc.).

    Finally, just use (as I said earlier) absolute positioning to place them where you’d like:

    .text { position:absolute; }
    #text1 { top:0;  left:0; }
    #text2 { top:0; right:0; }
    

    …and so on. When you’re done, you should have something that looks like this:

    four absolutely positioned divs

    Step Two

    Fading elements in requires animation. You kind of have a basic animation function, but I suggest you read Robert Penner’s article on tweening and animation. It was written for ActionScript, but the exact same principles apply.

    For now, here’s a good general-purpose JavaScript method that will take an element and fade it in:

    function fadeIn(totalTime, elem, after) {
        var cos = Math.cos,
            PI = Math.PI,
            startTime = +new Date(),
            endTime = startTime + totalTime,
            timer;
    
        elem.style.opacity = 0;
        elem.style.filter = 'alpha(opacity=0)';
    
        timer = setInterval(function () {
            var currentTime = +new Date();
            currentTime = currentTime > endTime ? 1 : (currentTime - startTime) / totalTime;
    
            var distance = (1 - cos(currentTime * PI)) / 2;
            elem.style.opacity = distance;
            elem.style.filter = 'alpha(opacity=' + distance * 100 + ')';
    
            if (currentTime === 1) {
                clearInterval(timer);
                if (after) {
                    after();
                }
            }
        }, 40);
    }
    

    You tell this function how long you want the animation to last (in milliseconds), and you can also give it a function to execute when the fading is done (if you want; it’s not necessary).

    If I understood your question correctly, you want all the texts to start invisible, and then fade in, one at a time, clockwise from the top. We can make them invisible with CSS, but then if the user has JS disabled, the page will appear blank. So you need to first “get” all of the elements (either with some kind of getByClass function or with four different calls to getElementById) and set their opacity to 0.

    So you can make the first group of texts fade in by doing the following:

    var text1 = document.getElementById('text1');
    fadeIn(1000, text1);
    

    The problem is, by doing this, there’s no way to tell when to start the next animation. So we need to make a function, with the help of closures, to help keep track of things (this assumes that you’ve already gotten the elements in JS and made them invisible):

    var tracker = (function () {
        var texts = [text1, text2, text3, text4],
            i = 0;
    
        return function () {
            var text = texts[i];
            if (text) {
                fadeIn(1000, text, tracker);
                i += 1;
            }
        };
    }());
    

    This function cycles through each element and fades it in when the previous one is done. (It’s okay if the code doesn’t make a lot of sense; closures are tricky things.)

    Here is the final result, in JSFiddle. Good luck.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please could someone post an example of how to check if an element exists
Could someone please explain when would I want to use delegation instead of inheritance?
Could someone please point out a site where I can find an algorithm to
Could someone please advice why i have a memory leak in this code? I
Could someone check my code and tell me if I am on the right
Could someone please demystify interfaces for me or point me to some good examples?
Could someone please tell me which objects types can be tested using Regular Expressions
Could someone please explain the best way to connect to an Interbase 7.1 database
Could someone please point me toward a cleaner method to generate a random enum
Could someone please explain? I couldn't find anything on the internet, everything talks about

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.