我从firebase数据库检索了图片网址但是当我试图显示在网页上检索到的图片时,图片的大小没有根据我在标签中提供的规格进行调整。获得的图像覆盖整个网页背景。
JS
var myParam=location.search.split('itemKey=')[1];
alert(myParam);
firebase.database().ref('/Sell_Products/'+myParam).once('value').then(function(snapshot)
{var name=snapshot.child('name').val();
alert(name);
var image=snapshot.child('image').val();
var category=snapshot.child('category').val();
var description=snapshot.child('description').val();
var price=snapshot.child('price').val();
document.querySelector('img').src = image;
});
HTML
<img height="125" width="125"/>
答案 0 :(得分:0)
让我们试一试:<img style="height: 125px; width: 125px;"/>
答案 1 :(得分:0)
您可以在javascript中修改高度和宽度。
id
添加到您的图片代码中,例如<img id="my_image"/>
var image = document.getElementById('my_image');
image.height = '125';
image.width = '125';