如何让背景图像显示在按钮的左边框附近?
.button1 {
background-color: transparent;
background-image: url('nebifat.png') no-repeat;
font-size: 30px;
padding-left: 64px;
text-align: left;
position: relative;
border-style: none;
height: 7%;
width: 50%;
vertical-align: middle;
margin-top: 10%;
opacity: 0.6;
}

<center>
<button id='r1' class='button1'>Matematica si Fizica</button>
</center>
&#13;
答案 0 :(得分:1)
您在no-repeat
中设置background-image
,而您可以使用background: url('...') no-repeat
或background-repeat: no-repeat
,同时center
已从网络标准中移除。您可以使用background-position
.button1 {
background-color: transparent;
background-image: url("http://placehold.it/50x50");
background-repeat: no-repeat;
font-size: 30px;
padding-left: 64px;
text-align: left;
position: relative;
border-style: none;
height: 7%;
width: 50%;
vertical-align: middle;
margin-top: 10%;
opacity: 0.6;
border: 1px solid black;
background-position: left;
}
<button id='r1' class='button1'>Matematica si Fizica</button>