自己在慕课网上看布局是全乱的,可是浏览器上显示正常

来源:5-2 编程练习

非凡哥大战哥斯拉

2018-12-29 16:04:27

<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
*{
margin: 0;
padding: 0;
font-family: "微软雅黑"
}
header{
width:100%;
height:80px;
background-color: black;
display: flex;
justify-content: space-around;
align-items: center;
}
.logo{
width:10%;
height: 100%;
align-self: auto;
}
.logo img{
display: block;
height: 100%;
}
.nav{
width:30%;
list-style: none;
display: flex;
justify-content: space-around;
color:white;
align-items: center;
}
.login{
width:10%;
display: flex;
justify-content: space-around
}
.login input{
background-color: orange;
padding: 2px 2px;
text-align: center;
color:white;
border:none;
border-radius: 5px;
cursor: pointer
}
section{
width:100%;
display: flex;
justify-content: space-around;
align-items: center;
flex-flow: row wrap;
}
.section{
width:40%;
height:15%;
background-color: lightblue;
display: flex;
justify-content: space-around;
align-items: center;
margin-top:10px;
border-radius: 10px;
}
.box{
width:70%;
height: 100%;
display:flex;
flex-direction: column;
justify-content: space-around;
margin-left:15px;
}
.shopping{
width:20%;
display: flex;
justify-content: center;
align-items: center

}
.btn{
color:white;
font-weight: bold;
border-radius: 10px;
background-color: orange;
padding:5px 5px;
cursor: pointer;
}
.btn:hover{
color:black
}
.login input:hover{
color: black
}
</style>
</head>
<body>
<!-- 头部 -->
<header>
<div class="logo">
<img src="http://climg.mukewang.com/59197ab000014f1503000100.jpg" alt="">
</div>
<ul class="nav">
<li>课程</li>
<li>路径</li>
<li>猿问</li>
<li>手记</li>
</ul>    
<div class="login">
<input type="button" value="登录">
<input type="button" value="注册">
</div>
</header>
<!-- 主体内容 -->
<section>
<div class="section">
<div class="box">
<p>《前端小白入门手册》</p>
<div>适用人群:没有任何前端基础的小白</div>
<div>费用:¥499</div>
</div>
<div class="shopping">
<div class="btn">加入购物车</div>
</div>
</div>
<div class="section">
<div class="box">
<p>《HTML5月CSS3实现动态网页》</p>
<div>适用人群:有html和css基础的童鞋</div>
<div>费用:¥599</div>
</div>
<div class="shopping">
<div class="btn">加入购物车</div>
</div>
</div>
</section>  
</body>
</html>

自己在编辑器上写好之后运行,布局是正常的,可是粘贴到慕课这里就会压缩得很乱,是flex本身就是这样还是我代码问题??

写回答

1回答

好帮手慕星星

2018-12-29

同学你好,经测试代码实现效果是可以的,顶部右侧的按钮可以再美化一下。

通过在线编辑器测试效果如下:

http://img.mukewang.com/climg/5c273a93000137ea19200544.jpg

可以将右侧的显示区域向左拖动进行查看,由于宽度比较小,所以部分内容显示不正常,在本地进行测试效果没有问题就可以。

祝学习愉快!

0

0 学习 · 5012 问题

查看课程