Results 1 to 4 of 4

Thread: Text selection - change color - how to?

  1. #1
    Join Date
    Aug 2007
    Location
    MO USA
    Posts
    106
    Thanks
    37
    Thanked 0 Times in 0 Posts

    Default Text selection - change color - how to?

    I recently saw a css website where if you select the text, the selection just changes color instead of the blue highlight which normal websites do. I was wondering how to achieve this? Any help would be greatly appreciated

  2. #2
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    Here's how to achieve what you want, only works in Firefox / Safari (I think, not 100%)

    put this in your CSS:

    Code:
    ::selection {
    	background: #FF99CC;
    	}
    ::-moz-selection {
    	background: #FF99CC; 
    }
    So let's say you have a class called "content", it would look like this:

    Code:
    .content::selection{
    background: #FF99CC;
    }
    .content::-moz-selection{ /* For Firefox */
    background: #FF99CC;
    }
    Good luck with it

  3. The Following 2 Users Say Thank You to Schmoopy For This Useful Post:

    me_myself (11-13-2008),Snookerman (11-13-2008)

  4. #3
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    Quote Originally Posted by Schmoopy View Post
    only works in Firefox / Safari (I think, not 100%)
    Works in FF3 and Opera 9.6 but not in IE6 or IE7. Safari I don't know. Does anyone know how to make it work in IE?
    Edit: OP, what browser did you view that website in? Do you have the link to the site?
    Last edited by Snookerman; 11-17-2008 at 11:11 PM.
    Eddy Proca
    I love Dropbox. Get it through my girlfriend's referral link (I reached my limit) and both you and her get 500 MB extra! Thanks and you're welcome!

  5. #4
    Join Date
    Sep 2004
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Bump'n the thread after doing a search. I found this fascinating and have it coded on my site now. Fairly useless other than a customizing point.

    http://arctic.ithium.net/

Tags for this Thread

Bookmarks

Posting Permissions

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