【发布时间】:2014-11-04 09:07:51
【问题描述】:
我有一个 67x67 像素的图像,我想缩小到 45x45 以适应锚点,但我不知道如何调整它。我的 HTML 是:
<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。有关如何将图像缩放到该尺寸的任何建议?
感谢任何提示或指示。
【问题讨论】:
标签: javascript html css image scale