2
I have a div who has yours header
and its content that has a height
fixed and this has scroll.
How to put position: fixed
in the header
(where is the title), without it moving when the scroll go with the page?
Example:
HTML
<div class="main">
<div id="conversation">
<div class="header">
<h3>Título</h3>
</div>
<div class="content">
<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>
</div>
CSS
body, html{
height: 150%
}
#conversation{
width: 400px;
border: 1px solid #eee;
height: 400px;
overflow-x: hidden;
}
.header{
background: #4ECDC4;
color: #fff;
text-align: center;
height: 40px;
position: fixed;
width: 385px;
}
.content{
margin-top:35px;
}
ul{
margin: 0;
padding: 0;
}
li{
list-style: none;
padding: 20px 10px;
border-bottom: 1px solid #eee;
}
That is not the answer to your question, but it is much simpler: http://jsfiddle.net/7aQYh/1/
– Bacco
I do not believe that it is possible to solve this problem by maintaining the
position: fixed
. When using this property, you highlight the page element, and it becomes independent of any hierarchy (that is, you cannot limit it in a div). So I think @Bacco’s solution is the way.– Michael Siegwarth
Jefferson, is this what you’re looking for? http://jsfiddle.net/sF95J/
– Sergio
@Sergio, almost. The problem is that my div is not glued to the top. add for example margin-top: 100px; and test there for you to see.
– Jefferson Alison
@Jeffersonalison, okay. So just join the position of the
.main
? So? http://jsfiddle.net/r95R8/– Sergio
@Jeffersonalison you want to make chat windows in facebook style?
– Erlon Charles
@Jeffersonalison the same as I originally proposed, but with margin-top: http://jsfiddle.net/7aQYh/3/ - I took the margin of H3
– Bacco