gpt4 book ai didi

HTML/CSS - 增加字体大小将页面上的所有内容向左移动

转载 作者:行者123 更新时间:2023-11-28 01:27:34 25 4
gpt4 key购买 nike

我正在构建一个网站作为学习练习。它的目的是展示一些故事,因此文本的可读性非常重要。

对于主页、关于和类似页面,我的布局很好。然而,在有故事的页面上,在我将字体大小增加到 1.2rem 或更大之后,段落似乎将页面上的所有内容相对于其他页面上的所有内容移动到左侧。

我已经为所有容器设置了宽度,但似乎并没有什么不同。

我已尝试找出问题所在,但只有字体大小有影响。如果我将它设置为低于 1.2rem,它会移回到正确的位置。

其中一个故事页面的 HTML 和故事页面的 CSS 文件如下。任何 Bootstrap 术语都是我采用的术语,它们没有使用任何 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>

最佳答案

我想问题是,无论何时增加字体大小,它都会在您提供的固定宽度内相应地对齐自身。因此,为了每次都获得所需的布局,请使用百分比而不是固定值。

关于HTML/CSS - 增加字体大小将页面上的所有内容向左移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51156496/

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