Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: CSS Help.

  1. #1
    Join Date
    Dec 2008
    Posts
    3,744
    Tokens
    2,116
    Habbo
    iBlueBox

    Latest Awards:

    Default CSS Help.

    Really new to HTML and CSS and all this basically,I have a header on my website, but I want each letter to be a specific colour I say such as green and blue, how would I do this on CSS?




  2. #2
    Join Date
    Feb 2013
    Posts
    2,534
    Tokens
    13,046

    Latest Awards:

    Default

    You might want to take a look here: http://www.w3schools.com/css/default.asp

    Are you talking about them alternating like this:

    Merry Christmas

    or like the words like this:

    Merry Christmas

    I know you could just have 2 classes and then have each letter in it's own class if it is the first one or each word if the second but that might be a bit messy, probably a better way to do it.

  3. #3
    Join Date
    Dec 2008
    Posts
    3,744
    Tokens
    2,116
    Habbo
    iBlueBox

    Latest Awards:

    Default

    Quote Originally Posted by Calum0812 View Post
    You might want to take a look here: http://www.w3schools.com/css/default.asp

    Are you talking about them alternating like this:

    Merry Christmas

    or like the words like this:

    Merry Christmas

    I know you could just have 2 classes and then have each letter in it's own class if it is the first one or each word if the second but that might be a bit messy, probably a better way to do it.
    Like the first one,




  4. #4
    Join Date
    Feb 2013
    Posts
    2,534
    Tokens
    13,046

    Latest Awards:

    Default

    Quote Originally Posted by iBlueBox View Post
    Like the first one,
    If I was doing it I'd setup 2 css classes then have them alternating with the classes so M would be in class_red, E in class_green etc but I'm SURE there HAS TO BE a better way to do it.

  5. #5
    Join Date
    Jun 2009
    Location
    Newcastle Upon Tyne, UK
    Posts
    2,652
    Tokens
    1,389
    Habbo
    lRhyss

    Latest Awards:

    Default

    HTML Code:
    <span class="red">Letter</span> <span class="green">Letter</span>
    The use CSS to style the classes

    or...

    HTML Code:
    <span style="color: Red">Letter</span> <span style="color: Green">Letter</span>
    The second method requires no css, but it's a more tacky way in my opinion.
    Last edited by lRhyss; 20-12-2013 at 05:45 PM.

  6. #6
    Join Date
    Nov 2008
    Posts
    217
    Tokens
    1,822
    Habbo
    eLv

    Latest Awards:

    Default

    Or you can do something like this. http://jsfiddle.net/sJTTG/

    HTML Code:
    <div class="text">
        <span>H</span>
        <span>E</span>
        <span>L</span>
        <span>L</span>
        <span>O</span>
    </div>
    HTML Code:
    .text span {
        color: blue;
    }
    .text span:nth-child(odd) {
        color: red;
    }






  7. #7
    Join Date
    Feb 2013
    Posts
    2,534
    Tokens
    13,046

    Latest Awards:

    Default

    How does Habbox do it for the VIP colours and such? @xxMATTGxx; @Skynus; @Recursion;

  8. #8
    Join Date
    Mar 2010
    Location
    Cornwall (UK)
    Posts
    2,329
    Tokens
    6,755
    Habbo
    -Nick

    Latest Awards:

    Default

    Yeh i like the habbox codes but i dunno what they are :/

  9. #9
    Join Date
    Nov 2008
    Posts
    217
    Tokens
    1,822
    Habbo
    eLv

    Latest Awards:

    Default

    They're probably using javascript.

    HTML Code:
        function alternate(colorpair) {
            if(colorpair.indexOf('|') == -1) return;
            var el = document.getElementById('alternator');
            colorpair = colorpair.split('|');
            var letters = el.innerHTML.replace(/^\s*|\s*$/g,''). /*strip leading/trailing spaces*/
                          replace(/<[^>]*>/g,''). /*strip existing html tags */
                          split(''), 
                output = '';
            for (var w = 0, l = letters.length; w < l; w++) {
                output += '<span style="color:' + ((w % 2) ? colorpair[0] : colorpair[1]) + ';">' + letters[w] + '</span>';
            }
            el.innerHTML = output;
        }
    http://jsfiddle.net/xpZqs/
    http://stackoverflow.com/questions/1...ing-javascript

    This is very cool too: http://rainbowcoding.com/how-to-crea...ss-javascript/






  10. #10
    Join Date
    Jul 2004
    Location
    UK
    Posts
    23,590
    Tokens
    33,601
    Habbo
    xxMATTGxx

    Latest Awards:

    Default

    Quote Originally Posted by Calum0812 View Post
    How does Habbox do it for the VIP colours and such? @xxMATTGxx; @Skynus; @Recursion;
    That would be telling


    Previous Habbox Roles
    Co-Owner of Habbox | General Manager | Assistant General Manager (Staff) | Forum Manager | Super Moderator | Forum Moderator

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •