Irish SEO,  Marketing & Webmaster Discussion

 
Chitika Malls

Inheritance + CSS

This is a discussion on Inheritance + CSS within the HTML Basics forums, part of the Coding Help category; I'm learning about Inheritance in CSS and have found out that the all tags take the properties (well not all) ...


Go Back   Irish SEO, Marketing & Webmaster Discussion > Webmaster Help > Coding Help > HTML Basics

Register Forum Rules FAQDonate Members List Calendar Search Today's Posts Mark Forums Read


Notices

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 19-01-2007, 12:08 AM
Coder
 
Join Date: Dec 2006
Posts: 44
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
fobby will become famous soon enough
Default Inheritance + CSS

I'm learning about Inheritance in CSS and have found out that the all tags take the properties (well not all) of the tag they are inside.


I realized my problem when I tried to add a border to a div tag that was nested in another div tag. It was pointless because it just took the value of the outside div tag ? So how do I change the values of a nested div tag independently of the outer tag ?

thanks ..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 19-01-2007, 10:24 AM
louie's Avatar
Senior Member
 
Join Date: Jan 2006
Location: Dublin, Ireland
Posts: 2,007
Nominated 5 Times in 3 Posts
TOTW/F/M Award(s): 0
louie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud of
Send a message via Yahoo to louie Send a message via Skype™ to louie
Default

did you try giving the nested div a class?

