css - Offset div from center -
i'm trying position div x amount of pixels right of center of page. div therefore relative center.
so far, i've tried stupid like
margin:0 auto; margin-left:20px;
but don't need test in browser know wouldn't work.
thanks in advance help.
i'd try using 2 divs, 1 inside another. this:
<div class="outer"> <div class="inner">hello, world!</div> </div> .outer { width: 1px; /* or zero, or small */ margin: auto; overflow: visible; background: red; /* color debug */ } .inner { margin-left: 20px; background: yellow; /* color debug */ width: 100px; /* depending on desired effect, width might needed */ }
see this example live @ jsfiddle.
the outer div
horizontally centered per question/answer: how horizontally center <div> in <div>?
then, inner diff moved 20 pixels right, using margin.
note that, if leave width
auto
, width zero, , might not want.
Comments
Post a Comment