Center text at the bottom of the page

I want the text to be centered at the bottom of the page.

I have the following code:

<html> <head> <title>test</title> </head> <body> <div style="position: relative"> <p style="position: fixed; bottom: 0; width:100%; text-align: center"> bla bla </p> </div> </body> </html> 

It works fine in Firefox and Chrome, but not in IE.

+4
source share
2 answers

You need to add doctype as the very first line:

 <!DOCTYPE html> <html> 

Without it, IE uses Quirks mode , which emulates IE 5.5 (which does not support position: fixed ).

+7
source

This might be a copy and paste problem, but you need an end quote in <p style=... > , which should help. Another option is to set text-align: center in the actual <div> so that you align the text inside the div. Both of them worked in IE 9 - what version of IE do you use to prevent it from working?

 <html> <head> <title>test</title> </head> <body> <div style="position: relative"> <p style="position: fixed; bottom: 0; width:100%; text-align: center"> bla bla</p> </div> </body> </html> 

OR

 <html> <head> <title>test</title> </head> <body> <div style="position: relative; text-align: center"> <p style="position: fixed; bottom: 0; width:100%;"> bla bla</p> </div> </body> </html> 
+1
source

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


All Articles