- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在使用来自 this answer 的一些代码关于如何将 dd
和 dt
元素对齐在同一行的问题,结果很好。
以下代码:
dl {
width: 100%;
overflow: hidden;
background:#ff0;
padding: 0;
margin: 0;
}
dt {
float: left;
text-align: right;
width: 20%;
background: #cc0;
padding: 0;
margin: 0;
font-weight: bold;
/* Question 2 */
/* font-family: monospace; */
margin-right: 10%;
}
dd {
float: left;
text-align: left;
width: 70%;
background: #dd0;
padding: 0;
margin: 0;
/* Question 1 */
/* font-family: monospace; */
}
<dl>
<dt>cat</dt><dd>small, domesticated feline</dd>
<dt>bear</dt><dd>large omnivore (top land predator)</dd>
<dt>giraffe</dt><dd>the most useless quadruped</dd>
</dl>
... 生成此图像:
但是,当我尝试将 font-family:monospace
应用于 dd
或 dt
元素时,布局会中断。
例如如果我删除 Question 1
行下面的评论,这就是我看到的:
而如果我删除 Question 2
行下面的注释,我会得到一个不那么引人注目的失败,但看起来仍然不愉快:
我想了解:
font-family: monospace
会如此扰乱布局(尤其是 dd
元素)最佳答案
原因是使用的字体行高不同。您系统的等宽字体比使用的其他字体略小。这导致 dd
和 dt
元素的高度不同。现在,在第一种情况下(dd
是等宽),第二个 dt
元素在第一个 dd
下方,因为实际上只剩下一个像素第一个 dt
的高度,因此由于 float 它被放置在那里。
如果两者都设置为等宽,它又看起来不错,因为所有元素再次具有相同的行高。
dl {
width: 100%;
overflow: hidden;
background:#ff0;
padding: 0;
margin: 0;
}
dt {
float: left;
text-align: right;
width: 20%;
background: #cc0;
padding: 0;
margin: 0;
font-weight: bold;
/* Question 2 */
font-family: monospace;
margin-right: 10%;
}
dd {
float: left;
text-align: left;
width: 70%;
background: #dd0;
padding: 0;
margin: 0;
/* Question 1 */
font-family: monospace;
}
<dl>
<dt>cat</dt><dd>small, domesticated feline</dd>
<dt>bear</dt><dd>large omnivore (top land predator)</dd>
<dt>giraffe</dt><dd>the most useless quadruped</dd>
</dl>
或者,如果您只想让两个元素之一使用等宽字体,您也可以显式设置行高:
dl {
width: 100%;
overflow: hidden;
background:#ff0;
padding: 0;
margin: 0;
}
dt {
float: left;
text-align: right;
width: 20%;
background: #cc0;
padding: 0;
margin: 0;
font-weight: bold;
/* Question 2 */
/* font-family: monospace; */
margin-right: 10%;
}
dd {
float: left;
text-align: left;
width: 70%;
background: #dd0;
padding: 0;
margin: 0;
/* Question 1 */
font-family: monospace;
}
dd, dt {
line-height: 14px;
}
<dl>
<dt>cat</dt><dd>small, domesticated feline</dd>
<dt>bear</dt><dd>large omnivore (top land predator)</dd>
<dt>giraffe</dt><dd>the most useless quadruped</dd>
</dl>
关于html - 为什么字体系列 : monospace changes the layout of my <dl>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37561760/
在normalize.css中,等宽字体规则包含 font-family: monospace, monospace; 这有什么不同 font-family: monospace; ? 一定有使用它的
我正在为计时器编写一个自定义 View ,但我无法为中间的数字获得适当的固定宽度字体。这是相关代码(来自两种不同的方法): mTextPaint = new TextPaint(Paint.ANTI_
如果我使用 font:monospace 似乎不起作用。但它适用于 font-family:monospace。font 和 font-family 有什么区别? 最佳答案 您至少需要指定 font-
正如您在下面的屏幕截图中看到的,在 Canvas 上绘制的两个长度相同的不同字符串的宽度不同。我使用的是 monospaced 字体,所以它不是 promise 以相同的宽度绘制吗?是因为字距调整吗?
我正在尝试使用系统字体并应用等宽设计,但没有运气。我可以使用自定义字体函数成功地使文本等宽,并传入 Courier 和大小,但这不是想法,因为这样字体大小是固定的。 VStack { Text
有没有办法以平台无关的方式在 Qml 中的“普通”和“等宽”之间切换 font.family? Label { font.family: "Monospace" } 目前我分别为每个平台设置字体
当在 标签中呈现文本时,我如何指定 weasyprint 应该退回到使用等宽字体? 我正在使用 weasyprint 将 HTML 文档转换为 PDF。该文档有一些我用 标记的文本。我为此文本指定
我正在尝试让等宽 asci 表工作,如下所示: tag and css font-family 这适用于除 IE8 之外的所有浏览器。 在 IE8 上,所有空格都被压缩为一个空格。 (所以列消失了)
我在 Ubuntu 15.10 上并使用 Chrome (47.0.2526.106)。据我了解,“等宽”只是使用“系统”等宽字体的指令(如不是特定字体)。在 Chrome 设置中,“固定宽度字体”设
我有一个数据库表,其中有一列类型为“文本”。 Flask-Admin 在 TextArea 字段中显示此文本并允许我对其进行编辑。但是,我希望文本以等宽字体显示。我怎样才能做到这一点? 我知道我可以通
目前,我可以使用 openCV API (putText) 将一些 HERSHEY 字体的文本插入到图像中。但是 openCV 似乎不支持任何等宽字体。 我想知道如何在图像中插入一些 Monospac
我有一种在我的 Android 应用程序中使用“等宽”的风格: true monospace @android
我正在使用来自 this answer 的一些代码关于如何将 dd 和 dt 元素对齐在同一行的问题,结果很好。 以下代码: dl { width: 100%; overflow: hi
很难说出这里问的是什么。这个问题是含糊的、模糊的、不完整的、过于宽泛的或修辞性的,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开它,visit the help center 。 已关
我正在尝试在我的个人网站上以等宽格式呈现代码。以下 CSS 样式适用于桌面浏览器(和适用于 Android 的 Firefox)没有问题,但在适用于 Android 的 Chrome 上失败: .co
Problem in screenshot 为什么?怎么修?16.10 中的 10px 太小(“p” - 10px),但 11px 太大(“p” - 12px)在 14.04 中正常字体大小 ("p"
我有以下 textarea 元素: {{default_data}} 我刚开始使用 bootstrap,但无法找到在文本区域中制作等宽文本的最佳方法。 最佳答案 将以下内容添加到
我在我的网站上使用了很多网络字体,现在我想添加新的字体系列,它有衬线/无衬线/等宽字体类型。我的 CSS 的一部分: @font-face { font-family: 'DejaVu', s
我一直在努力寻找 Java 的逻辑等宽字体背后的 TrueType 字体是什么 在 Windows XP 系统上。 原因是我在 IntelliJ Idea 10 中使用此字体作为代码编辑器的默认字体在
我想告诉浏览器使用等宽字体和无衬线字体(通常默认的等宽字体有衬线,而默认的无衬线字体不是等宽的)。除了提供我知道符合我的标准的字体列表之外,还有什么方法可以在 CSS 中指定它吗? 最佳答案 CSS
我是一名优秀的程序员,十分优秀!