GetDotted Domains

Viewing Thread:
"Inheriting CSS properties"

The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.

Tue 21/01/03 at 17:42
Regular
Posts: 787
Currently on my Web Site, I have a few
's to represent boxes for each link. Each box has the same properties, bar the top: px; one.

Therefor, I have one,
called a set number of times, with it calling the properties from the Style Sheet file and just add the top: px; to the actual
in the page, eg:

#Link-Box {
position: absolute;
left: 10px;
width: 140px;
height: 22px;
padding-top: 2px;
padding-left: 4px;
border-style: solid;
border-width: 3px;
border-color: #FF00FF;
background-color: transparent;
color: blue;
overflow: hidden;
}






Now, it appears I am unable to do this, as calling a div with a name already in use isn't correct (so only one can be reffered to as Link-Box). So, I'm going to have to create an id for each box, and style properties for each.

In the style sheet, is there a whay where I can have all the properties for "Link-BoxA", and for the rest, 'Link-BoxB, 'Link-BoxC' etc, have them inherit the propertis from the first definition, to save me writting the came properties again and again and again???

Something along these lines:

#Link-BoxA {
position: absolute;
left: 10px;
top: 100;
width: 140px;
height: 22px;
padding-top: 2px;
padding-left: 4px;
border-style: solid;
border-width: 3px;
border-color: #FF00FF;
background-color: transparent;
color: blue;
overflow: hidden;
}

#Link-BoxB {
inherit #Link-BoxA;
top: 135;
}
#Link-BoxC {
inherit #Link-BoxA;
top: 170;
}
#Link-BoxD {
inherit #Link-BoxA;
top: 205;
}






Thank you for any help on the matter.
Sun 26/01/03 at 22:51
Regular
"l33t cs50r"
Posts: 2,956
cjh wrote:
> Tyla wrote:
> Kill the it's a depricated tag and should never be used.
>
> You mean use

in it's place??

Nope...

works fine

>The problem with that is it seems Explorer and Netscape have different attitudes towards the positioning properties. Netscape likes to put items lower than Explorer does, even with the same top: px; values. Or is there a simple solution to that as well?

NN treats the as a block element, IE treats it as an inline element. To get around this, in your css just go for:

span(display:inline;)

This stop NN treating it as a block element (like a

) though NN6 I think displays it inline anyway..

The positioning probem is with the difference in "Box Model". NN and IE use different rules for their box outlines in padding, height, margin etc... have a look at:

http://www.tantek.com/CSS/Examples/boxmodelhack.html
http://www.w3.org/TR/REC-CSS2/box.html
http://www.alistapart.com/stories/journey/4.html

Once you understand the "box model" and the browser differences, it's a sinch...

Sun 26/01/03 at 22:37
Regular
"It goes so quickly"
Posts: 4,083
Tyla wrote:
> Kill the
You mean use

in it's place?? The problem with that is it seems Explorer and Netscape have different attitudes towards the positioning properties. Netscape likes to put items lower than Explorer does, even with the same top: px; values. Or is there a simple solution to that as well?

Sun 26/01/03 at 22:34
Regular
"l33t cs50r"
Posts: 2,956
cjh wrote:
> Just to ask though, on your test.php page, when you click the links,
> was it intended that in Explorer that they go dark, but in Netscape
> they stay normal??

IE/NN bug... they're null links so IE/NN handle the out come differently


> http://www.chrisjhaig.co.uk/SR_Sample/
> ... think I'm moving in the right direction with this CSS stuff?

Kill the it's a depricated tag and should never be used.
Sun 26/01/03 at 22:29
Regular
"It goes so quickly"
Posts: 4,083
That makes perfect sense, as that's the sort of thing I had :).

Still, it through the text links at the top of the page. But, I'll give it another go, chances are I probably miss typed part of it which it didn't like.

Just to ask though, on your test.php page, when you click the links, was it intended that in Explorer that they go dark, but in Netscape they stay normal??


