[英]How Do I Outline Only The Element In HTML
I have this: 我有这个:
< h1 style="position: relative; top: -103px; left: 700px; border-width: thin; border-style: dotted; border-color: grey;">
< small>Three Stars Of The Week</small>
</p>
It gives me a heading with a grey dotted line that ends way past the heading ends. 它给了我一个带有灰色虚线的标题,该标题结束了标题的末端。 It goes to the end of the page.
转到页面末尾。
How do I fix it so that the border goes only around the letters, not all the way to the end of the page? 如何解决此问题,使边框仅围绕字母,而不是一直到页面末尾?
h1
is a block-level element, so this is expected behavior. h1
是块级元素,因此这是预期的行为。 Put its content in an inline element (such as span
) and style that instead. 将其内容放入内联元素(例如
span
)中,然后对其进行样式设置。
It is obvious since <h>
(header 1 to 6) tags are block elements so it will take from the start to end of the page. 很明显,因为
<h>
(标题1到6)标记是块元素,因此它将从页面的开始到结尾。 Try using display:inline-block
. 尝试使用
display:inline-block
。 Something like this 像这样
Your CSS class 您的CSS类
.head-class{
position:relative;
top: -103px;
left: 700px;
border-width: thin;
border-style: dotted;
border-color: grey;
display:inline-block; /* style to make element as inline but block */
}
Your element 你的元素
< h1 class="head-class"><small>Three Stars Of The Week</small></h1><br>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.