gpt4 book ai didi

html - CSS:flexbox 内的按钮宽度小于内容

转载 作者:行者123 更新时间:2023-12-04 03:57:08 25 4
gpt4 key购买 nike

<分区>

这是我的代码,我简化了结构。所以我们可以重点关注buttondiv的区别我不知道为什么 button 中的文本会溢出并被裁剪。button 不会长大以适应内容,但 div 可以。(我在 Windows Chrome 上发现了这个问题,而 Firefox 似乎没问题)

我的解决方案是将 button 替换为 div。我想知道是否有人可以解释 buttondiv 之间的区别为什么div可以用同样的样式?

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.flexbox {
display: flex;
}
.btn {
display: inline-block;
background-color: #dc447d;
border: 0 solid #dc447d;
padding: 0 3%;
line-height: 1.63em;
font-size: 17.2px;
color: white;
border-radius: 5px;
white-space: nowrap;
}
</style>
</head>
<body>
<div class="flexbox">
<button class="btn">
<span>Start Free Trial</span>
</button>
</div>
<div class="flexbox">
<div class="btn">
<span>Start Free Trial</span>
</div>
</div>
</body>
</html>

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com