2014-03-26 41 views
1

是否有可能定义位置(中心),在这种情况下,图像div,在div溢出?定义位置内容Div溢出滚动

http://jsfiddle.net/KAy22/1/

#scroll-h-v { 
    width: 300px; 
    height: 300px; 
    position: relative; 
    overflow: auto; 
} 
.image { 
    text-align: center; 
    margin-left: auto; 
    margin-right: auto; 
    position: relative; 
} 

图像应在中央这样​​的负荷:

center image

回答

1

您可以用顶部和左侧位置和margin属性发挥如下

.image { 
    text-align: center; 
    margin-left: auto; 
    margin-right: auto; 
    position: relative; 
    top:50%; 
    left:50%; 
    margin-top:-500px; 
    margin-left:-500px; 
} 

http://jsfiddle.net/KAy22/2/

希望它有帮助!

+0

是的,正确的方法。但是有可能看到整个图像吗? – l00per

+0

你想缩放这样的图像吗?http://jsfiddle.net/KAy22/3/ tp占用容器的宽度 –

+0

其实像这样:http://jsfiddle.net/KAy22/1/。但我想展示部分,但想滚动整个图像。因此,图像应设置为顶部:-300像素,左侧:-300像素,但不切割图像。 – l00per