PDA

View Full Version : Resolved CSS help - selection styles...



utnalove
Jul 11th, 2010, 04:17 PM
If I leave
.postcontent::selection{
background:#cc0000;
color:#fff;
}

it is applied to normal text only.

if I put:


.postcontent b i::selection{
background:#cc0000;
color:#fff;
}
it is applied to bold italic text only...

if I put


.postcontent b::selection{
background:#cc0000;
color:#fff;
}

it is applied to bold only...

what should I put if I want it applied to each style (bold, italics, normal)?

karlosio
Jul 11th, 2010, 05:16 PM
.postcontent {
background: #c90;
color: #fff;
}
.postcontent i {
font-size: 2em;
}
.postcontent b {
font-family: Tahoma, geneva, sans-serif;
}



<p class="postcontent">This text is <b>bold</b> and this is <i>italic</i></p>


basic css selectors go like this:
[class/id postcontent][tag/id/class inside the class postcontent] the more specific you are the more important it is (in the cascade)

say you had



.postcontent {
color: red;
}

html body p.postcontent {
color: blue;
}


the second one would get the styles defined (turn the text blue) within the curly braces as its more specific. But if you changed it to this:



.postcontent {
color: red !important;
}

html body p.postcontent {
color: blue;
}


It will turn red as you have marked it as !important, it will not change no matter how specific you are.

utnalove
Jul 11th, 2010, 05:24 PM
My apologies, I didn't get it.

What I want is the text of the posts of my forum to be highlighted in red.
The problem is that if I use


.postcontent::selection{
background:#cc0000;
color:#fff;
}

only normal text is highlighted in red. All the italic and bold text is normally highlighted in blue.

If I want normal text, italic and bold to be highlighted in read I have to do:


.postcontent::selection{
background:#cc0000;
color:#fff;
}

.postcontent b::selection{
background:#cc0000;
color:#fff;
}

.postcontent i::selection{
background:#cc0000;
color:#fff;
}

.postcontent b i::selection{
background:#cc0000;
color:#fff;
}


It works.... however for something little I have to put a lot of code.


I am not a CSS expert... but I think (hope) there is a solution to have the "background" and "color" properties applied to all the texts "postcontent", no matter if they are normal, bold or italic.




Here is an example, where I am trying to put it: Fryzury na Wesele (http://wizazforum.pl/content/wlosy/144-fryzury-na-wesele-udana-fryzura-na-slub-wybierz-co-chcesz.html) As you can see -now- only bold AND italic text is red when selected.

.postcontent b i::selection{
background:#cc0000;
color:#fff;
} is used in this page right now.

utnalove
Jul 11th, 2010, 09:51 PM
Resolved - I decided to use this CSS for all the text of the site, it makes everything easier