首页 > 解决方案 > 为什么标题中的文本没有填满它的框?

问题描述

我对编码比较陌生,我正在努力让文本填满方框。当我增加字体大小时 - 字体变大,紫色框也变大,所以文本总是看起来太小。

   #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;}

标签: htmlcss

解决方案


我认为您在 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>


推荐阅读