CSS Text styling - fill text using animation with the numbers 1 and 0 - HTML












-3















I am trying to do the following, however not sure if this possible/ how to go about doing it. Is it possible to do this animation in CSS styling.



The below is the HTML - I am trying to generate some animation to fill the following text with the numbers 1 and 0. I have managed to get some javascript going to create an animation for 1,0 but not sure how to fill 'DEVELOPER' with text to make up each letter.






var outputbinary = document.querySelector(".output");

var optionsarray = [0, 1];
var binaryarray = ;


setInterval(function() {

if (binaryarray.length <= 2000) {
var binarynumber = optionsarray[Math.floor(Math.random() * optionsarray.length)];
binaryarray.push(binarynumber);
var str = binaryarray.join(" ");
outputbinary.innerText = str;
}

}, 10);

<div class="output"></div>
<div class="loading">Developer</div>
<div>





I want the the text developer to be displayed like



 111  0000
1 1 0
1 1 000
1 1 0
111 0000 //etc









share|improve this question




















  • 2





    I'm not understanding the question. You want to turn 'Developer' in to what?

    – dwjohnston
    Nov 28 '18 at 22:27











  • I want developer to be animated somehow. I would like each letter to fade into the screen and rather than it have a css styling of a colour e.g grey... I want the numbers 1 and 0 to make each letter rather than a solid colour. Does this make sense?

    – RA19
    Nov 28 '18 at 22:31






  • 1





    I made an edit to your question - is that what you mean? If not - roll it back.

    – dwjohnston
    Nov 28 '18 at 22:41











  • That’s exactly what I mean.. thank you. I am happy for it to alternate 1,0 even on one letter

    – RA19
    Nov 28 '18 at 22:48


















-3















I am trying to do the following, however not sure if this possible/ how to go about doing it. Is it possible to do this animation in CSS styling.



The below is the HTML - I am trying to generate some animation to fill the following text with the numbers 1 and 0. I have managed to get some javascript going to create an animation for 1,0 but not sure how to fill 'DEVELOPER' with text to make up each letter.






var outputbinary = document.querySelector(".output");

var optionsarray = [0, 1];
var binaryarray = ;


setInterval(function() {

if (binaryarray.length <= 2000) {
var binarynumber = optionsarray[Math.floor(Math.random() * optionsarray.length)];
binaryarray.push(binarynumber);
var str = binaryarray.join(" ");
outputbinary.innerText = str;
}

}, 10);

<div class="output"></div>
<div class="loading">Developer</div>
<div>





I want the the text developer to be displayed like



 111  0000
1 1 0
1 1 000
1 1 0
111 0000 //etc









share|improve this question




















  • 2





    I'm not understanding the question. You want to turn 'Developer' in to what?

    – dwjohnston
    Nov 28 '18 at 22:27











  • I want developer to be animated somehow. I would like each letter to fade into the screen and rather than it have a css styling of a colour e.g grey... I want the numbers 1 and 0 to make each letter rather than a solid colour. Does this make sense?

    – RA19
    Nov 28 '18 at 22:31






  • 1





    I made an edit to your question - is that what you mean? If not - roll it back.

    – dwjohnston
    Nov 28 '18 at 22:41











  • That’s exactly what I mean.. thank you. I am happy for it to alternate 1,0 even on one letter

    – RA19
    Nov 28 '18 at 22:48
















-3












-3








-3








I am trying to do the following, however not sure if this possible/ how to go about doing it. Is it possible to do this animation in CSS styling.



The below is the HTML - I am trying to generate some animation to fill the following text with the numbers 1 and 0. I have managed to get some javascript going to create an animation for 1,0 but not sure how to fill 'DEVELOPER' with text to make up each letter.






var outputbinary = document.querySelector(".output");

var optionsarray = [0, 1];
var binaryarray = ;


setInterval(function() {

if (binaryarray.length <= 2000) {
var binarynumber = optionsarray[Math.floor(Math.random() * optionsarray.length)];
binaryarray.push(binarynumber);
var str = binaryarray.join(" ");
outputbinary.innerText = str;
}

}, 10);

<div class="output"></div>
<div class="loading">Developer</div>
<div>





I want the the text developer to be displayed like



 111  0000
1 1 0
1 1 000
1 1 0
111 0000 //etc









share|improve this question
















I am trying to do the following, however not sure if this possible/ how to go about doing it. Is it possible to do this animation in CSS styling.



