html - 被切割的比例元素
问题描述
将 css 比例添加到 img 元素导致元素的左上角被剪切
css变换原点:0 0;可以解决这个问题,但这不是我想要的显示效果
<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>
我希望图像可以从中心转换,用户可以滚动查看缩放的图像
解决方案
推荐阅读
- r - R中的线性模型不合适
- visual-studio-code - 在 VSCode 中使用 submit50
- c - 在C中沿第n维找到最大值
- r - 为什么 dplyr 无法按行生成结果?
- c - if..else 内部的指针递增问题
- html - 在角度中选择一个特定的元组
- android - LiveData 在 ViewModel 中存储时不起作用
- python - 无法在 CentOS 6.10 上编译 Python(OpenSSL 错误)
- java - org.hibernate.MappingException:实体映射中的重复列:...列:add_by(应使用 insert="false" update="false" 映射)
- mysql - 当我只有一年可用时,如何根据日期时间字段查询数据库中的行?