我从昨天开始一直在寻找解决方案,但找不到一个解决方案,或找不到合适的搜索关键字。
所以我的网站上有一个标题,就像这是一个标题,我很好地集中了它并扩展了它的背景颜色。
现在我发现了如何制作一个漂亮的交互式/光泽导航条作为页脚,但我在顶部使用它,事情是我也想扩展它的大小,但它只是居中并且不扩展。我将在截图中显示此内容并发布我的代码。
另外:我希望我的盒子居中,它包含在名为#main_inner_area的div中。
注意:Navbar仍然在CSS / HTML代码中被称为#footer ..我想扩展导航栏的两侧,就像我的标题的背景颜色扩展到全宽。 我的截图:i41 DOT tinypic DOT com SLASH 2qk6mmt.png(抱歉但很难解释没有丝网)
HTML:
<div id="main_area">
<header>
<h1>This is a header</h1>
</header>
<div id="footer">long code for layout navbar</div>
<div id="main_inner_area">
<article>d fsdf sdf sdf dsf dsf dsf</article>
</div>
</div>
CSS:
*{
padding: 0px;
margin: 0px;
}
#main_area{
background:#4863A0;
display: block;
text-align: left;
}
header {
height:100px;
background: #4863A0;
color:white;
border:none;
width:700px;
margin: 0 auto;
}
#footer{
width:700px;
top:100px;
margin:0 auto;
padding:0;
left:0;
right:0;
margin: 0 auto;
height: 40px;
border-radius:7px 7px 7px 7px;
font-family:Arial;
text-shadow: 1px 1px 1px black; /*h,v,blur,color */
/* glass effect */
border-bottom: 1px solid rgba(0,0,0,0.3);
background: rgba(0,0,0,0.5);
/*inset = inner shadow ----------- this just creates multiple shadows*/
/*top border, top white section, overlay top white, bottom*/
box-shadow: inset 0px -2px rgba(255,255,255,0.3),
inset 0px -15px 20px rgba(0,0,0,0.2),
inset 0 -10px 20px rgba(255,255,255,0.25),
inset 0 15px 30px rgba(255,255,255,0.3);
}
#main_inner_area{
float: left;
width:735px;
margin:25px 0px 10px 0px;
}
article{
background: rgba(255,255,255, 0.5);
border: 1px solid #4863A0;
margin:0px;
margin-bottom: 10px;
padding: 15px;
font-family: Tahoma;
font-size: 14px;
text-align:left;
display:block;
width:700px;
height:auto;
border-radius: 7px 7px 7px 7px;
}
P.S。我真的很感激。我是一名18岁的学生,试图在我的学习旁边学习一些额外的东西。
答案 0 :(得分:1)
要使标题动态化,只需从中删除width
属性(以及#footer aswell)。如果将其设置为固定值,则无法进行缩放。
以article
使用margin-left: auto; margin-right: auto;
更新:(拉伸导航条)
CSS更改
#footer {
width: auto;
}
#footer .links {
width: 700px;
margin: 0 auto;
}
HTML更改:
<div id="footer">
<div class="links">long code for layout navbar</div>
</div>
答案 1 :(得分:0)
我不确定你的意思&#34;延伸&#34;但是你要为所有东西设定固定的宽度和高度:
#footer {
width: 700px;
height: 40px;
...
}
尝试使用百分比而不是固定宽度来处理CSS代码中的所有内容。
width: 100%;