Current location: Hot Scripts Forums » General Web Coding » CSS » div properties only within a specific div


div properties only within a specific div

Reply
  #1 (permalink)  
Old 06-24-09, 11:33 AM
macintosh macintosh is offline
Newbie Coder
 
Join Date: Mar 2007
Posts: 84
Thanks: 1
Thanked 0 Times in 0 Posts
div properties only within a specific div

I want to set some local properties of a div. for example, for example the properties of a div "info" only when its inside a div "main" . how this can be done?
thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 06-24-09, 12:15 PM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
This will work if the info div is the first div element in the main div element.
And to get it to work in IE you need to specify a doc type.

Example:
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<style>
#main
{
 width:200px;
 height:200px;
 border:1px solid #f00;
 }
#main > div:first-child
{
 width:100px;
 height:100px;
 border:1px solid #000;
 }
</style>
</head>
<body>
<div id="main">
 <div id="info"></div>
</div>
</body>
</html>
__________________
Jerry Broughton
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 06-24-09, 01:23 PM
macintosh macintosh is offline
Newbie Coder
 
Join Date: Mar 2007
Posts: 84
Thanks: 1
Thanked 0 Times in 0 Posts
thanks for your reply, but i have seen something like
Code:
.main {
width:200px;
height:200px;
border:1px solid #f00;
}

.main info{
 width:100px;
 height:100px;
 border:1px solid #000;
 }
Is it correct, if yes, how can i use this in html.
thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 06-24-09, 03:02 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
HTML Code:
#main .info
{
/* properties */
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 06-24-09, 11:31 PM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
Quote:
Originally Posted by macintosh View Post
thanks for your reply, but i have seen something like
Code:
.main {
width:200px;
height:200px;
border:1px solid #f00;
}

.main info{
 width:100px;
 height:100px;
 border:1px solid #000;
 }
Is it correct, if yes, how can i use this in html.
thanks.
Your kinda right, but I think it will work this way:
HTML Code:
<html>
<head>
<title></title>
<style>
.main
{
 width:200px;
 height:200px;
 border:1px solid #f00;
 }
.main .info
{
 width:100px;
 height:100px;
 border:1px solid #000;
 }
</style>
</head>
<body>
<div class="main">
 <div class="info"></div>
</div>
</body>
</html>
__________________
Jerry Broughton
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
div css theighost CSS 11 09-14-08 03:30 AM
[SOLVED] delay on html element properties? UnrealEd JavaScript 5 05-05-08 04:23 AM
[SOLVED] Change content in a DIV with links in another DIV s1yfa JavaScript 3 05-04-08 05:10 AM
padding error, div within div manuleka CSS 5 06-14-07 11:58 PM
Can't Understand java script maverickminds JavaScript 1 07-16-06 02:23 PM


All times are GMT -5. The time now is 08:21 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.