css网页制作(Hbuilder)

Aurene~ 2017-09-24 03:29:52
刚入门,老师布置的作业。做如图的样子。这是我的代码..哪儿错了?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>biaoge</title>
</head>
<body>
<style>
*{
margin: 0;
padding: 0;
}
.clear{
clear: both;
}
.box{
background: gray;
width: 800px;
margin: 0 auto;
}
.box.header{
background: greenyellow;
height: 80px;
}
.box.nav{
background: orange;
width: 50px;
}
.box.center{

}
.box.center.left{
width: 220px;
height: 590px;
background: blueviolet;
}
.box.center.right{
width: 580px;
height: 590px;
background: burlywood;
}
.box.footer{
height: 80px;
background: red;
}
</style>

<div class="box">
<div class="header">头部-header</div>
<div class="nav">导航-nav</div>
<div class="center">
<div class="left" style="float: left;"></div>
<div class="right" style="float: right;"></div>
<div style="color: red;">中间-center</div>
</div>

<div class="clear" class="box">
<div class="footer">底部-foot</div>
</div>
</div>

</body>
</html>
...全文
1648 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
StarXDer!!! 2018-11-16
  • 打赏
  • 举报
回复
最关键的一点是你代码里面.box.center.right应该之间有空格 写成.box .center .right 其他的你慢慢调吧,自己的作业还是自己完成比较好
三打不溜 2018-11-10
  • 打赏
  • 举报
回复
style标签放错位置了,要放在head标签里面
  • 打赏
  • 举报
回复
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>biaoge</title>
<style>
*{
margin: 0;
padding: 0;
}
.box{
background: gray;
width: 800px;
margin: 0 auto;
}
.header{
background: greenyellow;
height: 80px;
}
.nav{
background: orange;
height: 50px;
}
.left{
width: 220px;
height: 590px;
background: blueviolet;
float: left;
}
.right{
width: 580px;
height: 590px;
background: burlywood;
float: right;
}
.footer{
background: red;
height: 80px;
margin-top: 590px;
}
</style>
</head>
<body>
<div class="box">
    <div class="header">头部-header</div>
    <div class="nav">导航-nav</div>
    <div class="left"></div>
    <div class="right">中间-center</div>
    <div class="footer">底部-foot</div>           
</div>
</body>
</html>
不需要加太多选择器
Aurene~ 2017-09-24
  • 打赏
  • 举报
回复
引用 1 楼 qq_29594393 的回复:
中间并列的话,需要display:inline-block;

我先弄起来是这样...
在<div class="center" 后加了style="display:inline-block;width:800px;height:590px" 就成这样了..
请问具体怎么用?还是哪儿打的不对。大佬帮帮忙~
当作看不见 2017-09-24
  • 打赏
  • 举报
回复
中间并列的话,需要display:inline-block;
hongmei85 2017-09-24
  • 打赏
  • 举报
回复

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>biaoge</title>
<style>
*{
margin: 0;
padding: 0;
}
.clear{
clear: both;
}
.box{
background: gray;
width: 800px;
margin: 0 auto;
}
.box .header{
background: greenyellow;
height: 80px;
}
.box .nav{
background: orange;
height: 50px;
}
.box .center{

}
.box .center .left{
width: 220px;
height: 590px;
background: blueviolet;
}
.box .center .right{
width: 580px;
height: 590px;
background: burlywood;
}
.box .footer{
height: 80px;
background: red;
}
</style>
</head>
<body>

<div class="box">
<div class="header">头部-header</div>
<div class="nav">导航-nav</div>
<div class="center">
<div class="left" style="float: left;"></div>
<div class="right" style="float: right;">中间-center</div>
</div>

<div class="clear" class="box">
<div class="footer">底部-foot</div>
</div>
</div>

</body>
</html>

61,112

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