html - 当标题浮动时如何将标题和段落放在单独的行中?
问题描述
我只是想在段落的右侧和下方获取标题。所以我只是试图向右浮动标题。但是段落和标题在同一行。当标题位于 div 的右侧时,如何获取标题下的段落。我试过这样。
.aboutus{
height: 100vh;
width: 100%;
}
.details{
}
.details h1{
float: right;
text-transform: uppercase;
color: #EE4036;
font-size: 4.5em;
font-weight: bold;
}
<section class="row aboutus">
<div class="container">
<div class="details">
<h1>about us</h1>
<p>some text here.some text here.some text here.some text here.some text here.some text here.some text here.some text here.some text here.some text here.some text here.some text here.some text here.some text here.
</p>
</div>
</div>
</section>
解决方案
您可以为此使用 text-align 属性。text-align 属性指定元素中文本的水平对齐方式。
div.a {
text-align: center;
}
div.b {
text-align: left;
}
div.c {
text-align: right;
}
div.c {
text-align: justify;
}
您可以使用此链接尝试更多关于 text-align 属性的信息。 https://www.w3schools.com/cssref/playit.asp?filename=playcss_text-align
这是你预期的结果???
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://fonts.googleapis.com/css?family=Bree+Serif&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<style>
.aboutus{
height: 100vh;
width: 100%;
}
.details{
}
.details h1{
text-align: right;
text-transform: uppercase;
color: #EE4036;
font-size: 4.5em;
font-weight: bold;
}
</style>
</head>
<body>
<section class="row aboutus">
<div class="container">
<div class="details">
<h1>about us</h1>
<p>some text here.some text here.some text here.some text here.some text here.some text here.some text here.some text here.some text here.some text here.some text here.some text here.some text here.some text here.
</p>
</div>
</div>
</section>
</body>
</html>
推荐阅读
- html - Chrome CSS:使用伪元素的相邻选择器不起作用
- teamcity - OctopusDeploy:创建发布步骤失败并出现错误“提要返回了意外的状态代码 '403'”
- amazon-web-services - 如何禁用在 S3 中公开存储桶
- python - 如何使用python在数据框中将列中的每个元素移动n个范围?
- filter - Google表格中带有过滤功能的公式解析错误
- java - Arraylist 中的数据重复
- oracle - Devart dotConnect for Oracle 不会与 Visual Studio 2017 安装/集成
- python - 如何加载使用纯张量流训练的 tf.keras 模型
- java - 如何添加显示更多功能以获取 firebase 数据库?
- julia - 使用 eigs 从一组复杂的特征值中恢复具有最大实部的特征值