<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>宽度适应内容</title>
<style>
/* .news-container {
display: flex;
flex-direction: column;
align-items: start;
} */
.news-type {
background: #334e70;
padding: 5px 8px;
color: rgb(255, 255, 255, 0.8);
font-size: 1em;
border-radius: 5px;
font-weight: 400;
display: flex;
align-items: center;
/* 宽度适应内容 */
width: fit-content;
}
</style>
</head>
<body>
<div class="news-container">
<div class="news-type">
<span>更多话题</span>
<a href="">更多</a>
</div>
<div class="news-list"></div>
</div>
</body>
</html>
效果: