Html 被切割的比例元素
将css比例添加到img元素,并将其引至被剪切元素的左顶部 css变换原点:0;可以解决这个问题,但这不是我想要的效果Html 被切割的比例元素,html,css,Html,Css,将css比例添加到img元素,并将其引至被剪切元素的左顶部 css变换原点:0;可以解决这个问题,但这不是我想要的效果 <html> <head>scale element being cut</head> <style> .image-container { position: fixed; top: 50px; left: 50px;
<html>
<head>scale element being cut</head>
<style>
.image-container {
position: fixed;
top: 50px;
left: 50px;
width: 100px;
height: 100px;
overflow: auto;
}
img {
width: 100%;
height: 100%;
}
</style>
<body>
<div class="image-container">
<img id="image" src="https://avatars1.githubusercontent.com/u/9919?s=200&v=4" alt="">
</div>
<input type="button" onClick="scale()" value="scale image">
<script>
function scale () {
document.getElementById('image').style.transform = 'scale(2)';
}
</script>
</body>
</html>
被切割的比例元素
.图像容器{
位置:固定;
顶部:50px;
左:50px;
宽度:100px;
高度:100px;
溢出:自动;
}
img{
宽度:100%;
身高:100%;
}
功能量表(){
document.getElementById('image').style.transform='scale(2)';
}
我希望图像可以从中心变换,用户可以滚动查看缩放图像
scale
将仅对图像进行视觉缩放。等同于。您可以将宽度和高度改为200%:style.height='200%'代码>/style.width='200%'代码>缩放
将仅在视觉上缩放图像。等同于。您可以将宽度和高度改为200%:style.height='200%'代码>/style.width='200%'代码>