2012-02-25 65 views
1

我正在创建一个像Twitter一样的导航栏,但我希望该栏中的一个div可以滚动显示通知或新闻,而其他栏内容将保持“原样”状态。任何建议? http://jsfiddle.net/fdezluis96/JJ29E/独立div切换

#navigation{ 
position:fixed; 
top:0; 
left:0; 
width:100%; 
padding:5px; 
color: #fff; 
height:32px; 
font-size:20px; 
background: #333; 
}​ 

这是主要的HTML代码

<div id="navigation">This is the main div static content 
    <div id="subnavigation">This is the scrolling content.</div> 
</div>​ 

谢谢!

回答

0

对于live-pin.com网站,这似乎工作:

<!-->Add "position: relative;" to have a non-statically position parent.</--> 
<div class="nav-collapse" style="position: relative;"> 

<!-->Change inline styles from "background:#fff; width:300px; overflow:auto;" to "background: #fff; border: 1px solid #fff; border-top-width:0px; border-bottom-width:0px; background: #666; border-radius: 5px; border-top-right-radius: 0px; border-top-left-radius: 0px; position: absolute; max-width: 300px;" (mostly from the fiddle, but "position: absolute" to keep it where it is and remove it from the normal document flow; removing it from the document flow is what allows it to escape its parent's containment.) </--> 
<li id="notificationss" style="background: #fff; border: 1px solid #fff; border-top-width:0px; border-bottom-width:0px; background: #666; border-radius: 5px; border-top-right-radius: 0px; border-top-left-radius: 0px; position: absolute; max-width: 300px;"> 
    dssdadsadas 
    <br>dsadsasdadssdadsadas 
    <br>dsadsasdadssdadsadas 
    <br>dsadsasdadssdadsadas 
    <br>dsadsasdadssdadsadas 
    <br>dsadsasdadssdadsadas 
    <br>dsadsasda 
</li> 
+0

http://jsfiddle.net/fdezluis96/JJ29E/2/ <---测试,不起作用。 – Luis 2012-02-25 03:02:18

+0

似乎在Chrome中为我工作:http://jsfiddle.net/JJ29E/6/除非我误解你想要的东西... – pete 2012-02-25 14:53:14

+0

不完全是我的意思,我有2节ABC,其中C = A,两者都是CSS-Same,B是滚动内容。我希望A具有一个定义的高度(24px),它保持那样,静态,因为C和A相同,它也是静态的,而且B有内容在页面中“飞行”,就像这样jsfiddle http://jsfiddle.net/fdezluis96/JJ29E/,表格示例。 – Luis 2012-02-25 15:06:30