473,771 Members | 2,372 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CSS Layouts - Is there an easier way?

Greetings,

I have been developing websites in CSS for a couple years; I claim to
be no expert, but certain things could definitely be easier.

Consider the box model and it's different implementations :

http://tantek.com/CSS/Examples/boxmodelhack.html

Microsoft's way and the web standards way. Ironically, though
Microsoft implemented the box model incorrectly, I consider it
superior.

One of the biggest issues that comes about when attempting to create
CSS web designs is fitting a bunch of boxes within a containing box
where the width unit specified on inner boxes may vary. I'm sure many
of you have run into this common problem -- some inner boxes are
measured in ems, some in pixels, some in percentages, etc. I'm not
advocating that a designer use inconsistent units of width without
reason; sometimes, however, certain designs do warrant differing
units.

Microsoft's way makes the calculations for fitting boxes across the
entire width of a containing box much easier. Today, using the
correct box model, some designers will nest their <div> tags inside of
an outer containing <div> tag (having no margin, no padding) in order
to mimic Microsoft's way inside the context of a standard's compliant
browser.

This lead me in my thinking to trying to come up with a better way to
solve old problems. I was thinking about a new way of laying out
pages where designers could eliminate the headache of trying to
specify all the right calculations for getting all their boxes fitted
properly together.

Here it is:

The "pushpin" property.

Imagine the following box.
<div id='example'></div>

tl t tr
+----------------------------+
| |
| |
| 'example' |
| div |
l | | r
| |
| |
| |
+----------------------------+
bl b br

Each box has named sides and corners necessary for use with the
pushpin property.

sides: t = top, r = right, b = bottom, l = left
corners: tl = topleft, tr = topright, bl = bottom left, br =
bottomright

Now for the purpose and the implementation of the pushpin...

Take the following 3 boxes contained inside the body.

<body>
...
...
<div id='menu'></div>
<div id='content'></div>
<div id='sidebar'></div>
...
...
</body>

+--------+ +-----------------+ +--------+
| | | | | |
| | | | | |
| | | | | |
| menu | | content | | sidebar|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
+--------+ +-----------------+ +--------+

....and the accompanying CSS:

#menu {
width: 150px;
}
#content {
pushpin: left right menu;
width: auto; /* shrink-to-fit */
}
#sidebar {
pushpin: left right content;
width: 150px;
}

Here's the definition of pushpin:

pushpin {[side or corner name of this element] [side or corner name of
attached element] [attached block element id] ... }

Therefore...

#content {
pushpin: left right menu;
}

.... reads ...

join the "left" side of the the "content" block to the "right" side of
the "menu" block. The shorthand reads...

#content {
pushpin: left right;
}

join the "left" side of the #content block to the "right" side of the
preceding block (regardless of its ID, if any) present in the markup.

So what? Does this solve anything?

Lots of things:

1. Consider that a common fixed-width layout uses a background image
that includes sidebar coloring so that the sidebar will have the
"appearance " of extending all the way down the page.

http://www.alistapart.com/articles/fauxcolumns/

Using a "pushpin" tells the CSS rendering logic to join two
block-level elements entirely along their opposing sides (or corners
if desired). Using a pushpin would allow the actual sidebar to extend
fully down the page (not only by appearance).

In this way, designers wouldn't have to specify special margins or
padding to prevent the actual content from spilling into the area
immediately below the sidebar. Thus markup is greatly reduced. And
the background images assigned to the parts would actually contain
only the images required by each specific element.

2. Consider tables. How difficult is it to mimic complex table
layouts with CSS only and without tables? It can be done, but there
are a host of problems.

Consider...

+-------------------------------------+
| ele1 |
+-------+--------+------------+-------+
| ele2 | ele3 | ele4 | ele5 |
| | | | |
+-------+--------+------------+ |
| ele6 | ele7 | |
| | | |
+-------+---------------------+-------+

Looks like a table right? Designating a purpose for each of the 7
elements is irrelevant. The point is it's a mock layout that somebody
somewhere might use, and as far as tables go, it's nothing that
complex. Tables can be so much more complex than this.

Imagine how difficult it would normally be to lay this out using
tableless methods. Sure it could be done. But let me add a few
restrictions. You must do it using the following markup.

<div id='ele1'></div>
<div id='ele2'></div>
<div id='ele3'></div>
<div id='ele4'></div>
<div id='ele5'></div>
<div id='ele6'></div>
<div id='ele7'></div>

Notice there is nothing more and nothing less that the semantic markup
for the elements required by our hypothetical page. (Isn't that the
goal -- to avoid unnecessary markup?) There is no need for containing
elements to group elements together. Our markup contains nothing but
what is required semantically. (We didn't even need to specify
rowspan or colspan!)

