我有一段文字,我想在每個屏幕上居中。但是,每當屏幕尺寸增大時,屏幕保持在頂部,屏幕底部保持空白並且看起來很糟糕。無法使用Bootstrap爲不同的屏幕大小定位HTML文本部分
我粘貼了代碼和屏幕截圖,如何保持最佳狀態而不是居中。
我也在代碼中標記了那部分,從頂部調整頁面的填充。不知道如何使它適合所有屏幕尺寸的中心。由於
body {
width: 100%;
height: 100%;
font-family: Lora,"Helvetica Neue",Helvetica,Arial,sans-serif;
color: #fff;
background-color: #000;
}
html {
width: 100%;
height: 100%;
}
h1,
h2,
h3,
h4,
h5,
h6 {
margin: 0 0 35px;
text-transform: uppercase;
font-family: Montserrat,"Helvetica Neue",Helvetica,Arial,sans-serif;
font-weight: 700;
letter-spacing: 1px;
}
p {
margin: 0 0 23px;
font-size: 18px;
line-height: 1.5;
}
@media(min-width:768px) {
p {
text-align: justify;
text-justify: inter-word;
margin: 0 0 20px;
font-size: 20px;
line-height: 1.6;
}
}
a {
color: #3bc692;
-webkit-transition: all .2s ease-in-out;
-moz-transition: all .2s ease-in-out;
transition: all .2s ease-in-out;
outline: 0!important;
}
@media(min-width:768px) {
.adjust-this {
padding-left: 55px; padding-right: 55px;
}
}
.content-section {
padding-top: 85px;
}
@media(min-width:767px) {
.content-section {
padding-top: 50px; /*This is where you can adjust padding for the section*/
width: 100%;
height: 100%;
}
}
.content-section p {
opacity: 0.9;
font-family: 'Domine';
font-size: 19px;
font-weight: 500;
}
a:hover,
a:focus {
text-decoration: none;
color: #1d9b6c;
}
.greeting {
padding-top: 5px;
margin-bottom: 20px;
}
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>About</title>
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="about.css" rel="stylesheet">
<!-- Custom Fonts -->
<link href="font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="http://fonts.googleapis.com/css?family=Open Sans:400,700,400italic,700italic" rel="stylesheet" type="text/css">
</head>
<body>
<!-- About Section -->
<article id="about" class="content-section">
<div class="container">
<div class="row">
<div class="col-sm-10 col-sm-offset-1 text-left adjust-this">
<h2 class="text-center greeting">Hi there!</h2>
<p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
</p>
<p>
It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
<p>
It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.
</p>
</div>
</div>
</div>
</article>
</body>
你能約你的要求更加明確。此外這似乎是一個簡單的谷歌問題。 – Ale
我希望這個文本能夠在更大的屏幕中居中並且不會留在空底部的頂部 – tsaebeht
您可以在這裏查看幾種居中方法:https://css-tricks.com/centering-css-complete-guide/ – Alvaro