为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

繁星点点滴滴 2024-01-11 16:31:39
由于某种原因,我在网站中使文本居中时遇到一些问题。我需要文本在网站(计算机和网站)中精确居中。.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>
查看完整描述

2 回答

?
子衿沉夜

TA贡献1828条经验 获得超3个赞

.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);

    z-index:0;

  }


#cs {

    display: block;

    text-align: center;

    font-family: 'Times New Roman';

    position: relative;

    color: #EFE4D9;  

}


#text {

  position: relative;

}


查看完整回答
反对 回复 2024-01-11
?
智慧大石

TA贡献1946条经验 获得超3个赞

尝试这个:


.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);

    z-index:0;

  }


#cs {

    display: block;

    text-align: center;

    font-family: 'Times New Roman';

    position: relative;

    color: #EFE4D9;  

}


#text {

  position: relative;

}

<!DOCTYPE html>

<html>

    <head>

        <link rel="stylesheet" href="styles.css">

    </head>

    <body>

        <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>

        <!--a countdown should be here-->

    </body>

</html>


查看完整回答
反对 回复 2024-01-11
  • 2 回答
  • 0 关注
  • 106 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信