gpt4 book ai didi

html - 根据内容/标签优化按钮宽度

转载 作者:行者123 更新时间:2023-11-28 00:09:44 26 4
gpt4 key购买 nike

下面是HTML源代码的截图,其中一个按钮占用的宽度比里面的内容多。以黄色突出显示,按钮右侧有空格。我知道它是因为多线。这是跨浏览器的预期行为吗?是否有任何解决方案可以根据内容使用宽度?

Screenshot of HTML source to demonstrate issue with button width

div {
width: 100px;
}
button {
display:inline !important;
text-align: left;
}
<div>
<button>
Testing Programs
</button>
</div>

最佳答案

通常是的,除非您定义它的最大高度。你可以尝试这样的事情。

HTML

<div class="parent-div">
<p class="text">Try to change the max width in the css or remove some of the text here</p>
</div>

CSS

.parent-div {
max-width:600px;
padding:10px;
background-color:#FFF000;
display:block;
margin: 0 auto;
}

.text {
font-size:5vw;
color:#FF00FF;
text-align:center;
}

关于html - 根据内容/标签优化按钮宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55459273/

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