Connecting Tech Pros Worldwide Forums | Help | Site Map

CSS positioning problem

Joni
Guest
 
Posts: n/a
#1: Jul 20 '05
Hello NG,

I am quite new to CSS and currently trying to change our sites to better use
CSS for easier site style/layout configuration.

I am having some problems and I couldn't find any good help Googling the
net. So I was hoping someone would be able to help me here.

The problem is very simple. The feature I'm trying to replicate is a very
basic table layout.

----------------------------------------------------------------------------
--
<html>
<table align="center" border="0" width="600">
<tr><td colspan="2" align="center" valign="top">top</td></tr>
<tr><td width="400" align="left" valign="top">left</td><td width="200"
align="left" valign="top">right</td></tr>
<tr><td colspan="2" align="center" valign="top">bottom</td></tr>
</table>
</html>
----------------------------------------------------------------------------
--

This case is a fixed width table centered to the page with one centered
column at top, two fixed width columns at the center and one centered column
at the bottom. Quite simple.

I was able to replicate this with the following CSS / HTML.

----------------------------------------------------------------------------
--
style.css:
#header {
position:relative;
width:600px;
left:50%;
margin-left:-300px;
text-align:center;
}

#midleft {
position:relative;
width:600px;
left:50%;
margin-left:-300px;
}

#midright {
float:right;
width:200px;
}

#footer {
position:relative;
width:600px;
left:50%;
margin-left:-300px;
text-align:center;
}

index.html:
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>

<div id="header">
top
</div>

<div id="midleft">
<div id="midright">
right
</div>
left
</div>

<div id="footer">
bottom
</div>

</body>
</html>
----------------------------------------------------------------------------
--

This is a working configuration, but I would like to be able to take the
"midright" DIV out of the "midleft" DIV so I could change the whole layout
with just the CSS.

I would like people to be able to select which layout they want and I would
not have to change to HTML file at all. So I could change top->bottom or
left->right etc. Using this CSS the "midright" is always INSIDE the
"midleft" area.

Or am I complete off track thinking that having the DIVs on the same level
the positioning would be easier?

Best Regards,
Joni



Jonathan Melhuish
Guest
 
Posts: n/a
#2: Jul 20 '05

re: CSS positioning problem


Joni a écrit :[color=blue]
> This is a working configuration, but I would like to be able to take the
> "midright" DIV out of the "midleft" DIV so I could change the whole[/color]
layout[color=blue]
> with just the CSS.[/color]

Sorry if I haven't quite grasped the question, but why did you have to
nest them in the first place?
[color=blue]
> I would like people to be able to select which layout they want and I[/color]
would[color=blue]
> not have to change to HTML file at all. So I could change top->bottom or
> left->right etc. Using this CSS the "midright" is always INSIDE the
> "midleft" area.
>
> Or am I complete off track thinking that having the DIVs on the same[/color]
level[color=blue]
> the positioning would be easier?[/color]

Well, yes, you'd be able to position them independently of each other,
whereas at the moment any changes you make to "midleft" will impact
"midright".

Jon

Philip Herlihy
Guest
 
Posts: n/a
#3: Jul 20 '05

re: CSS positioning problem


Does it ever make sense to nest DIVs?

--
######################
## PH, London ##
######################


Jonathan Melhuish wrote:[color=blue]
> Joni a écrit :[color=green]
> > This is a working configuration, but I would like to be able to[/color]
> take the > "midright" DIV out of the "midleft" DIV so I could change
> the whole layout[color=green]
> > with just the CSS.[/color]
>
> Sorry if I haven't quite grasped the question, but why did you have to
> nest them in the first place?
>[color=green]
> > I would like people to be able to select which layout they want[/color]
> and I would[color=green]
> > not have to change to HTML file at all. So I could change[/color]
> top->bottom or > left->right etc. Using this CSS the "midright" is
> always INSIDE the > "midleft" area.[color=green]
> >
> > Or am I complete off track thinking that having the DIVs on the[/color]
> same level[color=green]
> > the positioning would be easier?[/color]
>
> Well, yes, you'd be able to position them independently of each other,
> whereas at the moment any changes you make to "midleft" will impact
> "midright".
>
> Jon[/color]


Johannes Koch
Guest
 
Posts: n/a
#4: Jul 20 '05

re: CSS positioning problem


Philip Herlihy wrote:[color=blue]
> Does it ever make sense to nest DIVs?[/color]

<div id="content">
<h1>headline</h1>
<div class="imageBlock">
<img src="..." alt="..." ...>
<div class="subline">subline</div>
</div>
<p>text</p>
</div>
<ol id="menu">
<li><a href="foo">foo</a></li>
<li><a href="bar">bar</a></li>
</ol>

But that's an HTML question, so xpost and f'up2 ciwah.
--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)

Closed Thread