【发布时间】:2017-04-05 07:49:08
【问题描述】:
我想创建带有图像和居中文本的按钮,这里是一个图形示例: http://www.essenzialmenta.it/wp-content/uploads/2014/03/ytbtn-1.png
感谢您的帮助!
【问题讨论】:
我想创建带有图像和居中文本的按钮,这里是一个图形示例: http://www.essenzialmenta.it/wp-content/uploads/2014/03/ytbtn-1.png
感谢您的帮助!
【问题讨论】:
使用
background: url(yourimage.png) center center no-repeat transparent;
在带有 CSS 的按钮上设置背景图像。
Stackoverflow 上已经有回答的问题:
<input type="button">背景:How to add background image for input type="button"?<button>后台:<button> background image
.button{
background: url(http://www.essenzialmenta.it/wp-content/uploads/2014/03/ytbtn-1.png) center center no-repeat transparent;
cursor:pointer;
border: none;
padding: 100px;
}
<input type="button" name="button" value="Button" class="button"/>
【讨论】:
你可以试试,
css
.button-image{
height: 50px;
width: 75px;
background: url(your-image.jpg) center center no-repeat transparent;
border: none;
display: block;
}
html
<button class="button-image">Button Text</button>
您可以根据需要更改高度和宽度。
【讨论】: