/    Sign up×
Community /Pin to ProfileBookmark

layout issues

I’m trying to create a page with a number of different-sized boxes that take up a given size.

IE The whole page is 790×600 or whatever, and inside that I’m going to have a bunch of different sized pieces that make up that size, similar to a puzzle. Each box has a 1px border and a margin of 5px around it to space them out.

The problem is that I’m trying to figure out how to “lock” those boxes to a certain size.

Basically, how do I set the boxes to be 50% 50% of the available space, but not go over that, etc. If I set them to 50/50 etc, they will not be put next to each other, because one is wrapped down to the next line?(margin,padding,etc. gets in the way with the calculations.)

I need to be able to lock them into certain sizes, say 200px,600px, or 50%,200px… That can’t go over that size no matter what is put into them, but also should never be smaller than that.

Thanks for the help. I could easily do this in tables but CSS killing me…

Here’s the html page…

[code]<div id=”box”>

<div id=”user_content” style=”width:775px;”></div>

<div id=”user_content” style=”display:inline;width:50%;”></div>
<div id=”user_content” style=”display:inline;width:45%;”></div>

</div>[/code]

and here’s the CSS

[code]div#user_content {
border:1px solid #000000;
margin:5px;
padding:5px;
background-color:#ffffff;
}
div#box {
background-color: #FEAB22;
padding-top:5px;
border-right:1px solid #000000;
border-left:1px solid #000000;
border-bottom:1px solid #000000;
}[/code]

to post a comment
CSS

3 Comments(s)

Copy linkTweet thisAlerts:
@BonRougeJan 01.2006 — [url=http://bonrouge.com/br.php?page=div-table]See if this helps[/url].
Copy linkTweet thisAlerts:
@afmookauthorJan 03.2006 — This sort of helped... but what I was hoping for is a way to define sizes *without* stating "This is exactly <this> wide." etc on each one. Similar to how a table can be set to 100% width, etc.

If I have one div by itself, it will take the full width : good.

But if I have one that's 100px, and another that I want to take up the REST of the space, I have to manually set it : bad. Why can't I do this? If I set it to 100% it tries to take 100% of the parent div/etc, and of course formatting then fails.

You'd figure CSS (being an upgrade) to the way formatting is done would allow this with ease... is there something I just don't see?
Copy linkTweet thisAlerts:
@ray326Jan 03.2006 — It's done all the time. Check out some of the design sites like

http://www.glish.com/css/

http://www.positioniseverything.net/
×

Success!

Help @afmook spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...