All along, I think a width, and then write a margin:0 auto, it can, but sometimes it will not work.
For example, when I want to set a div with a width of 700, set it in the middle with relative positioning. Any stretch you have is centered.
See the Real Example
<!doctype Html>"Utf-8"><title> Untitled Document </title><script type="Text/javascript"Src="Jquery-2.0.3.js"></script><style>. scroll{height:2000px;}. Main{width: -%;height:550px; background-color: #fe3a08; position:relative;} . Cent{width:700px;color: #fff; font-size:46px; Font-family:"Young Circle"; Position:absolute; Left -%; margin-left:-350px;line-height:500px;top:0px;}</style><script>function Changetop (obj, value) {varOffsetTop = Obj.offset (). Top +value; varScrollTop =$ (window). scrolltop (); Console.log (OFFSETTOP); Console.log (scrolltop); varresult = ScrollTop-OffsetTop; if((OffsetTop <scrolltop)) {Obj.find (". Bg-image"). Stop (true,true). Animate ({"Top": result}, -); } if(OffsetTop +550<scrolltop) {Obj.find (". Bg-image"). Stop (true,true). Animate ({"Top":"0px"}, -); }}$ (function () {$ (window). Scroll (function () {Changetop ($ (". Main"), the); }) })</script>class="Scroll"> <divclass="Main"> <divclass="cent Bg-image">R6 BRANCH OFFICE|Engineering Management</div> </div></div></body>