Is it possible to fix an element (div, img, p) in a div with scroll
and with position:relative
and using css only?
* Currently I reposition the div using the $('elemento').scroll()
function and calculating the scroolTop()
of the element but in IE (the worst browser in the world) there is a delay and the element is 'tremendous' so I wonder if it is possible to do this with CSS only.
HTML:
<div class="divContainer">
<div class="conteudoFixo">
<h3>Objeto Fixo</h3>
</div>
<div class="conteudoNormal">
<ul>
<li>Primeira conversa</li>
<li>Segunda conversa</li>
<li>Terceira conversa</li>
<li>Terceira conversa</li>
<li>Terceira conversa</li>
<li>Terceira conversa</li>
<li>Terceira conversa</li>
<li>Terceira conversa</li>
<li>Terceira conversa</li>
<li>Terceira conversa</li>
<li>Terceira conversa</li>
<li>Terceira conversa</li>
</ul>
</div>
</div>
CSS:
.divContainer {
height:200px;
width:300px;
position:left;
overflow:auto;
border: 1px solid #FF0000;
position: relative;
}
.conteudoFixo {
position: absolute;
top:0px;
left:0px;
background-color:#FF00FF;
width:100%;
}
Example link: link