如何水平居中文本(h2)?我有问题

由于某种原因,我在网站中使文本居中时遇到一些问题。我需要文本在网站(计算机和网站)中精确居中。


.bg { 

    background: url(https://i.imgur.com/HrC81SX.jpg) no-repeat center center fixed; 

    -webkit-background-size: cover;

    background-size: cover;

    width: 100%;

    height: 100%;

    top: 0;

    left: 0;

    position: fixed;

    -webkit-filter: blur(5px);

    filter: blur(5px);

  }


#cs {

    display: block;

    text-align: center;

    font-family: 'Times New Roman';

    position: absolute;

    color: #EFE4D9;

}


#text {

    text-align: left;

}

<div class="bg"></div>

<h1 id="cs" style="text-align: center;">C O M I N G&nbsp;&nbsp;&nbsp;S O O N</h1>

<p id="text">such's movie room is on it's way through the development, just stay tuned! C:<br>- such <3</p>


繁星点点滴滴
浏览 117回答 2
2回答

子衿沉夜

.bg {&nbsp;&nbsp; &nbsp; background: url(https://i.imgur.com/HrC81SX.jpg) no-repeat center center fixed;&nbsp;&nbsp; &nbsp; -webkit-background-size: cover;&nbsp; &nbsp; background-size: cover;&nbsp; &nbsp; width: 100%;&nbsp; &nbsp; height: 100%;&nbsp; &nbsp; top: 0;&nbsp; &nbsp; left: 0;&nbsp; &nbsp; position: fixed;&nbsp; &nbsp; -webkit-filter: blur(5px);&nbsp; &nbsp; filter: blur(5px);&nbsp; &nbsp; z-index:0;&nbsp; }#cs {&nbsp; &nbsp; display: block;&nbsp; &nbsp; text-align: center;&nbsp; &nbsp; font-family: 'Times New Roman';&nbsp; &nbsp; position: relative;&nbsp; &nbsp; color: #EFE4D9;&nbsp;&nbsp;}#text {&nbsp; position: relative;}

智慧大石

尝试这个:.bg {&nbsp;&nbsp; &nbsp; background: url(https://i.imgur.com/HrC81SX.jpg) no-repeat center center fixed;&nbsp;&nbsp; &nbsp; -webkit-background-size: cover;&nbsp; &nbsp; background-size: cover;&nbsp; &nbsp; width: 100%;&nbsp; &nbsp; height: 100%;&nbsp; &nbsp; top: 0;&nbsp; &nbsp; left: 0;&nbsp; &nbsp; position: fixed;&nbsp; &nbsp; -webkit-filter: blur(5px);&nbsp; &nbsp; filter: blur(5px);&nbsp; &nbsp; z-index:0;&nbsp; }#cs {&nbsp; &nbsp; display: block;&nbsp; &nbsp; text-align: center;&nbsp; &nbsp; font-family: 'Times New Roman';&nbsp; &nbsp; position: relative;&nbsp; &nbsp; color: #EFE4D9;&nbsp;&nbsp;}#text {&nbsp; position: relative;}<!DOCTYPE html><html>&nbsp; &nbsp; <head>&nbsp; &nbsp; &nbsp; &nbsp; <link rel="stylesheet" href="styles.css">&nbsp; &nbsp; </head>&nbsp; &nbsp; <body>&nbsp; &nbsp; &nbsp; &nbsp; <div class="bg"></div>&nbsp; &nbsp; &nbsp; &nbsp; <h1 id="cs" style="text-align: center;">C O M I N G&nbsp;&nbsp;&nbsp;S O O N</h1>&nbsp; &nbsp; &nbsp; &nbsp; <p id="text">such's movie room is on it's way through the development, just stay tuned! C:<br>- such <3</p>&nbsp; &nbsp; &nbsp; &nbsp; <!--a countdown should be here-->&nbsp; &nbsp; </body></html>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Html5