练习2-9,老师请问怎么样让文字居中呢
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
*{
margin: 0px;
padding: 0px;
}
.pilot{
background: black;color: #fff;
width: 100%;height: 100px;
position: fixed;
}
.logo{
float: left;
}
.guidance{
float: right;
list-style: none;
}
.guidance li{
list-style: none;
float: left;
line-height: 100px;
font-size: 20px;
text-align: center;
width: 100px;
}
.middle{
width: 100%;height: 1000px;margin: 0 auto;
}
.left{ width: 50%;height: 1000px;background: #B0E0E6; float: left;padding-top: 300px;}
.right{ width: 50%;height: 1000px;background: #B0E0E6; float: right;padding-top: 300px;}
.title1{
font-size: 30px;
font-weight: bold;
}
.title2{
font-size: 30px;
font-weight: bold;
}
.foot{
background: black;color: #fff;
width:100%;height: 100px;bottom: 0;
line-height: 100px;
position: fixed;
text-align: center;
}
.foot li{
display: inline-block;
list-style: none;
line-height: 100px;
text-align: center;
width: 100px;
}
img{
display: block;
width: 100%;
background-size:100% 100%;
}
a:link,a:visited,a:hover,a:active{
text-decoration: none;
color:#fff;
}
</style>
</head>
<body>
<div class="pilot">
<div class="logo">
<a href="#"><img src="http://img1.sycdn.imooc.com/climg//58c0d2d900016ce303000100.png" alt=""></a>
</div>
<div class="guidance">
<ul>
<a href="#"><li>课程</li></a>
<a href="#"><li>职业路径</li></a>
<a href="#"><li>实战</li></a>
<a href="#"><li>员问</li></a>
<a href="#"><li>手记</li></a>
</ul>
</div>
</div>
<div class="middle">
<div class="left">
<div class="title1"><span>课程推荐</span></div>
<div class="job"><span class="pink">职业路径 </span>HTML5与CSS3实现动态网页</div>
<div class="job"><span class="pink">职业路径 </span>零基础入门Android课程</div>
<div class="job"><span class="pink">职业路径 </span>ios基础语法与常用插件</div>
<div class="job"><span class="pink">职业路径 </span>PHP入门开发</div>
<div class="job"><span class="pink">职业路径 </span>Java入门开发</div>
</div>
<div class="right">
<div class="title2">相关课程</div>
<div class="job">HTML CSS Jquery Javascript </div>
<div class="job">HTML5 CSS3 Jquery</div>
<div class="job">移动端基础 移动端APP开发</div>
</div>
</div>
<div class="foot">
<a href="#">
<li>企业合作</li>
</a>
<a href="#">
<li>人员找平</li>
</a>
<a href="#">
<li>详细信息</li>
</a>
<a href="#">
<li>友情链接</li>
</a>
<a href="#">
<li>回到目录</li>
</a>
</div>
</body>
</html>24
收起
正在回答
1回答
中间部分水平居中,上传代码因为中间一个左浮动,一个右浮动,个让一半,里面的内容都是左侧开始显示,可以嵌套个div控制内容的大小同时居中 ,参考如下:
html :
<div class="middle"> <div class="content"> <div class="left">...... </div> <div class="right">......</div> </div> </div>
2. 样式:
.middle{
width: 100%;height: 1000px;
background: #B0E0E6;
}
.content{
width: 60%;
margin:auto;
}
.left{ width: 50%;height: 1000px; float: left;padding-top: 300px;}
.right{ width: 50%;height: 1000px;float: right;padding-top: 300px;}希望对你有帮助 ,动手实践,加油!
前端小白入门系列课程
- 参与学习 人
- 提交作业 11218 份
- 解答问题 36712 个
从一个不会编程的小白到一个老司机是需要过程的,首先得入门,学习基础知识,然后才能进阶,最后再到精通,本专题是你走进前端世界的不二选择!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星