我感觉我的代码写得很杂很多,怎么精简下啊?
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
/*此处写代码*/
* {
margin: 0;
padding: 0;
}
body{
min-width: 1300px;
}
/*header*/
.header {
width: 100%;
height: 100px;
background: black;
}
.nav {
float: right;
height: 100px;
line-height: 100px;
}
ul {
list-style: none;
color: white;
}
.nav ul li {
float: left;
font-size: 25px;
margin-right: 50px;
cursor: pointer;
}
/*container*/
.one {
width: 50%;
height: 540px;
background: skyblue;
float: left;
border-right: 5px solid yellow;
box-sizing: border-box;
}
.left {
float: left;
width: 50%;
height: 100%;
position: relative;
}
.left ul {
width: 300px;
height: 300px;
color: black;
position: absolute;
top: 50%;
left: 50%;
margin-top: -150px;
margin-left: -150px;
}
.left li {
margin-top: 30px;
}
span {
font-weight: bold;
background: red;
}
.right {
float: right;
width: 50%;
height: 100%;
position: relative;
top: 0;
right: 0;
}
.right ul {
width: 300px;
height: 300px;
position: absolute;
color: black;
top: 50%;
right: 50%;
margin-top: -150px;
margin-right: -150px;
}
.right li {
margin-top: 30px;
}
.two {
width: 50%;
height: 540px;
background: skyblue;
float: left;
position: relative;
}
.login {
width: 300px;
height: 300px;
position: absolute;
top: 50%;
left: 10%;
margin-top: -150px;
}
input {
width: 250px;
height: 40px;
margin-top: 30px;
}
/*footer*/
.footer {
width: 100%;
height: 100px;
background: black;
clear: both;
}
p.foot {
text-align: center;
width: 100%;
margin: 0 auto;
color: white;
font-size: 1.5em;
word-spacing: 40px;
line-height: 100px;
padding-right: 0px;
}
</style>
</head>
<body>
<!-- 此处写代码 -->
<!--header-->
<div class="header">
<img src="http://img1.sycdn.imooc.com/climg//59093e9c00016ce303000100.png" />
<div class="nav">
<ul>
<li>课程</li>
<li>职业路径</li>
<li>实战</li>
<li>猿问</li>
<li>手记</li>
</ul>
</div>
</div>
<!--container-->
<div class="one">
<div class="left">
<ul>
<h2>课程推荐</h2>
<li><span>职业路径</span> HTML5与CSS3实现动态网页</li>
<li><span>职业路径</span> 零基础入门Android语法与界面</li>
<li><span>职业路径</span> IOS基础语法与常用控件</li>
<li><span>职业路径</span> PHP入门开发</li>
<li><span>职业路径</span> JAVA入门开发</li>
</ul>
</div>
<div class="right">
<ul>
<h2>相关课程</h2>
<li>HTML CSS Javascipt</li>
<li>HTML5 CSS3 Jquery</li>
<li>移动端基础 移动端APP开发</li>
</ul>
</div>
</div>
<div class="two">
<div class="login">
<h2>登录</h2>
<form>
<input type="text" name="account" placeholder="请输入登录邮箱/手机号"><br>
<input type="password" name="password" placeholder="6-16位密码,区分大小写,不能用空格"><br>
<input type="submit" name="submit" value="登录" style="background-color: red;color: #fff;">
</form>
</div>
</div>
<!--footer-->
<div class="footer">
<p class="foot">网站首页 企业合作 人才招聘 联系我们 友情链接</p>
</div>
</body>
</html>
老师能不能把你们写的完整代码贴出来,让我参考下你们是怎么布局的,用了哪些元素啊
正在回答
1、关于答案提供的问题,编码本身的灵活性很大,同样的问题,往往会有很多不同的实现方式,如果在实现的过程中遇到问题您可以在问答区提问,我们会为大家提供思路,并帮助大家查找代码中存在的错误,这个不断修正认知的过程想必也会更有帮助的。
2、页面主体的布局可以再修改下:

可以分为这4个部分,这4个部分在主体区域是独立的,通过浮动,使它们能够在一行显示,主体宽度的分布,你之前的宽度分布是两大块各50%,与效果图有出入。
3、代码的精简是需要在练习中不断的优化和积累出来的。初学时期还是多练习,掌握好相关的知识和属性,多运用,熟能生巧。
祝学习愉快!
- 参与学习 人
- 提交作业 11218 份
- 解答问题 36712 个
从一个不会编程的小白到一个老司机是需要过程的,首先得入门,学习基础知识,然后才能进阶,最后再到精通,本专题是你走进前端世界的不二选择!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星