2016-09-18 177 views
0

无法将按钮的图像更改为箭头,尝试了多件事但未完成工作。更改按钮的背景图像

button .arrow{ 
 
     background-image: url("http://alexoliveira.me/Hawaii/images/chevron-left.png"); 
 
     background-repeat: no-repeat; 
 
     background-position: 50% 50%; 
 
     /* put the height and width of your image here */ 
 
     height: 50px; 
 
     width: 200px; 
 
     border: none; 
 
    } 
 
    
 
    .arrows { 
 
     width: 100%; 
 
     height: 100%; 
 
     display: flex; 
 
     align-items: center; 
 
     justify-content: space-between; 
 
     position:absolute; 
 
    
 
    }
<div class="arrows"> 
 
     \t \t <button onClick="carousel(-1)" class="arrow" style="width:20px;height:40px;"></button> 
 
     \t \t <button onClick="carousel(1)" src="http://alexoliveira.me/Hawaii/images/chevron-right.png" class="arrow" style="width:20px;height:40px;"></button> 
 
     \t </div>

回答

1

只需更新你的CSS来button.arrow(删除空格)。你必须调整你的样式表然后

+0

background:url(http://alexoliveira.me/Hawaii/images/chevron-left.png)不重复50%50%透明;也许? :-) –

+0

与我使用它的图像并不相当锻炼 – Tahtoh

+0

是的,你必须选择一个适合你的宽度和高度的按钮 –