html - 为什么标题中的文本没有填满它的框?
问题描述
我对编码比较陌生,我正在努力让文本填满方框。当我增加字体大小时 - 字体变大,紫色框也变大,所以文本总是看起来太小。
#header {
background: #9800A3;
border-radius:10px;
border: 1px solid #84008f;
margin: 5px;
font-family: "Georgia";
text-align:center;
font-weight:bold;
font-size:3em;
font-size-adjust: auto;}
解决方案
我认为您在 html 文件中使用了 div 或 header 标记,它们都是block
元素。
您需要使其成为inline-block
元素,以便它根据内容占用宽度。
这个答案可能会帮助您更多地了解显示属性。
#header {
background: #9800A3;
border-radius: 10px;
border: 1px solid #84008f;
margin: 5px;
font-family: "Georgia";
font-weight: bold;
font-size: 3em;
font-size-adjust: auto;
display:inline-block;
}
<header id="header">abcd</header>
推荐阅读
- javascript - 尝试按喜欢的数量对帖子进行排序 mongodb
- c - 按字母顺序插入链表
- python - Python 测试不工作
- php - 使用 args 从 href 调用 PHP 函数到 zip 文件夹并下载
- r - x 和 y 数据帧之间的 left_join 函数返回的行数比 r 中的第一个数据帧多
- javascript - 有和没有 requestAnimationFrame 的鼠标拖动事件响应
- python - 如何在 Cinema4D 中使用 Python 读取大量 csv 文件?
- c# - 简单的 Web API 计算器帮助
- python - 我有一个递归函数来验证树图并需要一个返回条件
- kubernetes - 由于误导性资源过度使用消息 k8s,pod 无法在节点上调度