Internet Explorer CSS - Div Center

I recently made a website, but I really have a big problem with Internet Explorer. CSS seems to do weird things in IE. Instead of copying hundreds of CSS lines, this is a link to the site page: http://www.appwheal.com/app/ios/angry-birds-space All content should be displayed in the middle of the screen. Instead, IE is stuck on the left.

I use

margin-left: auto; margin-right: auto; 

This is supported by IE, right.

Please help and thanks in advance.

+4
source share
4 answers

You need to declare the default DOCTYPE or Internet Explorer parameter for Quirks mode (IE5 compatible). Go to Internet Explorer, press F12 to open the developer tools, and note that in document mode it shows the "Quirks" mode. Quirks does not support any of the well-known methods of centering divs around, and declaring DOCTYPE is the easiest (and recommended) way to fix it.

To customize the page for XHTML 1.0 Transitional (which is the most common), use

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

To declare a page to be HTML5 compatible, use

 <!DOCTYPE html> 

The DOCTYPE line should be the first line in the html file that appears before the opening <html> .

+12
source

You must also install

 body { text-align: center; } #yourDiv { margin: 0 auto; text-align: left; } 
+1
source

Set margin and width:

 #yourDiv { margin: 0 auto; width: 300px; } 
+1
source

You can use the old text text-align: center And try top: 50%; left: 50%; and the offset of the corresponding negative pixels

0
source

Source: https://habr.com/ru/post/1412646/


All Articles