我有一个67x67像素图像,我想缩小到45x45以适合锚点,但我不知道如何调整它。我的HTML是:如何使用JavaScript来缩放图像以适合
<a class="CompareProfilePic" id="CompareProfilePic1" href="#">
<span id="CompareProfilePicActionBtn1" class="autocenter">
</span>
</a>
我的CSS是:
a.CompareProfilePic {
height: 45px;
width: 45px;
border-radius: 50%;
float: left;
margin-right: 10px;
cursor: default !important;
}
而我的JS是:
document.getElementById('CompareProfilePic1').style.cssText = 'background-image: url(img/pic1.jpg)';
我所有的搜查,对不断变化的是什么阻碍了图像的大小,但需要保持45x45。有关如何将图像缩放到该尺寸的任何建议?
感谢您的任何提示或指针。
啊,那很完美!不能相信它是如此简单,但我无法在其他任何地方找到它。谢谢! – Scott 2014-09-10 16:23:09