Help - Search - Members - Calendar
Full Version: CSS Style and sub-class
Invision Power Services > Community Forums > Community Web Design and Coding
d6rth7ader
Hi I have a #stylelike in a web page

#bottom{
{ font:Arial, Helvetica, sans-serif;
font-size:12px;
color:#CC3333;
font-weight:bold
}

Now

Html is like this

<div id="bottom">
<p> Bottom Line 1 </p>
<p> Bottom Line2 </p>
</div>


I have to add a different font for bottom Line 2. how can I do that without changing the <div id="bottom">

Can I add a sub-class in the #bottom id style.

Please help with sample code..
Reply With Quote
RobertMidd
QUOTE(d6rth7ader @ Aug 7 2006, 03:58 AM) *
Hi I have a #stylelike in a web page

#bottom{
{ font:Arial, Helvetica, sans-serif;
font-size:12px;
color:#CC3333;
font-weight:bold
}

Now

Html is like this

<div id="bottom">
<p> Bottom Line 1 </p>
<p> Bottom Line2 </p>
</div>


I have to add a different font for bottom Line 2. how can I do that without changing the <div id="bottom">

Can I add a sub-class in the #bottom id style.

Please help with sample code..
Reply With Quote




It can be done in a number of ways and here is my example.



CODE
<style>
.bottom{
{ font-family:Arial, Helvetica, sans-serif;
font-size:12px;
color:#CC3333;
font-weight:bold;
}
.bottom P#line2{
font-family:Courier;
{

</style>
<div class="bottom">
<p> Bottom Line 1 </p>
<p id='line2'> Bottom Line2 </p>
</div>
_
Here's another one.
CODE
#bottom *:last-child {
    color: #f00;
}


It basically modifies any element that is the last child of #bottom, which would therefore not require changing any of the (X)HTML, however you'd find it not working in browsers like Internet Explorer 6.
=Charles
How about:

CODE
#bottom p+p {
    font-family: Arial, Helvetica, sans-serif;
}
Bøb
QUOTE(d6rth7ader @ Aug 7 2006, 03:58 AM) *
Hi I have a #stylelike in a web page

#bottom{
{ font:Arial, Helvetica, sans-serif;
font-size:12px;
color:#CC3333;
font-weight:bold
}

Now

Html is like this

<div id="bottom">
<p> Bottom Line 1 </p>
<p> Bottom Line2 </p>
</div>
I have to add a different font for bottom Line 2. how can I do that without changing the <div id="bottom">

Can I add a sub-class in the #bottom id style.

Please help with sample code..
Reply With Quote



and remember to remove your double opening of { in the first css style tongue.gif
Antony
QUOTE(Aka Tolken @ Aug 7 2006, 07:27 PM) *
How about:

CODE
#bottom p+p {
    font-family: Arial, Helvetica, sans-serif;
}


Will that work in IE?
=Charles
Unfortunately not. sad.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.