Next restriction. Do it without "absolute" positioning.
Unfortunately, we want to maintain this layout regardless of whether
or not one element stretches to fit its content. Absolute positioning
will most likely create overlaps when this happens.

Here's our CSS:

#ele1 {width: 100%}
#ele2 {pushpin: topleft bottomleft ele1;}
#ele3 {pushpin: topleft topright ele2;}
#ele4 {pushpin: topleft topright ele3;}
#ele5 {pushpin: topleft topright ele4;}
#ele6 {pushpin: top bottom ele2;}
#ele7 {pushpin: topleft bottomleft ele3 left right ele6 topright
bottomright ele4 bottomright bottomleft ele5;}

Notice that "ele7" has multiple pushpins. Think of pushpins as the
metaphor they are. You can add as many as needed to join all the
corners and edges you like.

Notice that width was only specified on the top element (ele1).
Widths could have been specified on certain elements if they had a
desired width (regarless of unit). The remaining widths will be
evenly distributed; however, the pushpins must always perform their
duty. No element may ever accidentally spill over into the region of
some other element.

Futhermore, pushpinned elements could still speficy margins in order
to create visual gaps between the boxes.

One of the best features of the pushpin metaphor is that it is easy to
define layout in a way that is much easier to get our brains to
understand (my brain anyway) than to have to constantly play with
units of measurement. The unit measurements may still be specified on
the blocks whose width must be a certain size, but they may often be
omitted. Consider the three panel layout in the first example --
specifying the width on the content area was completely unnecessary.

I can offer many more examples of the benefits of the pushpin
metaphor, but I'm hoping you can begin to envision them for yourself.
I hesitate to go on and on with examples without first receiving some
feedback. Oftentimes, it's easy to imagine better ways, only to find
that more experienced persons can offer equally valid ways for
accomplishing the same within the context of what already exists.

As I said, for me the concept of telling the browser to join things
together based on common corners and edges seems far superior to
having to calculate widths. The visions I have for page designs
almost always involve a layout that in every respect looks like a
complex table (or many creative newspaper layouts). Yet I know that
for the sake of semantic markup tables are undesirable (they are meant
to markup tabular data!). Futhermore, think about the way that our
content (contained within tables) displays in text-only browsers.
Don't get me wrong, I'll use a table if it makes sense or it makes my
job a lot easier, but I try to avoid them because of my desire to have
good semantic markup.

I haven't worked out all the syntax, just the general concept. What
do you guys think about the "pushpin" metaphor? Am I on to something?
Or am I missing something completely?

Mario T. Lanza
Clarity Information Architecture, Inc.
2004.10
Jul 20 '05 #1
2 1839
Mario T. Lanza wrote:
Consider the box model and it's different implementations :

http://tantek.com/CSS/Examples/boxmodelhack.html

Microsoft's way and the web standards way.
Not quite. On the one hand, the box model for MSIE 5.x/Win, which is
also the model for MSIE 6.0/Win, but for the latter, only when it's in
quirks mode.[1]

On the other hand, the web standards way.
Ironically, though Microsoft implemented the box model incorrectly,
....in certain versions of their browser...
I consider it superior. Microsoft's way makes the calculations for fitting boxes across the
entire width of a containing box much easier. Today, using the
correct box model, some designers will nest their <div> tags inside
of an outer containing <div> tag (having no margin, no padding) in
order to mimic Microsoft's way inside the context of a standard's
compliant browser.
That's what I'd do, since it's a pretty easy solution.

I'd much rather have a solution to the sidebard width: 14em; content
width: 100%-14em, which would make floats more useful. But this isn't
really related to the broken box model.
#menu { width: 150px;


Why are you suggesting px for a text content width? Better rethink your
proposal, and come back when you've thought throught the issues a bit more.
[1] I've never tried to figure out the box model of NN4, IE4, etc.

--
Brian (remove "invalid" to email me)
http://www.tsmchughs.com/
Jul 20 '05 #2
"Mario T. Lanza" <ml****@lycos.c om> wrote in message
news:bd******** *************** **@posting.goog le.com...
Greetings,

I have been developing websites in CSS for a couple years; I claim to
be no expert, but certain things could definitely be easier.

Consider the box model and it's different implementations :

http://tantek.com/CSS/Examples/boxmodelhack.html

Microsoft's way and the web standards way. Ironically, though
Microsoft implemented the box model incorrectly, I consider it
superior.

