I am wondering if it is possible to use only HTML and CSS (without any Javascript) to achieve the following:
|--div1-----------------|
| |--div2------||
| | ||
||--div3-|| ||
|| ||____________||
|| | |
|| | |
||_______| |
|_______________________|
- div1 contains div2 and div3.
- div2 is all the way on the top and to the right of diff3
- div3 is all the way on the left and its top starts halfway (or some other configurable percentage) down the height of div2.
- The sizes of div2 and div3 are not known. I am not asking for the obvious solution of hardcoding this using absolute positions. The solution I'm looking for must work for divs of arbitrary sizes.
More generally: Is there is a way to specify the position of an element by referring to the position and size of another element, without using Javascript?
EDIT: The goal of the example above is that div1 automatically expands to fit div2 and div3 after they have been positioned as required, thus the size of div1 is also not known in advance.
EDIT2: To put the question differently: Is there some way of specifying a style similarly to this "magic" CSS:
#div2 { ... }
#div3 {
position absolute;
top: div2.height/2;
}
perhaps using calc()
?
EDIT3: div2 and div3 cannot be nested inside each other.