老师,我的问题是“CSS网页基础布局”中的2-12编程练习。
来源:2-12 编程练习
慕斯0469344
2019-06-19 15:42:04
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>2-10</title>
<style type="text/css">
/*此处写代码*/
body,h2{
padding:0;
margin:0;
}
.box{
width:100%;
height: auto;
background: #fff;
}
.container{
width: 100%;
height:100px;
position: absolute;
background: black;
}
.img{
float:left;
cursor:pointer;
}
.nav{
list-style: none;
width:600px;
cursor: pointer;
float: right;
font-family: "Microsoft Yahei";
font-size: 22px;
color:#fff;
line-height: 100px;
position: absolute;
top:50%;
left: 60%;
margin-top: -50px;
margin-left: 0px;
}
.nav li{
float: left;
}
.content{
width:100%;
height: 1000px;
background: #ccffff;
margin:0 auto;
}
.left{
width:40%;
font-family: "Microsoft Yahei";
height: 1000px;
position: absolute;
top:200px;
left:200px;
float: left;
}
.left h2{
font-family: "Microsoft Yahei";
}
.right{
width:30%;
height: 1000px;
position: absolute;
top:200px;
left:600px;
float: left;
}
.right h2{
font-family: "Microsoft Yahei";
}
.color{
color:orange;
}
.middle{
width: 30%;
height: 1000px;
top:200px;
left:1000px;
float:right;
position: absolute;
top:200px;
font-family: "Microsoft Yahei";
}
.middle .color1{
}
.middle p{
width:158px;
height: 30px;
background-color: rgb(255,0,0);
text-align: center;
color:#fff;
font-family: "Microsoft Yahei";
line-height: 30px;
}
.footer{
width: 100%;
height: 100px;
background: black;
}
.list-1{
list-style:none;
width: 800px;
height: 100px;
margin:0 auto;
line-height: 100px;
color:#fff;
font-size: 22px;
font-family: "Microsoft Yahei";
cursor: pointer;
position: absolute;
left: 20%;
}
.list-1 li{
float: left;
}
</style>
</head>
<body>
<div class="box">
<div class="container">
<img src="http://climg.mukewang.com/58c0d2d900016ce303000100.png" class="img">
<ul class="nav">
<li>课程 </li>
<li>职业路径 </li>
<li>实战 </li>
<li>猿问 </li>
<li>手记 </li>
</ul>
</div>
<div class="content">
<div class="left">
<h2>课程推荐</h2>
<p><span class="color">职业路径</span> HTML5与CSS3实现动态页面</p>
<p><span class="color">职业路径</span> 零基础入门Android语法与界面</p>
<p><span class="color">职业路径</span> iOS基础语法与常用控件</p>
<p><span class="color">职业路径</span> PHP入门开发</p>
<p><span class="color">职业路径 </span>JAVA入门开发</p>
</div>
<div class="right">
<h2>相关课程</h2>
<p><span>HTML</span> <span>CSS</span> <span>JavaScript</span></p>
<p><span>HTML</span> <span>CSS3</span> <span>Jquery</span></p>
<p><span>移动端基础</span> <span>移动端APP开发</span></p>
</div>
<div class="middle">
<h2>登录</h2>
<form>
<table>
<tr>
<td><input type="text" name="text" placeholder="请输入登录邮箱/手机号"></td>
</tr>
<tr>
<td><input type="text" name="text" placeholder="6-16位密码,区分大小写,不能用空格"></td>
</tr>
</table>
</form>
<p><span>登录</span></p>
</div>
</div>
<div class="footer">
<ul class="list-1">
<li>网站首页 </li>
<li>企业合作 </li>
<li>人才招聘 </li>
<li>联系我们 </li>
<li>常见问题 </li>
<li>友情链接 </li>
</ul>
</div>
</div>
</body>
</html>我的问题是:1:我无法用“表单”属性将“登录”设置为老师做的那种效果。2:我的前两个表单元素里面的“placeholder”值,在表单里没显示完全,这个也不像老师做好的那种效果。
1回答
你好,代码中的问题:
1、登录按钮可以使用type类型为submit的input框进行设置,然后所有输入框可以用css设置样式,参考:


2、中间分布有些集中:

右侧空白部分比左侧多,可以调整一下宽度。
3、底部有空白:

是因为中间部分left,right和middle部分设置高度有些大了,将设置了1000px的高度去掉即可。
4、底部导航项整体没有水平居中显示:

可以将添加的间隙去掉,li元素设置成内联元素显示在一行,参考:


可以重新修改测试下,祝学习愉快!
相似问题