One of the biggest issues that comes about when attempting to create
CSS web designs is fitting a bunch of boxes within a containing box
where the width unit specified on inner boxes may vary. I'm sure many
of you have run into this common problem -- some inner boxes are
measured in ems, some in pixels, some in percentages, etc. I'm not
advocating that a designer use inconsistent units of width without
reason; sometimes, however, certain designs do warrant differing
units.

Microsoft's way makes the calculations for fitting boxes across the
entire width of a containing box much easier. Today, using the
correct box model, some designers will nest their <div> tags inside of
an outer containing <div> tag (having no margin, no padding) in order
to mimic Microsoft's way inside the context of a standard's compliant
browser.


Maybe the best way to deal with this is not to be so picky about dimensions
of boxes, and to leave the details up to the browser. E.g. not to specify
dimensions in pixels except when a box contains something (like an image)
with dimensions inherently specified in pixels. You won't get identical
results with all browsers, but then you never can anyway.
Jul 20 '05 #3

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

Similar topics

1
1707
by: Dario de Judicibus | last post by:
I wish to create two simple layouts by using only HTML, CSS and the minimum JavaScript as possible. Layouts should be "elastic" (no fixed widths and heights) and cross-browser enabled. The first one is a non-scrollable page which contains a centered title and a centered division with automatic scrolling on overflow, that is: +---------------------+ | TITLE | | +--------------++ |
6
2827
by: Tristan Miller | last post by:
Greetings. Can someone point me to a good source of nice, simple stylesheets, similar to the W3C Core Styles provided at http://www.w3.org/StyleSheets/Core/? I don't need anything fancy like multiple columns; I just want some more elegant combinations of fonts and colours for all the basic HTML elements. The Open Directory Project has a whole category devoted to CSS layouts, but as far as I can tell most of those sites concentrate on...
0
1627
by: John Bradley | last post by:
I've read and understood the w3 specs on css1 and css2. I've done some positioned layouts on my own system that worked as expected. But - I'm concerned about letting anything on to the live system because all I hear are bugs, workarounds and hacks. The last straw was the ie6 peekaboo bug. I don't have ie6 and in a panic had to phone my brother the other side of the country to tell him to browse my simple site and describe what he saw. It...
7
3365
by: Alan J. Flavell | last post by:
A colleague recently breezed in with a new web page design. He didn't tell me where he got the ideas from, but ... Looking at his stylesheets, I noticed they identified themselves as "Ruthsarian Layouts". Google took me to http://webhost.bridgew.edu/etribou/layouts/ We don't seem to have had any discussion here that mentioned them. Anyone care to take a look, and share thoughts?
16
2460
by: Michael Rozdoba | last post by:
I'm far from a CSS expert, but what I see of it I really like & I love keeping content & style separate. I also hate the way table layout produces convoluted bulky code. However when asked why one should use CSS rather than tables, particularly when tables work & browser support of CSS can be dodgy, especially in IE, I usually fail to come up with a concise & convincing argument :/ I've been having this long running discussion with a...
6
3734
by: glakk | last post by:
I got on the tableless layout bandwagon early on, and thought it was a really cool way to lay out a page. I don't know why I thought it was so cool, except I guess I fell for the "oh, cool" talk. I never did really find out why this is a better way to lay out a page, except the slogan "tables are for tabular data...", and well, CSS is the "way to fly". So I converted my basic blog layout to tableless, and it wasn't all that hard,...
5
1795
by: Stan R. | last post by:
Greetings. I have a couple of questions concerning CSS layouts, as apposed to the old <tablemethod for creating layouts . Even after spending the last few days searching all over Google Groups, I haven't not been able to find a solution to my collective dilemma, and I hope some of you fine folks here in these neck of the UseNet woods might be able to share some wisdom with a fellow coder. My questions are in regard to what are the proper...
13
1819
by: Justin.Voelker | last post by:
Hello Everyone: I am in search of an easier way to develop pages. My most current website, www.Base2WebDesign.com, has the exact same layout throughout the entire site. Right now I use a function called "page_top()" and page_bottom()" that , when called, display the tops and bottoms of pages. All I have to do on the actual index.php page is call those two functions and then write the main content on that page. This seems stupid but...
3
1959
by: =?Utf-8?B?Sm9obiBXYWxrZXI=?= | last post by:
Hi, Below is sample output in x12 EDI format. I'm using vb.net to create this output file but i'm not sure if .NET has any tools to make the coding more organized and/or efficient. Right now the only way i can think to create each segment is by hardcoding the different elements into a string. For example, to create the N1 segment i'll do this: Dim sN1 as string = "N1*IM*" & drv("importer_name") & "*" & drv("consignee_code") & "*" &...
0
9619
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10038
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.