首页 > 解决方案 > 如何更改边框宽度和高度,使其环绕文本?

问题描述

我有以下网页: 在此处输入图像描述

这是我的代码: 在此处输入图像描述

创建标题时,边框宽度标签是在<h1>标签内还是在单独的标签中?我正在尝试使边框环绕页面中间的标题文本,而不是拉伸到任一侧。

标签: htmlcssheaderborder

解决方案


使用填充和显示:inline-block;在跨度标签上。

或者这样做:

span {
    padding: 10px;
    border: 5px solid black;
    display: inline-block;
}
<span>Is this long enough? Is this long enough? Is this long enough? Is this long enough? Is this long enough? Is this long enough? Is this long enough? Is this long enough? Is this long enough? Is this long enough? </span>


推荐阅读