我正在建立一个网站作为学习练习。目的是展示一些故事,因此文本的可读性非常重要。
对于主页,关于页面和类似页面,我的布局很好。但是,在有故事的页面上,当我将字体大小增加到1.2rem或更高时,段落似乎将页面上的所有内容相对于其他页面上所有内容的位置向左移动。
我已经为所有容器设置了宽度,但是似乎没有什么不同。
我尝试隔离问题,只有字体大小有所不同。如果我将其设置为低于1.2rem,它将移回其正确位置。
以下是故事页面之一的HTML和故事页面CSS文件。任何引导程序术语都只是我采用的术语,它们没有使用任何Bootstrap样式。试图从头开始构建它。
很抱歉,或者以下任何一种格式不正确/写得不好。
感谢任何帮助。
谢谢!
/* Fonts */
/* Montserrat and Raleway */
@import url('https://fonts.googleapis.com/css?family=Montserrat|Raleway');
/* Reset */
* {
box-sizing: border-box;
}
html {
font-size: 16px;
font-family: 'Raleway', sans-serif;
}
/* Components */
.container {
width: 66%;
margin: 0 auto;
}
.jumbotron {
background-color: #ededed;
padding: 6% 10%;
margin: 20px;
}
.jumbotron-header {
font-size: 2rem;
font-family: 'Montserrat', sans-serif;
}
/*block size and height, margins left and right slightly*/
.story-text {
font-size: 1.5rem;
line-height: 1.5;
margin: 20px;
width: 100%;
}
.story-text > p {
width: 100%;
}
.story-subtitle {
font-size: 2rem;
font-weight: 600;
font-family: 'Montserrat', sans-serif;
}
.quote-block {
margin: 50px 300px;
}
.quote {
font-style: italic;
}
.quote-attribution {
font-weight: 700;
}
/* General Styling */
a {
text-decoration: none;
color: black;
}
/* Navigation */
/* Layout */
.nav-area {
display:flex;
height: 40px;
background-color: #ededed;
align-items: center;
}
.nav-links {
display: flex;
flex-grow: 10;
align-items: center;
}
.logo-area {
display: flex;
flex-grow: 1;
justify-content: space-around;
align-items: center;
background-color: #bcbcbc;
height: inherit;
}
/* Styling */
#logo {
font-size: 20px;
font-weight: bold;
}
.nav-links > div {
height: 40px;
line-height: 40px;
}
.nav-links span {
font-size: 20px;
margin: 20px;
line-height: normal;
vertical-align: middle;
}
.nav-links > div:hover {
background-color: #ffffff;
}
/* Mobile */
/* Burger Menu */
.mobile-nav {
display: none;
}
.mobile-menu {
display: none;
}
.mobile-menu > div {
background-color: #ededed;
border: 1px solid #e5e5e5;
padding: 5%;
}
.mobile-menu > div:hover {
background-color: #cecece;
}
/* Navigation */
@media screen and (max-width: 826px) {
.nav-area {
height: auto;
}
.logo-area {
padding: 5%;
}
}
@media screen and (max-width: 700px) {
.nav-links {
display: none;
}
.mobile-nav {
display: block;
margin: 20px;
}
}
@media screen and (max-width: 740px) {
.jumbotron-header {
font-size: 1rem;
}
.story-text {
font-size: 1rem;
}
.story-subtitle {
font-size: 1.2rem;
}
}
<body>
<!-- Navbar -->
<header>
<div class="nav-area container">
<div class="logo-area">
<span id="logo"><a href="../index.html">The Lovecraft Project</a></span>
</div>
<div class="nav-links">
<div><span><a href="../index.html">Home</a></span></div>
<div><span><a href="../About-Us/index.html">About</a></span></div>
<div><span><a href="../Stories/index.html">Stories</a></span></div>
</div>
<!-- Burger Menu -->
<i class="mobile-nav fas fa-bars"></i>
</div>
</header>
<div class="container">
<!-- Mobile Menu -->
<div class="mobile-menu">
<div><a href="../index.html">Home</a></div>
<div><a href="../About-Us/index.html">About</a></div>
<div><a href="../Stories/index.html">Stories</a></div>
</div>
</div>
<!-- Content -->
<div class="container">
<div class="jumbotron">
<div class="jumbotron-header">
<h1>The Shadow Over Innsmouth</h1>
<hr>
<p>H.P. Lovecraft</p>
</div>
</div>
<div class="story-text">
<p class="story-subtitle">I.</p>
<p>During the winter of 1927–28 officials of the Federal government made a strange and secret investigation of certain conditions in the ancient Massachusetts seaport of Innsmouth. The public first learned of it in February, when a vast series of raids and arrests occurred, followed by the deliberate burning and dynamiting—under suitable precautions—of an enormous number of crumbling, worm-eaten, and supposedly empty houses along the abandoned waterfront. Uninquiring souls let this occurrence pass as one of the major clashes in a spasmodic war on liquor.</p>
<p>Keener news-followers, however, wondered at the prodigious number of arrests, the abnormally large force of men used in making them, and the secrecy surrounding the disposal of the prisoners. No trials, or even definite charges, were reported; nor were any of the captives seen thereafter in the regular gaols of the nation. There were vague statements about disease and concentration camps, and later about dispersal in various naval and military prisons, but nothing positive ever developed. Innsmouth itself was left almost depopulated, and is even now only beginning to shew signs of a sluggishly revived existence.</p>
<p>Complaints from many liberal organisations were met with long confidential discussions, and representatives were taken on trips to certain camps and prisons. As a result, these societies became surprisingly passive and reticent. Newspaper men were harder to manage, but seemed largely to coöperate with the government in the end. Only one paper—a tabloid always discounted because of its wild policy—mentioned the deep-diving submarine that discharged torpedoes downward in the marine abyss just beyond Devil Reef. That item, gathered by chance in a haunt of sailors, seemed indeed rather far-fetched; since the low, black reef lies a full mile and a half out from Innsmouth Harbour.</p>
<p>People around the country and in the nearby towns muttered a great deal among themselves, but said very little to the outer world. They had talked about dying and half-deserted Innsmouth for nearly a century, and nothing new could be wilder or more hideous than what they had whispered and hinted years before. Many things had taught them secretiveness, and there was now no need to exert pressure on them. Besides, they really knew very little; for wide salt marshes, desolate and unpeopled, keep neighbours off from Innsmouth on the landward side.</p>
<p>But at last I am going to defy the ban on speech about this thing. Results, I am certain, are so thorough that no public harm save a shock of repulsion could ever accrue from a hinting of what was found by those horrified raiders at Innsmouth. Besides, what was found might possibly have more than one explanation. I do not know just how much of the whole tale has been told even to me, and I have many reasons for not wishing to probe deeper. For my contact with this affair has been closer than that of any other layman, and I have carried away impressions which are yet to drive me to drastic measures.</p>
</div>
</div>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script>
<script type="text/javascript" src="../Resources/Scripts/script.js"></script>
</body>
答案 0 :(得分:0)
我想问题是,每当您增加字体大小时,它都会在提供的固定宽度内相应地对齐。因此,为了每次获得所需的布局,请使用百分比而不是固定值。