html - 为什么我的段落超出了调整大小段落下方的 hr 行?
问题描述
问题是我的屏幕左侧有一个图像,我的屏幕右侧有一个段落,段落和图像下方有一条 hr 线。因此,每当我调整浏览器窗口的大小时,该段落就位于 hr 行下方,因为它在调整大小时会被压缩(压扁)。即使我调整浏览器窗口的大小,我也不希望该段落低于 hr 行。我希望段落低于图像但不超过 hr 线。如果您想查看问题所在,请查看我的网站并调整浏览器窗口大小以查看问题。
网站链接:http: //www.greenfield-school.com/AboutUs.html
谢谢
这是 HTML:
<h3><b>About Us</b></h3>
<hr style="border: 2px solid green; width: 88%">
<div class="row2">
<div class="column2" style="background-color:;">
<img class="pic img-responsive" src="Icon.jpeg" style="height: 200px; height: 230px">
</div>
<div class="column" style="background-color:;">
<h5 class="welcome"><b>Mission</b></h5>
<p class="paragraph" style="font-family: book antiqua"><li class="vision1">To care for, respect and encourage all children equally, regardless of gender or ability.</li>
<li class="vision1">To encourage our pupils to develop a sense of self worth, self discipline, personal responsibility and consideration for others.</li>
<li class="vision1">To provide an enjoyable, challenging and purposeful atmosphere for our pupils.</li>
<li class="vision1">To value and encourage the special talents and strengths of pupils.</li></p>
</div>
</div>
这是CSS:
.vision1 {
list-style-type: square;
font-family: book-antiqua;
}
.row2{
display: flex;
padding: 2rem 6rem;
}
.column {
flex: 60%;
height: 200px; /* Should be removed. Only for demonstration */
}
.column2{
flex: 0%;
height: 0px; /* Should be removed. Only for demonstration */
}
h3{
padding: 5rem 5rem 0rem;
color: green;
}
解决方案
让我为您提供一个替代方案 - 我似乎无法在container
height
. 但这可以无缝地工作:
这是您的 HTML:
<div class="container">
<div class="column one"> Column 1 - this is where your picture is</div>
<div class="column two"> Column 2 - this is where your paragraph is</div>
</div>
<hr />
这是CSS:
.container{
width: 100%;
overflow: auto;
height: auto;
clear: both;
display: block;
}
.column{
float: left;
}
.column.one{
//style for column one here
}
.column.two{
//style for column two here
}
hr{
clear: both;
}
这将container
根据column one
或的最大高度调整高度column two
我在这里检查了这段代码CodePen
推荐阅读
- sql - SQL - 在“AND”之后使用“CASE”
- node.js - 第一次尝试对 github 存储库进行 docker 化——我做错了什么?
- autodesk-forge - 如何使用标记扩展创建直线工具?
- java - 扫描仪错误 - 尝试在空对象引用上调用虚拟方法
- reactjs - 即使在提供样式后 CSS 对象也是空的
- docker - 每次创建 docker 镜像时都会下载 Gradle 依赖项
- javascript - MS Edge 中的 :scope 伪选择器
- reactjs - 反应父组件复选框状态更新一步延迟
- node.js - Node.js Web 应用程序在部署到 heroku 时崩溃
- sql - 如何使用 DB Browser SQLite 在列中添加批量值