And if you get bored, take a quick look at this. Just wanted to have a go and re-doing a site in CSS rather than TABLES, (just not one of my own) so borrowed this page ... (didn't do the search bit yet though)

http://www.chrisjhaig.co.uk/SR_Sample/

... think I'm moving in the right direction with this CSS stuff?
Sun 26/01/03 at 22:20
Regular
"l33t cs50r"
Posts: 2,956
cjh wrote:
> The problem I came across though using that method was the actual text
> links wouldn't position correctly.
>
> The boxes were fine, but the text links which should have gone inside
> them just placed themselves at the top of the page. As if they had
> just been wrote into the HTML document one after the other, and the
> background colour (white) would span the whole page when the relevent
> link was clicked.
>
> I couldn't see why this was occuring, so for now have gone back to the
> DIV method, but does the problem I've described above sound familier??
> Would you know why this may have occured???


You have to define the initial container DIV for the relationship to work:






CSS:

.menuitem {
display:block;
width:150px;
height:15px;
border:1px solid #999999;
font-family:Arial, Helvetica, sans-serif;
font-size:11px;
margin:2px;
color:#FFFFFF;
text-decoration:none;
text-align:right;
font-style: normal;
line-height: normal;
font-weight: normal;
padding-right: 5px;
right: 5px;
left: 35px;
position: relative;
}

.menuitem:hover {
background-color:#333333;
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
font-style: normal;
line-height: normal;
font-weight: bold;
color: #FFFFFF;
text-decoration: none;
}

#menu {
width:197px;
height:150px;
position: absolute;
top:5px;
left: 1px;
visibility: inherit;
z-index: 3;
}

The CSS is directly from my site, so will need adjusting for your needs. As long as you always define the inital container DIV you can use the class for the boxes anywhere and they will always be relevant to that container including the correct text formatting.

hope that makes sense?
Sun 26/01/03 at 22:08
Regular
"It goes so quickly"
Posts: 4,083
The problem I came across though using that method was the actual text links wouldn't position correctly.

The boxes were fine, but the text links which should have gone inside them just placed themselves at the top of the page. As if they had just been wrote into the HTML document one after the other, and the background colour (white) would span the whole page when the relevent link was clicked.

I couldn't see why this was occuring, so for now have gone back to the DIV method, but does the problem I've described above sound familier?? Would you know why this may have occured???
Sun 26/01/03 at 21:06
Regular
"l33t cs50r"
Posts: 2,956
cjh wrote:
> Do you mean rather than having a > class="Link-Box" within each
Exactly... Your trying to get to complicated with your positioning when there's more simple ways around things.
Sat 25/01/03 at 12:47
Regular
"It goes so quickly"
Posts: 4,083
Do you mean rather than having a
for each link, to just put a class="Link-Box" within each link???
Fri 24/01/03 at 17:21
Regular
"l33t cs50r"
Posts: 2,956
You got it all wrong...

Firstly, you can only use "id" once when calling it, to use the same style more than once you have to use it as a "class". SO instead of having id=1, id=2 etc etc, you just repeat the class="xx" instead. Repetative id's will work, but won't validate a correct CSS.

Secondly, you don't define a "display". You have either "inline" or "block" if you use block, it will automatically treat it as a new line "display:block;"

Have a look at the box menu on: http://www.tyla.org.uk/test.php

The menu box in called .menuitem in the css file.

You should only need to define the menu box once.

This should reduce your code, and make life much easier.
Thu 23/01/03 at 17:41
Regular
"It goes so quickly"
Posts: 4,083
Personally I feel anyone who trys using such a feature to view Web Pages deserves to see it looking cack :).

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

Many thanks!!
Registered my website with Freeola Sites on Tuesday. Now have full and comprehensive Google coverage for my site. Great stuff!!
John Shepherd
Simple, yet effective...
This is perfect, so simple yet effective, couldnt believe that I could build a web site, have alrealdy recommended you to friends. Brilliant.
Con

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.