homepage Welcome to WebmasterWorld Guest from 54.234.147.84
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Home / Forums Index / Code, Content, and Presentation / CSS
Forum Library, Charter, Moderator: open

CSS Forum

    
Block level elements on same line
jessejump




msg:3995396
 2:50 am on Sep 25, 2009 (gmt 0)

Hi
Are all block elements that are side by side - next to each other or on same line - or columns- floated or is there another way to do this? I use the web developer toolbar Outline block elements and there are many block level elements on same line on many web sites.
Thanks

 

D_Blackwell




msg:3995407
 3:58 am on Sep 25, 2009 (gmt 0)

The practicality depends upon what is happening with the entire page. Other options - yes. Better or equal choices - maybe. One possible option follows. Three columns, defined widths, position: absolute:, very fluid.....

A row of inline-block: would be another possible option, but you would have to keep an especially close eye on IE.

<!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" lang="en">
<head>
<title></title>
<meta http-equiv="content-style-type" content="text/css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<style type="text/css" media="screen">
html, body {
margin: 0; padding: 0; font-size: 100%;
}

#center-wrapper {
position: relative;
}

#first, #second, #third {
width: 30%;
border: .1em solid #000;
}

#first {
position: absolute; top: 0; left: 0;
}

#second {
position: absolute; top: 0; left: 50%; margin-left: -15%;
}

#third {
position: absolute; top: 0; right: 0;
}

</style>
</head>
<body>
<div id="center-wrapper">
<div id="first">
FIRST BLOCK
<br />
FIRST BLOCK
<br />
FIRST BLOCK
<br />
FIRST BLOCK
<br />
</div>
<div id="second">
SECOND BLOCK
<br />
SECOND BLOCK
<br />
SECOND BLOCK
<br />
SECOND BLOCK
<br />
</div>
<div id="third">
THRID BLOCK
<br />
THRID BLOCK
<br />
THRID BLOCK
<br />
THRID BLOCK
<br />
</div>
</div>
<!--##########

-->
</body>
</html>


swa66




msg:3995485
 8:14 am on Sep 25, 2009 (gmt 0)

Are all block elements that are side by side - next to each other or on same line - or columns- floated or is there another way to do this?

There are probably half a dozen ways to get blocks next to one another:

- floats, although I often feel it's a bit over-used.
- absolute positioning: you can put them *anywhere*, hence also next to one another
- relative positioning: you can nudge elements to move to where you want them
- inline-blocks: they are blocks but they are also inline elements
- display: table-* : makes your elements act as if they are elements in a table.
- CSS3 multiple columns
- ... (did I miss any)?

Which is best will depend a lot on what's in them and around them.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / CSS
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved