Connecting Tech Pros Worldwide Forums | Help | Site Map

Remove element from flow of other sibling elements

Jezternz's Avatar
Familiar Sight
 
Join Date: Jan 2008
Location: New Zealand
Posts: 128
#1: Jul 10 '09
Ok, I want to remove an element from the standard flow, so its location is not affected or determined by other sibling elements, the only catch is, I dont want to position it using top/left/right/bottom, I want to use a margin.
So I need to remove an element from the flow of the page. As far as I know position: fixed & absolute, make the margin property useless, so are there any other ways?

Thanks, Josh

drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,577
#2: Jul 10 '09

re: Remove element from flow of other sibling elements


Margin properties do not go away at all when using absolute or fixed.
Jezternz's Avatar
Familiar Sight
 
Join Date: Jan 2008
Location: New Zealand
Posts: 128
#3: Jul 11 '09

re: Remove element from flow of other sibling elements


ahh ok, maybe a better description would be "Margin: auto" doesnt work.
Basicly im trying to horizontally align (As far as I know vertical alignment is not possible with css?) a div above all other objects on the page.

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html>
  3. <head>
  4.     <style type="text/css">
  5.         *{margin: 0;padding:0;}
  6.         html, body {height: 100%;overflow: auto;margin:0;}
  7.         #center_me{margin:0 auto;width:200px;background:black;color:white;height:300px;position:fixed;}
  8.     </style>
  9.     <title>Test page</title>
  10. </head>
  11. <body>
  12.     <h1>adsada</h1>
  13.     <div id="center_me">Center me please</div>
  14.     </body>
  15. </html>
Weirdly enough in the above, static & relative center it, however they take into account the h1 :(, absolute and fixed dont center it at all.
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,662
#4: Jul 11 '09

re: Remove element from flow of other sibling elements


Quote:

Originally Posted by Jezternz View Post

(As far as I know vertical alignment is not possible with css?)

sure you can align vertically, only it works for less cases (table cells, that is) than horizontal alignment.
Reply