首页 > 解决方案 > Text not staying in border?

问题描述

I am making a website for a school project and i'm trying to make the height of a border fit the size of the text. however, whenever i adjust the height the text doesn't go with it and i'm not sure how to fix this. Code:

#slidercompare {
  font-size: 17px;
  font-family: sans-serif;
  border-style: solid;
  border-color: grey;
  opacity: 87%;
  position: absolute;
  top: 5px;
  right: 10px;
}
#slidercompare {
  width: 355px;
  height: 40px; /* for some reason I can't adjust the height smaller than this or else the border goes through the text. */
  color: white;
  background-color: black;
}
<html>
<head>
  <link rel="stylesheet" href="css/boardgames.css">
</head>
<body>
    <h1 id="slidercompare"><br>Chess.com (left) vs Video Chess (right)</h1>
</body>
</html>
Any ideas? Thanks

标签: htmlcss

解决方案


I inserted <br> to <h1>. Used that to seperate a thing earlier i dont need to seperate now. So, removing the <br> tag fixed the issue.


推荐阅读