【发布时间】:2021-05-01 23:55:21
【问题描述】:
我正在尝试在左侧栏旁边的中间制作内容容器,但无法让它在窗口调整大小时正确调整大小,并且仍然让整个内容容器不会超出窗口的视图。
https://jsfiddle.net/ptm7f6cL/
问题是如果我删除宽度:calc(100% - 200px);从 APP - 调整大小的 div 会丢失右侧的一部分并且不可见。
如果我使用 width:calc(100% - 200px);
就可以了但是当我调整它的大小时,会有这样的差距: 如何去除绿色间隙并仍然让容器正确调整大小而不会丢失右侧的 200px。
<!DOCTYPE html>
<html lang="en" style="padding: 0; position:fixed; left: 0; margin: 0; top: 0; width: 100%; height: 100%; background-color: purple;">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body style="padding: 0; left: 0; margin: 0; top: 0; width: 100%; min-width: 100%; height: 100%; background-color: lime;">
<!--Wrapper-->
<div style=" width: 100%; height: 100%; display: inline-flex;">
<!--LEFTBAR-->
<div style="max-width: 200px; min-width: 200px; width: inherit; box-sizing: border-box; height: inherit; max-height:100%; padding: 10px; left:0; top: 0; background-color:green;">
<h1>sadsdsadsad</h1>
</div>
<!--Wrapper 2-->
<div style="width: 100%; height: 100%; box-sizing: border-box; ">
<!--TOPBAR-->
<div style="display: inline-flex; width: 100%; height: 50px; padding: 10px; right:0; bottom: 0; background-color: sandybrown;">
<h1> adfgggggghhhhjjjjjjjjkkkkkkkllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll</h1>
<h1> ad</h1>
<h1> ad</h1>
<h1> ad</h1>
<h1> ad</h1>
<h1> ad</h1>
</div>
<!--APP-->
<div style=" width:calc(100% - 200px); max-width: 100%; height:calc(100% - 70px); box-sizing: border-box; display: flex; padding: 10px; right:0; bottom: 0; background-color:aqua;">
<iframe style="box-sizing: border-box; width: 100%; height:100%;" src="https://iconarchive.com/"></iframe>
</div>
<!-- Wrapper 3 Right Right -->
<!-- <div style="float: right; height:calc(100% - 70px); background-color:red;"> -->
</div>
<!-- Wrapper-Right 3 -->
<!-- <div style="position: relative; width:10px; height: 100%; background-color: orange;"></div> -->
</div>
</body>
</html>
无位置:固定;在 Html 标签上
问候
【问题讨论】:
-
你的 APP div 有
width:calc(100% - 200px);-> 所以你在右边有 200px 的空间。您的并发 DIV 是 LEFTBAR 和 Wrapper 2 -> 检查它们的大小和位置。 -
问题是如果我删除宽度:calc(100% - 200px);从 APP - 调整大小的 div 会丢失右侧的一部分并且不可见。
-
为什么你的位置:固定在你的 HTML 标签上?
-
你为什么不使用类?
-
我没有使用类,因为我正在测试它知道。位置:固定;在 html 上是因为在调整大小时它变得比屏幕小。我正在使用 chrome 上的开发工具对其进行测试,但针对的是移动版本。