如何使图像适应按钮大小?

时间:2016-04-20 19:22:23

标签: html css

如何使按钮的背景图像适应按钮的大小?如果我的图像是2800x1300,我怎样才能使它适应1000x540按钮?请帮助有需要的人!

3 个答案:

答案 0 :(得分:2)

真的取决于具体情况,但这可能会有所帮助:

background-size: cover

或者

background-size: contain

看看什么效果最好。

答案 1 :(得分:0)

使用:background-size:cover;

fiddle

.button {
  background: url(http://theimageconference.org/wp-content/uploads/2014/01/images-50x50.png) no-repeat;
  cursor: pointer;
  border: none;
  background-size: cover;
  width: 50px;
  height: 50px;
}
<input type="button" name="button" class="button" />

答案 2 :(得分:0)

您可以使用background-size:cover;

  

它将背景图像缩放为尽可能大   背景区域完全被背景图像覆盖。一些   部分背景图像可能不在背景中   定位区域

要了解这是如何运作的,请here

相关问题