html - 使左对齐的 div 占据所有空间
问题描述
我想制作一个指南以在Windows command prompt
.
.bold-cli {
float: left;
padding: 20px;
margin: 20px 30px;
font-family: Arial;
font-style: italic;
font-weight: bold;
background-color: black;
color: white;
}
<div class="bold-cli">
C:\> Rundll32 %windir%\system32\dfshim.dll CleanOnlineAppCache
</div>
我希望div
只占用足够的空间来显示命令,而不是水平拉伸,所以我添加了float: left
.
问题是,这个div后面的内容不是换行,而是显示在右边。
解决方案
.bold-cli {
float: left;
padding: 20px;
margin: 20px 30px;
font-family: Arial;
font-style: italic;
font-weight: bold;
background-color: black;
color: white;
}
<p>To fix this, start a command prompt, type the following command and then press Enter.</p>
<div class="bold-cli">
C:\> Rundll32 %windir%\system32\dfshim.dll CleanOnlineAppCache
</div>
<span style="float:left;clear: both;">We have build a utility to run this command for you. <a href="https://stackoverflow.com/" style="color: #DB5523;">Click me</a></span>
推荐阅读
- arrays - 如何在 Ionic 中获取嵌套 JSON 数组的值?
- python - 脚本中的 UTF8 不匹配
- angular - 如何手动触发事件并进行更改检测?
- c# - 使用带空格的 EPPlus 工作表名称导出到 Excel
- c - 通过调用函数在 C 中打印一系列数字的值
- android - Android Studio:JavaExec:找不到或加载主类
- lua - PBKDF2 Lua 实现问题
- c# - 无法创建 x 类型的常量值,此上下文仅支持原始类型或枚举类型
- c++ - Difference Between const char[] and const char*
- javascript - ComponentdidMount 使用 React 无限运行