gpt4 book ai didi

html - CSS - 将按钮设置为推荐大小的 150%

转载 作者:行者123 更新时间:2023-11-27 23:22:24 25 4
gpt4 key购买 nike

我在网页上有一个 HTML 按钮,悬停时文本会变成粗体。但是,当发生这种情况时,按钮会变大,这是我不想发生的。因此,我使用了一些简单的 JavaScript 来使按钮在 document.ready 时达到其大小的 150%。但是,我试图尽量减少对 JS 的使用,那么仅在 CSS 中就可以做到这一点吗?

代码示例:

<button id="b1">Test</button>
<style>
<!-- When you hover over the button, it resizes - I want the width to become 150% what it would be on page load. -->
#b1{
float: right;
margin-left: 15px;
background-color: white;
height: 100%;
transition-duration: 0.2s;
font-weight: bold;
border: 0;
font-size: 20px;
outline: 0;
}

#b1:hover{
color: #33F;
font-size: 22px;
}
</style>

提前致谢

-- 马修

最佳答案

  .btn1{
background:#0095ff;
border:0;
outline:0;
font-weight:400;
color:#fff;
font-size: 16px;
padding: 6px 15px;
transition: all .4s ease;
cursor:pointer;
text-transform:uppercase;
}
.btn1:hover{
font-weight:600;
background:#07c;
}


.btn2{
background:#0095ff;
border:0;
outline:0;
font-weight:400;
color:#fff;
font-size: 16px;
padding: 6px 15px;
transition: all .4s ease;
cursor:pointer;
text-transform:uppercase;
min-width:150px;
}
.btn2:hover{
font-weight:600;
background:#07c;
}
    This might be the Problem :
<button class="btn1">Hello</button>

<br><br><br><br>
Solution - need to add min-width or width in button
<button class="btn2">Hello</button>

关于html - CSS - 将按钮设置为推荐大小的 150%,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40471230/

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