View Full Version : Place object X pixels from center
07-25-2012, 06:36 PM
I have a fixed object that I'd like to place just outside of my centered layout. I know I can use Left and Right position but with variable screen sizes, this leads to inconsistency. Is there a position command that starts at 50% horizontal (center) and then can be set a certain amount of pixels outside of it?
Maybe I'm making this too complicated, but I was thinking about a Div within a Div -- the first Div is Right: 50%, the second Div is XXX pixels so that it hovers just outside the layout.
07-25-2012, 07:11 PM
Typically this is done with a negative left margin:
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<div style="width:500px;margin:0 auto;border:1px green solid">
<p>centered: sh dflksj hflskjh fsldkjh fslkjf hslkjf hslkjfh slkjfh sldkjf lskf lsjf</p>
<div style="width:200px;margin:0 auto;margin-left:-200px;border:1px red solid">
<p>inside kla dkj lkjh asdlfkjd shlfkjh sldkjfh sldkjf</p>
07-25-2012, 07:53 PM
07-26-2012, 05:14 AM
The margin trick worked. Thanks!
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.