CSS:在页面中间放置文本 [英] CSS: Position text in the middle of the page

查看:1140
本文介绍了CSS:在页面中间放置文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在任何用户页面的中间放置一个<h1>.我一直在搜索互联网,他们都将其放置在错误的位置.谢谢!

更新:我的意思是垂直和水平!在正中间!
另外:页面上没有没有任何内容.

I would like to position a <h1> in the middle of any user's page. I have been searching the internet and they all position it in the incorrect place. Thank you!

UPDATE: I mean vertical and horizontal! In the exact middle!
ALSO: There is nothing else on the page.

推荐答案

尝试以下CSS:

h1 {
    left: 0;
    line-height: 200px;
    margin-top: -100px;
    position: absolute;
    text-align: center;
    top: 50%;
    width: 100%;
}

jsFiddle: http://jsfiddle.net/wprw3/

jsFiddle: http://jsfiddle.net/wprw3/

这篇关于CSS:在页面中间放置文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