How do I (HTML/CSS)......

Status
Not open for further replies.

Plasdom

Ars Tribunus Angusticlavius
6,704
Create a page layout that looks like this
code:<HR>
Code:
.....................
.                   .
.                .......
.                .     .
.                .     .
.                .     .
.                .     .
.                .......
.                   .
.                   .
.                   .
.....................

I would prefer that the smaller table be independent of the larger one since it would have varying amounts of content at different times that may cause it to expand (downwards)
 

StanGable

Ars Legatus Legionis
18,817
Did you try just monkeying around with tables- like having the areas that are above and below the right side of your 'embedded' table just be td's with nothing in them (and no border, of course)? I am able to mimic what you describe pretty easily by just making the main table 3x3, then having the right middle td span two columns. Or are you trying to move the embedded table around?
 

Greg Hines

Ars Tribunus Militum
1,686
Subscriptor++
This is untested, but it should come close to the desired effect. At the very least, this ought to give you an idea of how to approach it:

code:<HR>
Code:
BODY {
	margin: 0;
}

#bigBox {
	margin: 20px 100px;
}

#littleBox {
	float: right;
	margin-right: 100px;
	margin-top: 100px;
	width: 200px;
}
code:<HR>
Code:
<div id="bigBox">
	<p>Content</p>
</div>
<div id="littleBox">
	<p>Content</p>
</div>
In the CSS for the #bigBox <div>, I gave it right and left margins of 100px. For the #littleBox <div>, I used a margin-right of 100px. This makes it so the right-hand side of the bigBox is lined up with the center of littleBox. You can use whatever values you want, but make sure that the right margin of littleBox is as large as the right margin of bigBox minus 1/2 the width of littleBox. Get it?
 

Plasdom

Ars Tribunus Angusticlavius
6,704
Thanks for the replies guys.

Malus:
The little box falls below the larger box when I implemented yourscript. So
code:<HR>
Code:
 margin-top: 100px;
is actually the margin space between big box and little box.

rodbac:
Can you post the code you used. The embedded table only needs to be able to take more content and still maintain that position. i.e. be able to expand vertically. The bigger box would also sometimes have varying content. The width of the whole layout would be fixed. but there should be the flexibility of being able to expand vertically.

EDIT: upon reading your post again, I infer that what you are saying is that the whole table layout should be something like
code:<HR>
Code:
...........................
.                    .    .
.              ............
.              .          .
.              .          .
.              .          .
.              .          .
.              .          .
.              ............
.                   .     .
...........................
?
 

HitScan

Ars Tribunus Militum
2,523
Subscriptor++
Just don't even think of doing this with tables. You will not be happy with the results, or the time spent on achieving said results. CSS can do it, it's just that I don't personally know enough to tell you how. :D I can tell you if you used tables and ever had to go back and modify any of it, you'd be left a sack of tears, sobbing into the night. Ick. :)

HitScan
 

Greg Hines

Ars Tribunus Militum
1,686
Subscriptor++
<aside>
<rant>
Ugh... there's a proportional font in the Reply text box. How hideous! And HTML posts don't seem to be working too well right now. Sigh.
</rant>
</aside>

Originally posted by Plasdom:
_Malus_:
The little box falls below the larger box when I implemented yourscript. So
<BLOCKQUOTE class="ip_ubbcode_code">code:<HR>
Code:
 margin-top: 100px;
is actually the margin space between big box and little box.<HR></BLOCKQUOTE>
You're right that it should do that, but not for the reason you think. the <code>margin-top: 100px;</code> doesn't have anything to do with it. I forgot to add a little snippit to the bigBox CSS. Add this and you should be set: <code>float: left;</code>

That really should work. I promise. If not, I may actually have to load it up in my browser and try it out. (I should have done this in the first place, but I'm very lazy.)

Originally posted by Plasdom:
I am toying around with absolute positioning right now. Anyone know of any issues with it?
Yeah... it won't work in Netscape 4.x reliably.
 

Greg Hines

Ars Tribunus Militum
1,686
Subscriptor++
I need to put more thought into these things before replying. My approach to it was all wrong. Floating elements is just fine until they run into each other. Then they'll fall one above the other on the y-axis rather than sharing the same area. For this, you need absolute positioning, but just a touch.

Here's what's in my CSS file:
code:<HR>
Code:
BODY {
	margin: 12px;
}

#bigBox {
	border: 1px solid #000;
	height: 200px; /* take out before use */
	margin: 0 100px;
	padding-right: 100px;
}

#littleBox {
	position: absolute;
	top: 100px;
	right: 14px;

	background-color: red;
	border: 1px solid #000;
	width: 200px;
}

and here's what's in my XHTML file:

code:<HR>
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
	<head>
		<title>Test</title>
		<meta http-equiv="Content-type" content="text/html; charset='UTF-8'" />
		<style type="text/css">
			@import "global.css";
		</style>
	</head>
	<body>

<div id="bigBox">
	<p>Content</p>
</div>

<div id="littleBox">
	<p>Content</p>
</div>

	</body>
</html>

You'll notice the line in the CSS file with the comment "take out before use." That height declaration is there solely to show you what it looks like without a bunch of content in there. I used a bunch of filler text before but I wasn't going to post it all here. So I just added that height property to show you the outline of the bigBox extending below the littleBox rather than ending above it (load this stuff up, then take that line out and you'll see what I mean).

Here's what I did and why I did it:

I made the littleBox absolutely positioned. It's 100px from the top of the page (this is an arbitrary value) and 14px from the right-hand side of the page. This is because the body margin is also 12px (an arbitrary value) and the <div>'s border of 2px total (if you remove the border or use a different border width, you'll need to change the right:14px value to accommodate).

I gave the bigBox a left/right margin of 100px. That's half the width of the littleBox. This is so that half of the littleBox will appear in the bigBox and half will appear outside it.

I gave the bigBox a padding-right of 100px. That's to account for the space taken up by the littleBox. Because I used absolute positioning on the littleBox, it overlaps the content in the bigBox. You can either do this or use a float:right workaround with some empty <div> element so that your content will wrap around the box. But such a workaround would be a lot of trouble, it wouldn't have the complete desired effect, and having the positioned box be taller than your workaround box would cause problems. So I recommend the padding because it's easy and it works.



There may be other things you want explained. Feel free to ask and I'll answer to the best of my ability. Also, I only tested this in IE6. I'm not on my Web-dev box so I can't tell you how it works in other browsers.
 

Greg Hines

Ars Tribunus Militum
1,686
Subscriptor++
Originally posted by Plasdom:
Now which to use?! "Decisions Decisions" ;)
Well, they're pretty much identical in how they work so by choosing one you're essentially choosing both. If you take out his nested <div> and use absolute positioning instead of relative, you have mine. So just use whichever you prefer (nested or sibling <div>s). Neither one is really better than the other. (So flip a coin if you wish. ;))
 
Status
Not open for further replies.