By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,723 Members | 1,270 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,723 IT Pros & Developers. It's quick & easy.

Remove element from flow of other sibling elements

Jezternz
100+
P: 145
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
Jul 10 '09 #1
Share this Question
Share on Google+
3 Replies


drhowarddrfine
Expert 5K+
P: 7,435
Margin properties do not go away at all when using absolute or fixed.
Jul 10 '09 #2

Jezternz
100+
P: 145
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.
Jul 11 '09 #3

Dormilich
Expert Mod 5K+
P: 8,639
@Jezternz
sure you can align vertically, only it works for less cases (table cells, that is) than horizontal alignment.
Jul 11 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.