html - 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>
解决方案
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.
推荐阅读
- python - 有没有办法有效地引用 Pandas 列中的先前值?
- javascript - 无法无限滚动以清除/删除较早加载的数据
- javascript - Exceljs 错误创建文件如果不存在
- android - 如何在 Flutter 2 中获取 snapshot.error?
- c - 将 perror(argv[0]) 替换为 stderr
- javascript - AJAX 从 PHP 文档中获取 URL
- html - 对于行/ div 中的三个项目,将图标与背景分成三部分
- pine-script - Pinscript:在条形图上绘制范围
- python - 如何通过聊天 ID 发送消息?
- dashboard - Data Studio 无法对文本求和,但我从未问过它