how to center a form using css?


Tags: javascript,css,centering

Problem :

Literally centering on ALL four sides. I see lots of tutorials just using

element.style.margin = "0 auto";

This only centers it on the X-Axis, but not the Y-axis.

How do I get it to center via Y-Axis as well?



Solution :

I've used:

#myItem {
   position: fixed;
   top: 50%;
   left: 50%;
   width: 100px;
   height: 100px;
   margin-top: -50px;
   margin-left: -50px;
}

.... before, hope it helps


    CSS Howto..

    Using bootstrap, how do you get columns to clear properly?

    (jQuery) How to animate the elements inside a scrollable div when they come into sight on scroll?

    How to set padding-left to my custom textbox in css?

    how to get the site to not collapse with css

    How to get rid of spaces with CSS

    How to make hashtag links work on Internet Explorer?

    HTML/CSS/jQuery: How to set an “absolute text bottom” so that further text expands upwards?

    How to draw rectangle on the website to highlight?

    CSS: How to get an animated gif background-image on top of a div

    How do I center the twitter bootstrap tabs on the page?

    How to change CSS color values in real-time off a javascript slider?

    How to draw half-opened line in CSS? [closed]

    How to merge .CSS files with Sass (or other tool)? [duplicate]

    css: how to target p a img

    How can I apply an external CSS class to a span created with dojo.create?

    How to make this Header/Content/Footer layout using CSS?

    How can I highlight position in nav bar for single-page website?

    How do I use the CSS box-model to make sure my body is spaced from the edge of the window despite being 100% high?

    How to edit the CSS of a selector in Polymer 1.0

    How to reference css and script files into a node.js app?

    How to override active admin CSS?

    how to override font-color dynamically with css color property

    How to center align text over CSS shape?

    How to add only those script and css files necessary to views with partial views [closed]

    How to make a fixed menu/sidebar while using position:relative?

    How to make a paragraph appear in a certain area in the page using Wordpress?

    How to extend the background of a CSS-arrow to the whole page width?

    How to define the width of a HTML element dynamically

    How do I add box shadows when the parent div has a background image?

    How to generate CSS with loop in less