css - Centering an absolutely positioned div over a bootstrap grid -



css - Centering an absolutely positioned div over a bootstrap grid -

i want center div on top of bootstrap grid , have remain centered responsive layout (regardless of screen size). here bootply of i'm trying do. how can center .ontop div on grid?

oops should have poked around more. found works pretty well:

width: 80%; height: 80%; left: 50%; top: 25%; margin-left: -40%; margin-right: -40%;

you have apply following:

.container .ontop { position: absolute; top: 50%; left: 50%; -webkit-transform: translate(-50%, -50%); -moz-transform: translate(-50%, -50%); transform: translate(-50%, -50%); }

the top/left properties move element 50% of width of parrent element horizontally/vertically. transform: translate() moves element half of width/height.

css twitter-bootstrap-3

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -