gpt4 book ai didi

html - 将 css 对齐到中间的问题

转载 作者:行者123 更新时间:2023-11-27 23:54:35 25 4
gpt4 key购买 nike

我在尝试将错误文本中心向下对齐到屏幕中间时遇到一些问题,填充有效,但 <h1>开始在一个很大的缝隙中分开,我希望它和现在一样但是在屏幕的中央。所有 <div>那说display: none;用于在正常工作的桌面模式下隐藏移动导航栏。

.nav2 {
display: none;
}

.nav-header{
display: none;
}

.nav-title{
display: none;
}

.nav-btn{
display: none;
}

.nav-check{
display: none;
}

#nav-check{
display: none;
}

.nav-links{
display: none;
}

.nav-header{
display: none;
}

.nav2 a {
display: none;
}

.nav-header a{
display: none;
}

.nav-title a{
display: none;
}

.nav-btn a {
display: none;
}

.nav-check a{
display: none;
}

#nav-check a{
display: none;
}

.nav-links a{
display: none;
}

.nav-header a{
display: none;
}

body > #header{position:fixed;}
#header {
width: 100%;
position: fixed;
z-index:9000;
color: #000000;
WHITE BG // color/ #8c8c8c;
font-size: 25px;
text-align: left;
font-family: 'Pacifico', cursive;
left: 15px;
top: 25px;
transition: all 0.5s linear;
transition: height 0.5s ease;
-webkit-transition: height 0.5s ease;
-moz-transition: height 0.5s ease;
-o-transition: height 0.5s ease;
-ms-transition: height 0.5s ease;
transition: background-color 0.5s ease;
-webkit-transition: background-color 0.5s ease;
-moz-transition: background-color 0.5s ease;
-o-transition: background-color 0.5s ease;
-ms-transition: background-color 0.5s ease;
transition: background-color 0.5s ease;
-webkit-animation: fadein 2s; /* Safari, Chrome and Opera > 12.1 */
-moz-animation: fadein 2s; /* Firefox < 16 */
-ms-animation: fadein 2s; /* Internet Explorer */
-o-animation: fadein 2s; /* Opera < 12.1 */
animation: fadein 2s;

}

#navigation {
width: 100%;
position: fixed;
z-index: 9000;
text-decoration: none!important;
list-style-type: none;
color: #006CFF;
font-family: 'Ubuntu', sans-serif;
font-size: 15px;
text-align: right;
margin: 22px -20px;
-webkit-animation: fadein 2s; /* Safari, Chrome and Opera > 12.1 */
-moz-animation: fadein 2s; /* Firefox < 16 */
-ms-animation: fadein 2s; /* Internet Explorer */
-o-animation: fadein 2s; /* Opera < 12.1 */
animation: fadein 2s;


}



.feedback {
text-align: center;
font-size: 22px;
color: #494949;

}

h1 {
text-align: center;
font-size: 50px;
font-weight: bolder;
color: #494949;

}
<doctype! html>
<html>
<head>
<link href="https://cdn.rawgit.com/michalsnik/aos/2.1.1/dist/aos.css" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Oops.. Dead End</title>
<script src="https://cdn.rawgit.com/michalsnik/aos/2.1.1/dist/aos.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-136743580-1"></script>
<div id="header">adamferreira</div>
<div id="navigation">
<ul>
<a class="nav" href="index.html"> Return Home</a>
</ul>
</div>


<div class="headerBackground"></div>
<body>

<div class="container" data-aos="ease-in-out-back" data-aos="zoom out">
<h1>Looks like this page doesn't exist</h1>
<h1 class="feedback">Please double-check you are entering the correct information in your address bar.<br> This page may also have been moved, deleted or a feature may not be available to you.</h1>


</head>

</body>
</html>

最佳答案

希望你一切顺利。以下是我在这种情况下建议的代码更改:

<div class="new">
<h1>Looks like this page doesn't exist</h1>
<h2 class="feedback">Please double-check you are entering the correct
information in your address bar.<br> This page may also have been moved,
deleted or a feature may not be available to you.</h1>
</div>

我创建了一个类名为“new”的新 div,并根据标准更改了第二个标签(将其更改为 h2)。最重要的是,在 CSS 中添加了以下内容:

.new {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}

希望对您有所帮助。

关于html - 将 css 对齐到中间的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56335044/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com