Code:
<style type="text/css">
.main{border:1px solid #cccccc; width:500px; padding:5px;}
.sec{border:1px dashed #000000;}
</style>
 
<div class="main"> main div
 <div class="sec">
 nested div
 </div>
</div>
__________________
:. Web Design & Development Web Design Ireland
:. Search Engines Optimization Search Engines Optimization
:. Directory Submission Directory Submission
:. News & Press Release Ireland GiveItSocks.com
:. Used Cars Ireland, Car Parts & Car Audio Cars For Sale, Car Parts & Accessories
:. I Have 2 Find It Directory SEF Directory
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 19-01-2007, 12:21 PM
Coder
 
Join Date: Dec 2006
Posts: 44
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
fobby will become famous soon enough
Default

Yes, thats how I tried it, then linked to an external style sheet. Maybe I should post some code to see clearer, will post tonight, thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 19-01-2007, 02:23 PM
Frontpage User
 
Join Date: Dec 2006
Location: dublin, ireland
Posts: 23
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
uncleseanie will become famous soon enough
Default

Quote:
Originally Posted by louie View Post
did you try giving the nested div a class?

Code:
<style type="text/css">
.main{border:1px solid #cccccc; width:500px; padding:5px;}
.sec{border:1px dashed #000000;}
</style>
 
<div class="main"> main div
 <div class="sec">
 nested div
 </div>
</div>
in the above example "sec" will inherit the width and padding properties.
so if you want to change the width then you will to explicitly state it
in .sec
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 19-01-2007, 04:28 PM
daviddoran's Avatar
Wannabe Geek
Recent Blog: Joost
 
Join Date: Aug 2006
Location: Meath, Ireland
Posts: 342
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
daviddoran will become famous soon enough
Default

I'm not sure what you mean by inherit in this situation.
When displayed, the "sec" box will have a black dashed border and will not have any padding or set width (it stretched to be the size of the parent minus padding). So it has not inherited any of the properties of the parent box.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6 (permalink)  
Old 19-01-2007, 11:50 PM
Coder
 
Join Date: Dec 2006
Posts: 44
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
fobby will become famous soon enough
Default

take a particular example,

I want to put a left margin in the div class "links". I think the code in the .links css is pointless because the links div tag is inside the container div id and therfore will take the css values of the parent tag ? Is this the case, seems to be what is happening.

So then how do I apply values to the nested <div> (class links in this case) ?

edit > ... having more issues with this, using dreamweaver (find it handy for learning the tags before you give out to me ), if I change any font in the div container, every font inside the container changes too ! missing something fundamental here !


<div id="container">

<div class="links">
<p>About</p>
<p>Services</p>
<p>Portfolio</p>
</div>
</div>

#container {
position: absolute;
left: 43px;
top: 29px;
width: 689px;
height: 503px;
background-color: #FFFFFF;

}

.links {
position: absolute;
left: -1px;
top: 113px;
height: 168px;
width: 161px;
background-color: #CCCCCC;
font-size: 24px;
color: #FFFFFF;
border-left-color: #00FF00;
border-left-width: thick;
}

Last edited by fobby; 20-01-2007 at 12:05 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7 (permalink)  
Old 20-01-2007, 01:10 AM
insert-witty-remark-here
 
Join Date: Oct 2006
Location: Dundalk
Posts: 164
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
gary.b will become famous soon enough
Default

Eh? err.. sorry - CSS at 1am doesn't go down well.

I'm not exactly sure what you want.

Just post a gif image of what you want the thing to look like - i'll try to give you the CSS (or at least explain it :P)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8 (permalink)  
Old 20-01-2007, 01:18 AM
daviddoran's Avatar
Wannabe Geek
Recent Blog: Joost
 
Join Date: Aug 2006
Location: Meath, Ireland
Posts: 342
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
daviddoran will become famous soon enough
Default

This will only happen with text because when you set the text color of the parent tag you are setting the style of the text, not the container per-se. (Yes guys, let's ignore whether this is technically correct)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9 (permalink)  
Old 20-01-2007, 10:16 AM
louie's Avatar
Senior Member
 
Join Date: Jan 2006
Location: Dublin, Ireland
Posts: 2,007
Nominated 5 Times in 3 Posts
TOTW/F/M Award(s): 0
louie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud of
Send a message via Yahoo to louie Send a message via Skype™ to louie
Default

Did you try adding margin-left:5px; to the links class?

can you make a draw of what you want to achieve?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10 (permalink)  
Old 20-01-2007, 01:10 PM
Coder
 
Join Date: Dec 2006
Posts: 44
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
fobby will become famous soon enough
Default

Here is a screen shot of what I want to do. I want to put a margin and or border on the left of the inside box (div links). My code is below. From the screen shot it looks like the border is there, but the colour (bright green just to see better) is not.

See the warning message on the left in Dreamweaver also.

"border-left-color does not apply to your selection because it is not inherited . It is applied to an enclosed tag."

I also get a similar message relating to the background of the enclosed tag.

background-colour does not apply to your selection because it is not inherited. It is applied to an enclosing tag. However, page elements are transparent by default, so this colour may show through."



<body>
<div id="container">
<div class="links">
<p>About</p>
<p>Services</p>
<p>Portfolio</p>
</div>
</div>
</body>
</html>


/* CSS Document */

#container {
position: absolute;
left: 43px;
top: 29px;
width: 689px;
height: 503px;
background-color: #FFFFFF;
font-style: normal;
font-family: "Times New Roman", Times, serif;

}


.links {
position: absolute;
left: -1px;
top: 113px;
height: 168px;
width: 161px;
background-color: #CCCCCC;
font-size: 24px;
color: #FFFFFF;
border-left-color: #00FF00;
border-left-width: thick;
margin-left:5px;
}
Attached Images
File Type: jpg dream_snap.jpg (26.5 KB, 7 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
css, inheritance

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads

Thread Thread Starter Forum Replies Last Post
CSS Issue for Wordpress Menu.. Cormac Coding Help 4 03-12-2006 02:12 PM
some simple store with css based layout kuba77 Site Reviews / Announcements 1 30-11-2006 02:07 PM
How to make a H1 tag in CSS into a link shanediffily Coding Help 4 10-10-2006 04:54 PM
dynamic css 7aken Coding Help 6 10-10-2006 08:13 AM


All times are GMT +1. The time now is 12:36 AM.


Powered by: vBulletin Version 3.7.3, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
Hosted in Ireland by Blacknight - Test your ISP |Irish Hosting Directory| Armchair.ie|Logo by Eden Web Design|Avatars by Afterglow |Latest Blog Entries | VPS HostingAd Management by RedTyger

Search Engine Friendly URLs by vBSEO 3.2.0