gpt4 book ai didi

javascript - 按钮的背景图像不会缩小

转载 作者:行者123 更新时间:2023-11-28 15:10:40 25 4
gpt4 key购买 nike

我尝试缩小按钮的背景图像,如 How to make background image shrink proportionally to fit button size in javascript? .

但它不起作用:

enter image description here

<button id="inc-fps-btn"
class="ui button"
style="height:20px;
width:20px;
background-size: 100%;
background-size: 20px auto;">
<img src="res/img/inc-btn-30.png">
</button>

其中 inc-btn-30.png 是一张 30 * 30 图片。

我看不出哪里出了问题。

最佳答案

这是您要找的吗?

试试这些方法中的任何一个

<div>
<strong>1. Make the image as button background. </strong>
</div>
<div>
<button id="inc-fps-btn" class="ui button" style="height:40px; width:40px; background: url('https://placeimg.com/131/131/nature');
background-size: cover; ">
</button>
</div>

<div>
<strong>2. Make the image in button with full size. </strong>
</div>
<div>
<button id="inc-fps-btn" class="ui button" style="height:40px;
width:40px; padding: 0;
background-size: 100%;
background-size: 20px auto;">
<img src="https://placeimg.com/131/131/nature" style="width: 100%; height: auto">
</button>
</div>

关于javascript - 按钮的背景图像不会缩小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51463612/

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