2012-06-22 41 views
3

这里是我的代码如何将图像放在div的顶部?

<div id="content_main2"> 
    <div id="content_main2_left"><img src="../images/logo.png"></div> 
</div> 

CSS

#content_main2 
{ 
    width:800px; 
    height:200px; 
} 
#content_main2_left 
{ 
    float:left; 
    width:300px; 
    height:240px; 
    margin-top:-40px; 
    -webkit-border-radius:15px; 
    -moz-border-radius:15px; 
    border-radius:15px; 
    background:#817339; 
} 

我的结果

enter image description here

BT我需要在DIV的顶部显示标志。我的意思是一半#content_main2 div和另一半#content_main2_left。我该怎么做 ?

回答

3

margin-top:-40px图像,而不是div。

0

为图像使用下面的CSS

#logoimage 
{ 
    position: absolute; 
    bottom: xxpx; 
} 

取代XX与所需的像素。

1

更好地利用

position: absolute; 

和 不同z-index两个

0

尝试添加该规则到你的样式表:

#content_main2_left img 
{ 
    position: relative; 
    left: 235px; 
} 

我感到困惑,你想怎么它虽然重叠。

1

您可以尝试使用负边距。

相关问题