The below is the HTML - I am trying to generate some animation to fill the following text with the numbers 1 and 0. I have managed to get some javascript going to create an animation for 1,0 but not sure how to fill 'DEVELOPER' with text to make up each letter.






var outputbinary = document.querySelector(".output");

var optionsarray = [0, 1];
var binaryarray = ;


setInterval(function() {

if (binaryarray.length <= 2000) {
var binarynumber = optionsarray[Math.floor(Math.random() * optionsarray.length)];
binaryarray.push(binarynumber);
var str = binaryarray.join(" ");
outputbinary.innerText = str;
}

}, 10);

<div class="output"></div>
<div class="loading">Developer</div>
<div>





I want the the text developer to be displayed like



 111  0000
1 1 0
1 1 000
1 1 0
111 0000 //etc





var outputbinary = document.querySelector(".output");

var optionsarray = [0, 1];
var binaryarray = ;


setInterval(function() {

if (binaryarray.length <= 2000) {
var binarynumber = optionsarray[Math.floor(Math.random() * optionsarray.length)];
binaryarray.push(binarynumber);
var str = binaryarray.join(" ");
outputbinary.innerText = str;
}

}, 10);

<div class="output"></div>
<div class="loading">Developer</div>
<div>





var outputbinary = document.querySelector(".output");

var optionsarray = [0, 1];
var binaryarray = ;


setInterval(function() {

if (binaryarray.length <= 2000) {
var binarynumber = optionsarray[Math.floor(Math.random() * optionsarray.length)];
binaryarray.push(binarynumber);
var str = binaryarray.join(" ");
outputbinary.innerText = str;
}

}, 10);

<div class="output"></div>
<div class="loading">Developer</div>
<div>






javascript html css






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 28 '18 at 22:41









dwjohnston

2,942115094




2,942115094










asked Nov 28 '18 at 22:24









RA19RA19

203112




203112








  • 2





    I'm not understanding the question. You want to turn 'Developer' in to what?

    – dwjohnston
    Nov 28 '18 at 22:27











  • I want developer to be animated somehow. I would like each letter to fade into the screen and rather than it have a css styling of a colour e.g grey... I want the numbers 1 and 0 to make each letter rather than a solid colour. Does this make sense?

    – RA19
    Nov 28 '18 at 22:31






  • 1





    I made an edit to your question - is that what you mean? If not - roll it back.

    – dwjohnston
    Nov 28 '18 at 22:41











  • That’s exactly what I mean.. thank you. I am happy for it to alternate 1,0 even on one letter

    – RA19
    Nov 28 '18 at 22:48
















  • 2





    I'm not understanding the question. You want to turn 'Developer' in to what?

    – dwjohnston
    Nov 28 '18 at 22:27











  • I want developer to be animated somehow. I would like each letter to fade into the screen and rather than it have a css styling of a colour e.g grey... I want the numbers 1 and 0 to make each letter rather than a solid colour. Does this make sense?

    – RA19
    Nov 28 '18 at 22:31






  • 1





    I made an edit to your question - is that what you mean? If not - roll it back.

    – dwjohnston
    Nov 28 '18 at 22:41











  • That’s exactly what I mean.. thank you. I am happy for it to alternate 1,0 even on one letter

    – RA19
    Nov 28 '18 at 22:48










2




2





I'm not understanding the question. You want to turn 'Developer' in to what?

– dwjohnston
Nov 28 '18 at 22:27





I'm not understanding the question. You want to turn 'Developer' in to what?

– dwjohnston
Nov 28 '18 at 22:27













I want developer to be animated somehow. I would like each letter to fade into the screen and rather than it have a css styling of a colour e.g grey... I want the numbers 1 and 0 to make each letter rather than a solid colour. Does this make sense?

– RA19
Nov 28 '18 at 22:31





I want developer to be animated somehow. I would like each letter to fade into the screen and rather than it have a css styling of a colour e.g grey... I want the numbers 1 and 0 to make each letter rather than a solid colour. Does this make sense?

– RA19
Nov 28 '18 at 22:31




1




1





I made an edit to your question - is that what you mean? If not - roll it back.

– dwjohnston
Nov 28 '18 at 22:41





I made an edit to your question - is that what you mean? If not - roll it back.

– dwjohnston
Nov 28 '18 at 22:41













That’s exactly what I mean.. thank you. I am happy for it to alternate 1,0 even on one letter

– RA19
Nov 28 '18 at 22:48







That’s exactly what I mean.. thank you. I am happy for it to alternate 1,0 even on one letter

– RA19
Nov 28 '18 at 22:48














1 Answer
1






active

oldest

votes


















2














This example builds letters from a series of zeros and ones, adds them to the page, and fades them in.



It displays them in a list. Each list item has a container that displays the sub-units using CSS grid.






const mapping = {
D: '1111010001100011000111110',
E: '1111110000111101000011111',
V: '1000110001100010101000100',
O: '0111010001100011000101110',
L: '1000010000100001000011111',
P: '1111010001111101000010000',
R: '1111010001111101000110001'
};

// Grab the binary mapping of the letter and
// return some HTML
function binaryise(letter) {
const arr = mapping[letter].split('');
return arr.map(char => `<div class="${char === '0' ? 'zero' : 'one'}">${char}</div>`).join('');
}

// For each letter in the word create a
// binary version and return it in a list-item container
function processWord(arr) {
const items = arr.map((letter, i) => {
const binaryised = binaryise(letter);
return `
<li data-id=${i}>
<div class="container">${binaryised}</div>
</li>
`;
}).join('');
return `<url>${items}</ul>`;
}

// Get a random number that hasn't previously appeared
function getRandom(arr, memo) {
const index = Math.floor(Math.random() * arr.length);
return memo.includes(index) ? getRandom(arr, memo) : index;
}

// Once the html has been added to the page
// (all set with opacity to 0)
// iterate over the letters turning the
// opacity of each to 1
function showLetters(arr, memo) {
memo = memo || ;
if (memo.length !== arr.length) {
const index = getRandom(arr, memo);
const letter = arr[index];
const el = document.querySelector(`[data-id="${index}"]`);
setTimeout(() => {
el.classList.add('show');
memo.push(index);
showLetters(arr, memo);
}, 1000);
}
}

var wordArr = 'Developer'.toUpperCase().split('');

// Process all the letters of the word and add them
// to the page...
const html = processWord(wordArr);
output.insertAdjacentHTML('beforeend', html);

// ...then fade them in
showLetters(wordArr);

ul {
width: 100%;
display: flex;
flex-direction: row;
list-style-type: none;
}

li {
display: inline-block;
margin-right: 1em;
opacity: 0;
}

.container {
width: 30px;
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
}

.show {
opacity: 1;
transition: opacity 4s linear;
}

.zero {
opacity: 0.2;
}

<div id="output"></div>








