473,395 Members | 1,537 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

CSS positioning problem

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
Jul 20 '05 #1
3 2598
Joni a écrit :
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.
Sorry if I haven't quite grasped the question, but why did you have to
nest them in the first place?
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?


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

Jul 20 '05 #2
Does it ever make sense to nest DIVs?

--
######################
## PH, London ##
######################
Jonathan Melhuish wrote:
Joni a écrit :
> 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.


Sorry if I haven't quite grasped the question, but why did you have to
nest them in the first place?
> 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?


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

Jul 20 '05 #3
Philip Herlihy wrote:
Does it ever make sense to nest DIVs?


<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.)

Jul 20 '05 #4

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

Similar topics

3
by: Mike Anderson | last post by:
I'm having a problem with the positioning of a div block in IE6. http://www.uah.edu/Athletics/index.shtml When the window is resized to a width smaller than the width of the "body" div (that...
0
by: Asad | last post by:
I have a problem with my site design. I have a table that is centred and it has links on it. Now when you roll mouse over these links I want sublinks to drop down which are in a hidden div. The...
2
by: Tim Charles | last post by:
Hello I am close to finishing my first properly css-friendly site (at least I hope it is), and am looking for some general feedback, plus a specific question answered, if possible. ...
4
by: CJM | last post by:
I'm developing a web application, that has a left-sided navigation menu and a centre-right content area. The menu is static and therefore is in an INCLUDEd file. I'm wanting to add a link to a...
1
by: Ren | last post by:
Hi All, I've created a Crystal Report using Visual Studio.NET 2003 that I'm trying to display in an HTML table in a webpage (i.e. I've placed the report viewer control within a table cell). The...
3
by: Axel Siebenwirth | last post by:
Hi, I would really love to get some help from you since I am starting to become completely desperate with something quite simple... I am trying to transfer a fixed-positioning-implementation...
4
by: gstick | last post by:
Using relative positioning I have not been able to get Firefox to respond to the following: <div style="position: relative; top: 10%; left: 5%; border: 2px green solid;"> It works in IE. I...
2
by: TheCruelPanda | last post by:
Hey there. My name is Rowan, and it's been three weeks since I last used tables for an HTML design. Okay, I'm rather new to CSS and I have a big positioning problem here. It might not be a...
4
by: Randell_D | last post by:
Folks, I've put my page online here at www.fiprojects.com / wip / (Note: I purposely separated the entire address to avoid spiders having a sniff and... *And* before you ask why I am doing...
6
by: sooshi | last post by:
Hi all, The height of my page needs to be flexible as the page contains columns with lists which can vary in length. I also have a footer which needs to be stuck to the bottom. I managed to do...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.