简体   繁体   中英

How to give position relative to particular div

i want .ra to be position:relative to the .da .

When i give position:relative to .ra div it moves according to the parent div .

What can be the CSS please help me.

<div>
<div class="ra">hi</div>
<div></div>
</div>

<div>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
</div>
<div>
<div style="float:left;"></div>
<div class="da">....</div>
</div>
.ra
{
    position:relative;
    left:200px;
    top:450px;
    min-width:101px;
    min-height:256px;
}
.da
{
    float: left;
    width: 287px;   
    padding: 0 5px 0 15px;
}

The only way .ra could be relative to .da would be if .ra were positioned inside of .da - which is not the case. You need to modify your HTML accordingly.

HTML:

<div class="da">
    <div class="ra">
        This is relative to parent
    </div>
</div>

CSS:

.da{
    position: relative;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM