我有width:100%
和overflow:hidden
我需要放置的2500-3000px
它里面的图像的父股利,但具有图像水平方向上居中(裁剪左侧和右侧),以使主中心部的图像显示在较小的屏幕上,但没有水平滚动条。
我不能使用background-image
,因为图像是通过php动态添加的。
请帮忙。中心图像水平内溢出:隐藏的div
6
A
回答
10
如果您知道图像的宽度和高度事先(即它们都是一样的),那么你可以使用旧margin
/position
招:
#myImage {
height: the image's height;
left: 50%;
margin-left: -half the image's width;
margin-top: -half the image's height;
position: relative;
top: 50%;
width: the image's width;
}
0
说myImg.jpg是100x100px:
<div style="overflow:hidden; width:100%;">
<img src="myImg.jpg" style="left: 50%; top:50%; position:relative; margin:-50px 0 0 -50px; width:100px; height:100px;" />
</div>
1
CSS:
div {background:salmon; width:100%; height:200px; overflow:hidden;}
img {left: 50%; margin-left:-1500px; position:relative;}
HTML:
<div><img src="" /></div>
相关问题
- 1. 水平展开DIV不溢出:隐藏
- 2. 使图像div水平溢出父div
- 3. div中溢出隐藏的中心图像
- 4. 隐藏html分区的水平溢出
- 5. 保持图像水平流动,隐藏溢出
- 6. 隐藏水平CSS菜单溢出
- 7. Html/CSS隐藏水平溢出
- 8. 溢出:隐藏只能水平工作
- 9. 中心李水平与内溢出的div:汽车
- 10. DIV内有溢出的DIV:隐藏?
- 11. 画布图像:中心宽图像并隐藏溢出
- 12. 滚动div内隐藏溢出div
- 13. 图像没有溢出隐藏:隐藏
- 14. 如何强制溢出:隐藏分区图像内的div?
- 15. 图像不溢出:隐藏
- 16. 允许垂直溢出,同时隐藏水平溢出
- 17. 显示DIV内容与溢出隐藏
- 18. 溢出:隐藏移动div内
- 19. 中心的图像水平
- 20. 允许图像在div中水平溢出
- 21. 如何在隐藏溢出的div中显示图像?
- 22. 中心图像垂直分区与溢出隐藏
- 23. 水平滚动溢出图像 - HTML/CSS
- 24. 水平滚动图像溢出问题
- 25. 水平中心div
- 26. 中心DIV水平
- 27. 溢出隐藏我的图像
- 28. KineticJS:隐藏溢出图层的内容
- 29. 在具有隐藏溢出的中心特定li div
- 30. 中心div里面的包装溢出隐藏