CSS的图像从div边缘伸出

时间:2012-08-13 14:39:04

标签: css

#col{
width:200px; 
float:left;
overflow:visible;
position:relative;
z-index:2;
}

<div id="col">

<img style="margin-left:-6px; z-index:999; position:relative;"  src="img.jpg" />
</div>

我希望图像向左伸出6px,但它正在切断。

此外,我必须在每行代码的字体中放置4个空格,这非常慢!

2 个答案:

答案 0 :(得分:1)

您的图片正在被截止,因为您在父div#col

上使用溢出
<div id="col">
  <img src="img.jpg" alt="some info">
</div>

CSS

#col{
width:200px; 
float:left;
position:relative;
/*overflow: visible;*// remove
/*z-index:2;*// no need to do that
}
#col img {
position: absolute;
top: 0;
left: -6px;
width: width of image in px;
height: height of image in px;
}

答案 1 :(得分:0)

这是你要找的吗?

http://jsfiddle.net/qPhba/