share|improve this answer


























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53529011%2fcss-text-styling-fill-text-using-animation-with-the-numbers-1-and-0-html%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    This example builds letters from a series of zeros and ones, adds them to the page, and fades them in.



    It displays them in a list. Each list item has a container that displays the sub-units using CSS grid.






    const mapping = {
    D: '1111010001100011000111110',
    E: '1111110000111101000011111',
    V: '1000110001100010101000100',
    O: '0111010001100011000101110',
    L: '1000010000100001000011111',
    P: '1111010001111101000010000',
    R: '1111010001111101000110001'
    };

    // Grab the binary mapping of the letter and
    // return some HTML
    function binaryise(letter) {
    const arr = mapping[letter].split('');
    return arr.map(char => `<div class="${char === '0' ? 'zero' : 'one'}">${char}</div>`).join('');
    }

    // For each letter in the word create a
    // binary version and return it in a list-item container
    function processWord(arr) {
    const items = arr.map((letter, i) => {
    const binaryised = binaryise(letter);
    return `
    <li data-id=${i}>
    <div class="container">${binaryised}</div>
    </li>
    `;
    }).join('');
    return `<url>${items}</ul>`;
    }

    // Get a random number that hasn't previously appeared
    function getRandom(arr, memo) {
    const index = Math.floor(Math.random() * arr.length);
    return memo.includes(index) ? getRandom(arr, memo) : index;
    }

    // Once the html has been added to the page
    // (all set with opacity to 0)
    // iterate over the letters turning the
    // opacity of each to 1
    function showLetters(arr, memo) {
    memo = memo || ;
    if (memo.length !== arr.length) {
    const index = getRandom(arr, memo);
    const letter = arr[index];
    const el = document.querySelector(`[data-id="${index}"]`);
    setTimeout(() => {
    el.classList.add('show');
    memo.push(index);
    showLetters(arr, memo);
    }, 1000);
    }
    }

    var wordArr = 'Developer'.toUpperCase().split('');

    // Process all the letters of the word and add them
    // to the page...
    const html = processWord(wordArr);
    output.insertAdjacentHTML('beforeend', html);

    // ...then fade them in
    showLetters(wordArr);

    ul {
    width: 100%;
    display: flex;
    flex-direction: row;
    list-style-type: none;
    }

    li {
    display: inline-block;
    margin-right: 1em;
    opacity: 0;
    }

    .container {
    width: 30px;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
    }

    .show {
    opacity: 1;
    transition: opacity 4s linear;
    }

    .zero {
    opacity: 0.2;
    }

    <div id="output"></div>








    share|improve this answer






























      2














      This example builds letters from a series of zeros and ones, adds them to the page, and fades them in.



      It displays them in a list. Each list item has a container that displays the sub-units using CSS grid.






      const mapping = {
      D: '1111010001100011000111110',
      E: '1111110000111101000011111',
      V: '1000110001100010101000100',
      O: '0111010001100011000101110',
      L: '1000010000100001000011111',
      P: '1111010001111101000010000',
      R: '1111010001111101000110001'
      };

      // Grab the binary mapping of the letter and
      // return some HTML
      function binaryise(letter) {
      const arr = mapping[letter].split('');
      return arr.map(char => `<div class="${char === '0' ? 'zero' : 'one'}">${char}</div>`).join('');
      }

      // For each letter in the word create a
      // binary version and return it in a list-item container
      function processWord(arr) {
      const items = arr.map((letter, i) => {
      const binaryised = binaryise(letter);
      return `
      <li data-id=${i}>
      <div class="container">${binaryised}</div>
      </li>
      `;
      }).join('');
      return `<url>${items}</ul>`;
      }

      // Get a random number that hasn't previously appeared
      function getRandom(arr, memo) {
      const index = Math.floor(Math.random() * arr.length);
      return memo.includes(index) ? getRandom(arr, memo) : index;
      }

      // Once the html has been added to the page
      // (all set with opacity to 0)
      // iterate over the letters turning the
      // opacity of each to 1
      function showLetters(arr, memo) {
      memo = memo || ;
      if (memo.length !== arr.length) {
      const index = getRandom(arr, memo);
      const letter = arr[index];
      const el = document.querySelector(`[data-id="${index}"]`);
      setTimeout(() => {
      el.classList.add('show');
      memo.push(index);
      showLetters(arr, memo);
      }, 1000);
      }
      }

      var wordArr = 'Developer'.toUpperCase().split('');

      // Process all the letters of the word and add them
      // to the page...
      const html = processWord(wordArr);
      output.insertAdjacentHTML('beforeend', html);

      // ...then fade them in
      showLetters(wordArr);

      ul {
      width: 100%;
      display: flex;
      flex-direction: row;
      list-style-type: none;
      }

      li {
      display: inline-block;
      margin-right: 1em;
      opacity: 0;
      }

      .container {
      width: 30px;
      display: grid;
      grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
      }

      .show {
      opacity: 1;
      transition: opacity 4s linear;
      }

      .zero {
      opacity: 0.2;
      }

      <div id="output"></div>








      share|improve this answer




























        2












        2








        2







        This example builds letters from a series of zeros and ones, adds them to the page, and fades them in.



        It displays them in a list. Each list item has a container that displays the sub-units using CSS grid.






        const mapping = {
        D: '1111010001100011000111110',
        E: '1111110000111101000011111',
        V: '1000110001100010101000100',
        O: '0111010001100011000101110',
        L: '1000010000100001000011111',
        P: '1111010001111101000010000',
        R: '1111010001111101000110001'
        };

        // Grab the binary mapping of the letter and
        // return some HTML
        function binaryise(letter) {
        const arr = mapping[letter].split('');
        return arr.map(char => `<div class="${char === '0' ? 'zero' : 'one'}">${char}</div>`).join('');
        }

        // For each letter in the word create a
        // binary version and return it in a list-item container
        function processWord(arr) {
        const items = arr.map((letter, i) => {
        const binaryised = binaryise(letter);
        return `
        <li data-id=${i}>
        <div class="container">${binaryised}</div>
        </li>
        `;
        }).join('');
        return `<url>${items}</ul>`;
        }

        // Get a random number that hasn't previously appeared
        function getRandom(arr, memo) {
        const index = Math.floor(Math.random() * arr.length);
        return memo.includes(index) ? getRandom(arr, memo) : index;
        }

        // Once the html has been added to the page
        // (all set with opacity to 0)
        // iterate over the letters turning the
        // opacity of each to 1
        function showLetters(arr, memo) {
        memo = memo || ;
        if (memo.length !== arr.length) {
        const index = getRandom(arr, memo);
        const letter = arr[index];
        const el = document.querySelector(`[data-id="${index}"]`);
        setTimeout(() => {
        el.classList.add('show');
        memo.push(index);
        showLetters(arr, memo);
        }, 1000);
        }
        }

        var wordArr = 'Developer'.toUpperCase().split('');

        // Process all the letters of the word and add them
        // to the page...
        const html = processWord(wordArr);
        output.insertAdjacentHTML('beforeend', html);

        // ...then fade them in
        showLetters(wordArr);

        ul {
        width: 100%;
        display: flex;
        flex-direction: row;
        list-style-type: none;
        }

        li {
        display: inline-block;
        margin-right: 1em;
        opacity: 0;
        }

        .container {
        width: 30px;
        display: grid;
        grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
        }

        .show {
        opacity: 1;
        transition: opacity 4s linear;
        }

        .zero {
        opacity: 0.2;
        }

        <div id="output"></div>








        share|improve this answer















        This example builds letters from a series of zeros and ones, adds them to the page, and fades them in.



        It displays them in a list. Each list item has a container that displays the sub-units using CSS grid.






        const mapping = {
        D: '1111010001100011000111110',
        E: '1111110000111101000011111',
        V: '1000110001100010101000100',
        O: '0111010001100011000101110',
        L: '1000010000100001000011111',
        P: '1111010001111101000010000',
        R: '1111010001111101000110001'
        };

        // Grab the binary mapping of the letter and
        // return some HTML
        function binaryise(letter) {
        const arr = mapping[letter].split('');
        return arr.map(char => `<div class="${char === '0' ? 'zero' : 'one'}">${char}</div>`).join('');
        }

        // For each letter in the word create a
        // binary version and return it in a list-item container
        function processWord(arr) {
        const items = arr.map((letter, i) => {
        const binaryised = binaryise(letter);
        return `
        <li data-id=${i}>
        <div class="container">${binaryised}</div>
        </li>
        `;
        }).join('');
        return `<url>${items}</ul>`;
        }

        // Get a random number that hasn't previously appeared
        function getRandom(arr, memo) {
        const index = Math.floor(Math.random() * arr.length);
        return memo.includes(index) ? getRandom(arr, memo) : index;
        }

        // Once the html has been added to the page
        // (all set with opacity to 0)
        // iterate over the letters turning the
        // opacity of each to 1
        function showLetters(arr, memo) {
        memo = memo || ;
        if (memo.length !== arr.length) {
        const index = getRandom(arr, memo);
        const letter = arr[index];
        const el = document.querySelector(`[data-id="${index}"]`);
        setTimeout(() => {
        el.classList.add('show');
        memo.push(index);
        showLetters(arr, memo);
        }, 1000);
        }
        }

        var wordArr = 'Developer'.toUpperCase().split('');

        // Process all the letters of the word and add them
        // to the page...
        const html = processWord(wordArr);
        output.insertAdjacentHTML('beforeend', html);

        // ...then fade them in
        showLetters(wordArr);

        ul {
        width: 100%;
        display: flex;
        flex-direction: row;
        list-style-type: none;
        }

        li {
        display: inline-block;
        margin-right: 1em;
        opacity: 0;
        }

        .container {
        width: 30px;
        display: grid;
        grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
        }

        .show {
        opacity: 1;
        transition: opacity 4s linear;
        }

        .zero {
        opacity: 0.2;
        }

        <div id="output"></div>








        const mapping = {
        D: '1111010001100011000111110',
        E: '1111110000111101000011111',
        V: '1000110001100010101000100',
        O: '0111010001100011000101110',
        L: '1000010000100001000011111',
        P: '1111010001111101000010000',
        R: '1111010001111101000110001'
        };

        // Grab the binary mapping of the letter and
        // return some HTML
        function binaryise(letter) {
        const arr = mapping[letter].split('');
        return arr.map(char => `<div class="${char === '0' ? 'zero' : 'one'}">${char}</div>`).join('');
        }

        // For each letter in the word create a
        // binary version and return it in a list-item container
        function processWord(arr) {
        const items = arr.map((letter, i) => {
        const binaryised = binaryise(letter);
        return `
        <li data-id=${i}>
        <div class="container">${binaryised}</div>
        </li>
        `;
        }).join('');
        return `<url>${items}</ul>`;
        }

        // Get a random number that hasn't previously appeared
        function getRandom(arr, memo) {
        const index = Math.floor(Math.random() * arr.length);
        return memo.includes(index) ? getRandom(arr, memo) : index;
        }

        // Once the html has been added to the page
        // (all set with opacity to 0)
        // iterate over the letters turning the
        // opacity of each to 1
        function showLetters(arr, memo) {
        memo = memo || ;
        if (memo.length !== arr.length) {
        const index = getRandom(arr, memo);
        const letter = arr[index];
        const el = document.querySelector(`[data-id="${index}"]`);
        setTimeout(() => {
        el.classList.add('show');
        memo.push(index);
        showLetters(arr, memo);
        }, 1000);
        }
        }

        var wordArr = 'Developer'.toUpperCase().split('');

        // Process all the letters of the word and add them
        // to the page...
        const html = processWord(wordArr);
        output.insertAdjacentHTML('beforeend', html);

        // ...then fade them in
        showLetters(wordArr);

        ul {
        width: 100%;
        display: flex;
        flex-direction: row;
        list-style-type: none;
        }

        li {
        display: inline-block;
        margin-right: 1em;
        opacity: 0;
        }

        .container {
        width: 30px;
        display: grid;
        grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
        }

        .show {
        opacity: 1;
        transition: opacity 4s linear;
        }

        .zero {
        opacity: 0.2;
        }

        <div id="output"></div>





        const mapping = {
        D: '1111010001100011000111110',
        E: '1111110000111101000011111',
        V: '1000110001100010101000100',
        O: '0111010001100011000101110',
        L: '1000010000100001000011111',
        P: '1111010001111101000010000',
        R: '1111010001111101000110001'
        };

        // Grab the binary mapping of the letter and
        // return some HTML
        function binaryise(letter) {
        const arr = mapping[letter].split('');
        return arr.map(char => `<div class="${char === '0' ? 'zero' : 'one'}">${char}</div>`).join('');
        }

        // For each letter in the word create a
        // binary version and return it in a list-item container
        function processWord(arr) {
        const items = arr.map((letter, i) => {
        const binaryised = binaryise(letter);
        return `
        <li data-id=${i}>
        <div class="container">${binaryised}</div>
        </li>
        `;
        }).join('');
        return `<url>${items}</ul>`;
        }

        // Get a random number that hasn't previously appeared
        function getRandom(arr, memo) {
        const index = Math.floor(Math.random() * arr.length);
        return memo.includes(index) ? getRandom(arr, memo) : index;
        }

        // Once the html has been added to the page
        // (all set with opacity to 0)
        // iterate over the letters turning the
        // opacity of each to 1
        function showLetters(arr, memo) {
        memo = memo || ;
        if (memo.length !== arr.length) {
        const index = getRandom(arr, memo);
        const letter = arr[index];
        const el = document.querySelector(`[data-id="${index}"]`);
        setTimeout(() => {
        el.classList.add('show');
        memo.push(index);
        showLetters(arr, memo);
        }, 1000);
        }
        }

        var wordArr = 'Developer'.toUpperCase().split('');

        // Process all the letters of the word and add them
        // to the page...
        const html = processWord(wordArr);
        output.insertAdjacentHTML('beforeend', html);

        // ...then fade them in
        showLetters(wordArr);

        ul {
        width: 100%;
        display: flex;
        flex-direction: row;
        list-style-type: none;
        }

        li {
        display: inline-block;
        margin-right: 1em;
        opacity: 0;
        }

        .container {
        width: 30px;
        display: grid;
        grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
        }

        .show {
        opacity: 1;
        transition: opacity 4s linear;
        }

        .zero {
        opacity: 0.2;
        }

        <div id="output"></div>






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 29 '18 at 1:02

























        answered Nov 28 '18 at 23:09









        AndyAndy

        30.3k73564




        30.3k73564
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53529011%2fcss-text-styling-fill-text-using-animation-with-the-numbers-1-and-0-html%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Futebolista

            Jornalista

            F# list compare