- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试使用 float 和 clear 在没有常见网格系统的情况下设置页面样式。页面的宽度和高度都应使用完整视口(viewport)。下面的设置工作正常,除非我开始调整视口(viewport)的大小。移动视口(viewport)后,导航和内容部分突然开始重叠,内容呈现在导航下方。
当用户可能会调整视口(viewport)大小时,我的方法有问题吗?或者我不应该使用 vh
和 vw
吗?
设置应该非常简单:
79.99vw
和 99.9vh
等尺寸的引入是为了避免任何舍入问题。我还分别尝试了 80vw
和 100vh
。
我的模板是这样的:
<div class="dashboard-wrapper">
<header class="header-bar">
<h1 class="bar-title">Brand Logo</h1>
<button class="logout-button">Log out</button>
</header>
<section class="side-bar">
<nav role="navigation" class="sidebar">
<ul>
<li>Navigation One</li>
<li>Navigation Two</li>
<li>Navigation Three</li>
<li>Navigation Four</li>
<li>Navigation Five</li>
</ul>
</nav>
</section>
<section class="content">
<h2>Lorem Ipsum</h2>
<p>Sed ut perspiciatis ...</p>
</section>
</div>
我的 CSS 看起来像这样:
.dashboard-wrapper {
margin-right: auto;
margin-left: auto;
}
.dashboard-wrapper header.header-bar {
float: top;
height: 40px;
}
.dashboard-wrapper header.header-bar h1 {
position: relative;
margin: 0 0 0 5px;
float: left;
}
.dashboard-wrapper header.header-bar button {
position: relative;
height: 40px;
width: 80px;
border: 0;
float: right;
}
.dashboard-wrapper section.side-bar {
float: left;
clear: left;
width: 20vw;
min-height: calc(99.9vh - 40px - 20px);
margin: 10px;
background: white;
}
.dashboard-wrapper section.content {
float: right;
clear: right;
position: relative;
width: calc(79.99vw - 30px);
min-height: calc(99.9vh - 40px - 20px);
margin: 10px 10px 10px 0;
background: white;
}
到目前为止,这仅在 Windows 上的 Chrome 中进行了测试。
最佳答案
float:top
, .cf
以清除 float
box-sizing:border-box
以防万一您可能会使用 padding
width
切换为 %
单位的 vw
单位,以便在使用 calc
时获得四舍五入的值并保持一致跨设备的结果。* {
box-sizing: border-box
}
.cf:before,
.cf:after {
content: " ";
display: table;
}
.cf:after {
clear: both;
}
body {
margin: 0;
}
.dashboard-wrapper header.header-bar {
height: 40px;
/*demo*/
background: green
}
.dashboard-wrapper header.header-bar h1 {
margin: 0 0 0 5px;
float: left;
}
.dashboard-wrapper header.header-bar button {
height: 40px;
width: 80px;
border: 0;
float: right;
}
.dashboard-wrapper section.side-bar {
float: left;
width: 20%;
min-height: calc(100vh - 60px);
margin: 10px;
background: red;
}
.dashboard-wrapper section.content {
float: left;
width: calc(80% - 30px);
min-height: calc(100vh - 60px);
margin: 10px 10px 10px 0;
background: lightblue;
}
footer {
background:orange;
width:100%
}
<div class="dashboard-wrapper">
<header class="header-bar cf">
<h1 class="bar-title">Brand Logo</h1>
<button class="logout-button">Log out</button>
</header>
<div class="main-wrapper cf">
<section class="side-bar">
<nav role="navigation" class="sidebar">
<ul>
<li>Navigation One</li>
<li>Navigation Two</li>
<li>Navigation Three</li>
<li>Navigation Four</li>
<li>Navigation Five</li>
</ul>
</nav>
</section>
<section class="content">
<h2>Lorem Ipsum</h2>
<p>Sed ut perspiciatis ...</p>
</section>
</div>
<footer>
Lorem Ipsum ed ut perspiciatis ...
</footer>
</div>
关于css - float/clear 突然溢出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35613529/
谁能告诉我为什么 的技术原因在 app.config 与 中无效 通常这样使用: 问题是我正在使用安装程序产品 (InstallShield) 将 xml 转换为 app.config
在Linux上,使用崇高的文本。Os.system(‘Clear’)应该只清除控制台窗口。用于Windows的os.system(‘cls’)。但它回来的时候和我不一样。。代码:。退货:。为什么在Cl
这个问题在这里已经有了答案: How can I force the STL memory cache to clear? (2 个答案) 关闭 6 年前。 我在 Solaris 10 上使用 g+
official docs关于 .clear() 我不是很清楚。他们说: Erases all AsyncStorage for all clients, libraries, etc. You pr
我有这段代码可以清除 C# WebBrowser 控件中的缓存。它的问题是它还会清除 cookie。在整个互联网上,我似乎是唯一一个不想这样的人。 我需要维护 cookie,但要丢弃缓存。 特别感兴趣
我记得直接在 DataTable 上调用的一些方法/属性之间存在差异。类,以及 DataTable.Rows 上同名的方法/属性属性(property)。 (可能是我读到这篇文章的 RowCount/
在 Unity 的 Camera组件中有一个属性清除标志,它允许从四个选项中进行选择:天空盒、纯色、仅深度和不清除。 正如文档所说: Don’t clear This mode does not cl
我无法找出为什么我的函数没有被调用。我将 alert("test") 放在那里只是为了测试函数是否被调用,而事实并非如此。 HTML: JS: function clear(price,quanti
我有 2 个数组列表: ArrayList> res= new ArrayList(); ArrayList data= new ArrayList(); 在我将结果集添加到子项并将子项附加到父项后,
正如主题所述..哪个版本更有效,为什么? std::vector a; .. a.clear(); 或 std::vector a; .. if(!a.empty()) a.clear(); 最佳
我包含了定义函数“clear()”的“PDCurses/curses.h”,然后当我使用“std::wstring::clear()”时,msvc-10.0 编译器报告错误。当我在包含后使用“#und
Session.Clear() 与 Session.Contents.Clear() 有什么区别? 我想清除所有 session 变量。 谢谢。 最佳答案 根据反射器,没有差异。 Session.Co
QPointer有一个方法, clear() . Clears this QPointer object. 我不确定“清晰”的确切含义。在我看来,这可能意味着 它会删除您引用的指针。 或 它取消附加您
在 string::clear 函数的描述中,它说: clear: Erases the contents of the string, which becomes an empty string (
我有两个不同的 Mathematica 笔记本,它们具有相似但功能不同的功能。当它们是唯一打开的笔记本时,两者都可以正常工作。尽管我(自由地)使用 Clear[] 来清除相关变量,但其中一个在另一个笔
有没有办法扩展 Symfony 2 cache:clear命令来清除 APC 还是执行一些其他逻辑? 最佳答案 您可以使用 ApcBundle去做这个。 关于php - 扩展 Symfony 2 缓存
我正在尝试使用 html 和 css 制作一个简单的信息网站,并使用 960 网格,因为该网站将具有分栏结构。 当我将标题 h1 float 到左侧(它有 Logo 图像,我正在使用 css 添加图像
我刚刚意识到: 在一系列 float div 导致布局破坏之后,同时 工作正常。 谁能解释一下? 这是 CSS: div.clear { clear:both; } 最佳答案 如果您将
这两个命令等效吗?如果不是,有什么区别? 最佳答案 rake 任务仅清除存储在文件系统 "#{Rails.root}/tmp/cache" 中的文件。这是该任务的代码。 namespace :cach
在STM32F407上初始化USART1时,我在启用TC中断时遇到了问题。一旦 USART RCC 启用,SR 中的 Tcflags就会被设置(“1”),而在启用 TC 中断之前清除该标志对我来说已经
我是一名优秀的程序员,十分优秀!