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..

    how to clip text in css like gmail does to emails subject listings

    How do I include a css file while creating a wordpress theme?

    How to use Materialize css Tabs in Meteor?

    How to add css class?

    How to setup a multi-department form using JavaScript

    CSS how to make an element fade in and then fade out?

    CSS hide/show effect works on Firefox but not on Chrome/Safari

    How to add a color in the
    bottom content area?

    How to center video source in circle shape using css, html

    Cache policy, css/js/images how to make them not to load each time i do full postback?

    how to show an arrow to the only li item that has sub-menu

    How to not inherit width in css?

    how to get true css property names from CSSStyleDeclaration object?

    SASS: How to exclude part of selector

    How to Vertical align text in div

    How to add css library to project generated with angular-cli@webpack

    CSS: How to select all rel atributes

    How to make jQuery UI nav menu horizontal?

    How to Style CSS Checkboxes with Font Awesome

    How to include css from resources folder in symfony 2

    How to add image, that overlapping Bootstrap modal?

    How to hide overflow on slideshow without hiding arrows?

    jQuery: How to check if an element exists and change css property

    how to build a mobile site - basics, is it all CSS?

    How to write a PHP code that will group students into groups of ten using data from a database? [closed]

    How to make Chrome and IE display block hyperlinks correctly

    How to read CSS Content value with jQuery?

    How do I make the 'panel/well' dynamically wrap around the image while keeping it centered? // Using Bootswatch/Bootstrap CSS

    How do I add an image directly below a text header?

    How can I achieve this layout using CSS only?