472,951 Members | 2,030 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,951 software developers and data experts.

CSS parent problem

Hej,

I have a table with 1 row and 2 columns. In both columns are images below each
other. In the right cell are less images, so the height of this cell is
smaller.

Anyway, I want a navigation image at the bottom of both cells. Both cells share
the same CSS class "menubar":

td.menubar
{
background-color: white;
height: 100%;
text-align: center;
vertical-align: top;
}

This works, both cells are expanded to the same height. Now I add several image
to the cells, no problem so far. At the end of each cell I add the navigation
image and give it a CSS class bottom_btn:

..bottom_btn
{
position: absolute;
margin: 5px 0px;
bottom: 0px;
}

I expected that the parent of this image is the <td>, but the image is
positioned absolute to the <table>. Furthermore the image is not horizontal
center aligned anymore.

<table id="content">
<tr>
<td class="menubar">
<img src ...>
<img src ...>
<img src ...>
<img src ...>

<img src="img/links.gif" width="25" height="20" class="bottom_btn" />

</td>

<td class="menubar">
<img src ...>
<img src ...>

<img src="img/links.gif" width="25" height="20" class="bottom_btn" />

</td>
</tr>
</table>

And here another part of the CSS:

#content
{
width: 100%;
}

For the document I'm using XHTML 1.0 Transitional. The document is valid
(w3.org) as well as the CSS (w3.org). I think I have a logical error, does
anybody see it?!

Sebastian
Jul 23 '05 #1
2 6211
Sebastian Stein <se*******@gmx.de> wrote:
I have a table with 1 row and 2 columns. In both columns are images below each
other. In the right cell are less images, so the height of this cell is
smaller.

Anyway, I want a navigation image at the bottom of both cells. Both cells share
the same CSS class "menubar":

td.menubar
{
background-color: white;
height: 100%;
text-align: center;
vertical-align: top;
}

This works, both cells are expanded to the same height. Now I add several image
to the cells, no problem so far. At the end of each cell I add the navigation
image and give it a CSS class bottom_btn:

.bottom_btn
{
position: absolute;
margin: 5px 0px;
bottom: 0px;
}

I expected that the parent of this image is the <td>,
It is, but as you absolutely position it that no longer plays any part
in its presentation. Unless the <td> is also its containing block, and
based on the styles you've given here the <td> is not a containing
block.
but the image is
positioned absolute to the <table>.
Unless the table is a containing block that's not true. What is the
value of the position property of the table?

Most likely the containing block is the initial containing block.
Furthermore the image is not horizontal center aligned anymore.
Nor should it be. You've told the image to be absolutely positioned
but you haven't specifed a value for left or right to it defaults to
left: 0;

In fact with the styles you've given here both images will be
displayed at the same location. So why not get rid of one of them?
For the document I'm using XHTML 1.0 Transitional. The document is valid
(w3.org) as well as the CSS (w3.org). I think I have a logical error, does
anybody see it?!


You've misunderstood how absolute positioning works. See
http://www.w3.org/TR/CSS21/visuren.h...te-positioning and in
particular http://www.w3.org/TR/CSS21/visudet.html#x0

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>
Jul 23 '05 #2
Steve Pugh <st***@pugh.net> wrote:
.bottom_btn
{
position: absolute;
margin: 5px 0px;
bottom: 0px;
}

I expected that the parent of this image is the <td>,


It is, but as you absolutely position it that no longer plays any part
in its presentation. Unless the <td> is also its containing block, and
based on the styles you've given here the <td> is not a containing
block.


Ok, I see now, absolute only means absolutely to the last containing block. I
thought the parent is always the last containing block. As I see it now I only
have one possibility: Make the table cell also a containing block. If I
understood it correctly, it only becomes a containing block, if it is
positioned absolutely. But this is, of course, not what I want. So I'm looking
for another easy solution. Maybe I have to rethink the whole design. Maybe you
know a better solution for my initial design problem.
For the document I'm using XHTML 1.0 Transitional. The document is valid
(w3.org) as well as the CSS (w3.org). I think I have a logical error, does
anybody see it?!


You've misunderstood how absolute positioning works. See
http://www.w3.org/TR/CSS21/visuren.h...te-positioning and in
particular http://www.w3.org/TR/CSS21/visudet.html#x0


I think I just have not understood it yet, I just started to look into CSS two
days ago.

Sebastian
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: jalkadir | last post by:
Let's say that I have this class: class Parent{ private: char* str; public: const char* getStr(){return str;} }; And then I create a child class class Child{ private: std::string str;...
2
by: dannielum | last post by:
Hi all, I am trying to write a Binary Search Tree that each of its node will have 3 node pointers: left, right and parent. I need a parent pointer for some the purpose of my project. Without the...
25
by: Steve Jorgensen | last post by:
Yup, Steve's full of tips, but hey, it makes him feel important, right? Ok, here goes. I've been trying to improve encapsulation by putting code in the same object as the stuff it affects, so I...
2
by: Raj | last post by:
Hi All, I have a problem with trying to refresh the parent window from child window in order to update data in the parent window. The sequence of events are 1) I click a button in the parent...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
3
by: Eddie | last post by:
If FormMain = MDI parent, FormSub = Child parent, I execute FormSub from the menu like this way. FormSub^ sub = gcnew FormSub; sub->MdiParent = this; sub->Show(); This can generate child...
4
by: Richard Lewis Haggard | last post by:
What is the mechanism by which a child window can notify its parent that it has been clicked on? -- Richard Lewis Haggard www.Haggard-And-Associates.com
2
by: Steven | last post by:
I have a page(pg1) which contains a select list (list1) in a form(form1) and an iframe(frame1), in this iframe is a page(pg2) with another select list(list2) in a form(form2) and I transfer the...
3
by: Darin | last post by:
I have a problem I just can't figure out. I have a form with a subform, and the recordsource of the subform has criteria based on some unbound fields in the parent form so that data in the parent...
4
by: Harlequin | last post by:
I have a question concerning the need to trigger events within a "child" subform which is itself enbedded within a master "parent" form and which is accessible via a tab in the parent form. Becuase...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.