Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 将3列布局转换为始终位于顶部的一列_Css_Layout_Css Position_Multiple Columns - Fatal编程技术网

Css 将3列布局转换为始终位于顶部的一列

Css 将3列布局转换为始终位于顶部的一列,css,layout,css-position,multiple-columns,Css,Layout,Css Position,Multiple Columns,我用它作为出发点。我希望其中一列在顶部始终可见。我将{position:fixed;top:0}放在右边的css列中,但这并没有达到我想要的效果。它只是让正确的栏目内容消失了 如何实现我想要的(只使用css,最好不使用javascript,至少不使用jquery) 下面是全部代码。只需从原来的2行修改 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD

我用它作为出发点。我希望其中一列在顶部始终可见。我将{position:fixed;top:0}放在右边的css列中,但这并没有达到我想要的效果。它只是让正确的栏目内容消失了

如何实现我想要的(只使用css,最好不使用javascript,至少不使用jquery)

下面是全部代码。只需从原来的2行修改

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Dynamic Drive: CSS Liquid Layout #3.2- (Fluid-Fluid-Fixed)</title>
<style type="text/css">

body{
margin:0;
padding:0;
line-height: 1.5em;
}

b{font-size: 110%;}
em{color: red;}

#topsection{
background: #EAEAEA;
height: 90px; /*Height of top section*/
}

#topsection h1{
margin: 0;
padding-top: 15px;
}

#contentwrapper{
float: left;
width: 100%;
}

#contentcolumn{
margin: 0 200px 0 25%; /*Margins for content column. Should be "0 right-column-width 0 left-column-width*/
}

#leftcolumn{
float: left;
width: 25%; /*Width of left column in percentage*/
margin-left: -100%;
background: #C8FC98;
}

#rightcolumn{
top: 0;  /* THIS IS ADDED LINE by me...... */
position: fixed; /* THIS IS ADDED LINE by me...... */
float: left;
width: 200px; /*Width of right column in pixels*/
margin-left: -200px; /*Set margin to -(RightColumnWidth)*/
background: #FDE95E;
}

#footer{
clear: left;
width: 100%;
background: black;
color: #FFF;
text-align: center;
padding: 4px 0;
}

#footer a{
color: #FFFF80;
}

.innertube{
margin: 10px; /*Margins for inner DIV inside each column (to provide padding)*/
margin-top: 0;
}

</style>

<script type="text/javascript">
/*** Temporary text filler function. Remove when deploying template. ***/
var gibberish=["This is just some filler text", "Welcome to Dynamic Drive CSS Library", "Demo content nothing to read here"]
function filltext(words){
for (var i=0; i<words; i++)
document.write(gibberish[Math.floor(Math.random()*3)]+" ")
}
</script>

</head>
<body>
<div id="maincontainer">

<div id="topsection"><div class="innertube"><h1>CSS Liquid Layout #3.2- (Fluid-Fluid-Fixed)</h1></div></div>

<div id="contentwrapper">
<div id="contentcolumn">
<div class="innertube"><b>Content Column: <em>Fluid</em></b> <script type="text/javascript">filltext(450)</script></div>
</div>
</div>

<div id="leftcolumn">
<div class="innertube"><b>Left Column: <em>25%</em></b> <script type="text/javascript">filltext(20)</script></div>

</div>

<div id="rightcolumn">
<div class="innertube"><b>Right Column: <em>200px</em></b> <script type="text/javascript">filltext(15)</script></div>
</div>

<div id="footer"><a href="http://www.dynamicdrive.com/style/">Dynamic Drive CSS Library</a></div>

</div>
</body>
</html>

动态驱动:CSS液体布局#3.2-(液体固定)
身体{
保证金:0;
填充:0;
线高:1.5em;
}
b{字体大小:110%;}
em{颜色:红色;}
#上段{
背景:#EAEAEA;
高度:90px;/*顶部高度*/
}
#上剖面h1{
保证金:0;
填充顶部:15px;
}
#内容包装器{
浮动:左;
宽度:100%;
}
#内容栏{
边距:0 200px 0 25%;/*内容列的边距。应为“0右列宽0左列宽”*/
}
#左列{
浮动:左;
宽度:25%;/*左栏宽度(百分比)*/
左边距:-100%;
背景:#C8FC98;
}
#右栏{
顶部:0;/*这是我添加的行*/
位置:固定;/*这是我添加的行*/
浮动:左;
宽度:200px;/*右列的宽度(像素)*/
左边距:-200px;/*将边距设置为-(RightColumnWidth)*/
背景#FDE95E;
}
#页脚{
清除:左;
宽度:100%;
背景:黑色;
颜色:#FFF;
文本对齐:居中;
填充:4px0;
}
#页脚a{
颜色:#FFFF80;
}
.内管{
边距:10px;/*每列内部DIV的边距(提供填充)*/
边际上限:0;
}
/***临时文本填充函数。部署模板时删除***/
var gibberish=[“这只是一些填充文本”,“欢迎使用Dynamic Drive CSS库”,“演示内容无需阅读”]
函数填充文本(单词){

对于(var i=0;i您的CSS将第三列从屏幕左侧移开,这就是它不可见的原因。 将CSS从

#rightcolumn {
   top: 0;
   position: fixed;
   float: left;
   width: 200px;
   margin-left: -200px; 
   background: #FDE95E;
}


你认为你能把不起作用的相关HTML和CSS链接给我们吗?我复制粘贴了上面的代码。我添加的行带有注释“这是我添加的行”
#rightcolumn {
   top: 0;
   position: fixed;
   width: 200px;
   right: 0;
   background: #FDE95E;
}