Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Align text centrally on the bottom of the page

Tags:

html

css

I want to have a text aligned centrally on 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.

like image 530
user1006115 Avatar asked Feb 22 '23 00:02

user1006115


2 Answers

You need to add a doctype as the very first line:

<!DOCTYPE html>
<html>

Without it, IE is using Quirks Mode which emulates IE 5.5 (which doesn't support position: fixed).

like image 57
thirtydot Avatar answered Feb 28 '23 04:02

thirtydot


Might be a copy and paste issue but you need an ending quote in your <p style=... >, that should help. Another option is the set your text-align: center on the actual <div> so your aligning the text inside the div. Both of these worked in IE 9 - what version of IE are you using that it's not working in?

<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>
like image 42
Robert Avatar answered Feb 28 '23 04:02

Robert