html - CSS 和页面大小调整
问题描述
我正在设置一个带有顶部的简单页面,下面的部分分为垂直部分。
左侧部分包含一个站点菜单,右侧部分包含措辞,中间是左右之间的空格(不需要?)。
我的问题:
当页面水平调整大小时,右侧部分在左侧移动,完全遮盖了站点菜单。
右侧部分中的文本环绕到站点菜单下方的左侧。我希望右侧部分中的文本保留在右侧部分中。
.top {
width: auto;
height: auto;
padding-bottom: 50px;
background-color: white;
}
.ileft {
width: 15%;
float: left;
background-color: white;
}
.imiddle {
width: 5%;
float: left;
background-color: white;
}
.iright {
width: 80%;
float: left
margin-left: 30px;
background-color: white;
}
解决方案
请按照其他人所说的那样使用flex
或grid
创建此布局。
但是,如果您出于某种原因想要使用此设置,则代码的问题是您在选择器中的属性;
之后缺少一个,您需要将宽度设置为以便它考虑该属性(或仅删除)。float
.iright
calc(80% - 30px)
margin-left
margin-left
/* Added so you can see the output better */
div {
height: 40px;
}
.top {
width: auto;
height: auto;
padding-bottom: 50px;
background-color: red;
}
.ileft {
width: 15%;
float: left;
background-color: blue;
}
.imiddle {
width: 5%;
float: left;
background-color: purple;
}
.iright {
width: calc(80% - 30px);
float: left;
padding: left;
margin-left: 30px;
background-color: yellow;
}
<div class="top">Top</div>
<div class="ileft">Left</div>
<div class="imiddle">M</div>
<div class="iright">Right</div>
请按照其他人所说的那样使用flex
或grid
创建此布局。
推荐阅读
- javascript - 如何预填充下拉字段
- javascript - 尝试将文本框值添加为表格行
- recursion - 是否可以限制 S3 存储桶中递归目录列表的深度?
- css - chrome 中的 flex-basis 自动
- django - NoModuleName 'channels',但我已经安装了它。姜戈
- node.js - 为什么 Express 应用使用 server.js 和 app.js
- javascript - 如何轻松到达距其后代 12 级的祖先元素?
- javascript - 通过 PHP 查询本地 PostGIS 数据库
- c++ - 如何创建一个将键作为输入并在 C++ std:map 中查找值的模板函数?
- express - 多次调用 Express 路由器中间件