![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
Hi I've been trying to position some element's on my page and I can'tcome up with a way to equally position 4 DIV's in another DIV without explicitly setting the width of the "child" DIV's. Here's what the code look's like: div id="Heading" a id="WP">WERSJA POLSKA</a div id="Buttons" div id="Home" class="ButtPart"><img src="Images/Buttons/blank_button.gif" alt="" class="InButtPart" / div id="ab"> HOME </div></div div id="HTML" class="ButtPart" img src="Images/Buttons/blank_button.gif" class="InButtPart" alt=""/></div div id="PP" class="ButtPart" img src="Images/Buttons/blank_button.gif" alt="" class="InButtPart"/></div div id="C#" class="ButtPart" img src="Images/Buttons/blank_button.gif" alt="" class="InButtPart"/></div /div /div and the css file: #WP {font-weight:bold;color:red;text-align:right;float:right;margin-top:0.5%;margin-bottom:2%} .ButtPart {float:left;width:20%;text-align:center;margin-top:0.5%;margin-bottom:2%} #LM {float:left} #Buttons {width:70%} #ab {position:absolute;text-align:center} Right now it work's but I would like to know if there's a way to do it without having to play around with the width. |
|
The second and more inportant problem is how to make the text "HOME" appear exactly in the middle of the first button image. I read about backgrounds, positioning layers but non of this seems to work in this case. |
#3
| |||
| |||
|
|
Only with a table. You can give the whole table a width, put each ButtPart in a cell, and the UA will aim to make the cells equal widths. |
Maybe someone knows a good tutorial
#4
| ||||
| ||||
|
First of all thanks for your answer![]() Only with a table. You can give the whole table a width, put each ButtPart in a cell, and the UA will aim to make the cells equal widths. Hmm... I read in many places that tables should be used only to present tabular data... Why isn't there a CSS way to accomplish such a layout? |
|
As for the image and text problem I tried what you proposed and it works both in IE and Firefox |
|
but now I have the rest of my images stacked underneath the first one. |
|
I must rethink what is going on cause I can't full comprehend this CSS language Maybe someone knows a good tutorial explaining the layoutpossibilities of this language? As for the idea of using the imageas a background I don't know if it will work cause i I want that image to be anchored to a hyperlink and I don't know if you could do it for backgrounds. |
#5
| |||
| |||
|
|
You can't hyperlink the background image itself, but you can hyperlink the box it's in which is just as good. e.g. a { display: block; background-image: url(home.png); width: 100px; height: 100px; } ... a href="http://home"></a |
#6
| |||
| |||
|
|
There is, display: table-cell and friends, they just don't work in IE. |

This is the most helpful answer in weeks
I
As for
Right now I'll stick to an HTML table...|
You can't hyperlink the background image itself, but you can hyperlink the box it's in which is just as good. (...) Sounds like they're ending up slightly too wide for some reason. But you'd need to post a url to a page reproducing the problem. (...) Following up to myself here... but I should point out that there are likely to be some accessibility problems with this for users without CSS enabled. |
#7
| |||
| |||
|
|
Ben C wrote: [snip] You can't hyperlink the background image itself, but you can hyperlink the box it's in which is just as good. (...) Sounds like they're ending up slightly too wide for some reason. But you'd need to post a url to a page reproducing the problem. (...) Following up to myself here... but I should point out that there are likely to be some accessibility problems with this for users without CSS enabled. That's an idea, but your right about that accessibility concern. I want all my webpage content to be visible on as much devices as I can, and much of them (for example cell phones) probably won't have CSS support. |
|
I think I need to find a different way to position that text. From what I read about layers they look good but I don't know what positioning to choose... It would be good to to put the text in a layer and make it behave just like the container was empty. Than I could position it exactly the same way I positioned the image. Is there such positionning in CSS? |
#8
| |||
| |||
|
|
a span { display: none; } a href="home"><span>Home</span></a That way someone with no CSS will just get the text "Home", but people with CSS will get the graphic but not the text. |

#9
| |||
| |||
|
|
You could just put some text in the <a> but make it display: none in the CSS. (...) That way someone with no CSS will just get the text "Home", but people with CSS will get the graphic but not the text. Surely mobile phones will have CSS though? Accessibility is still a good goal though. I'd better not talk you out of that one having already given you an excuse to use tables... |
You haven't talked me out
As for the mobile phones they probably
I still want to have all the data (images,|
What's a "layer"? |
I meant a DIV but in the context that it's positioned "on top"![]() |
| Thread Tools | |
| Display Modes | |
| |