CSS 内容总结
1.流式布局
- 流式布局,就是百分比布局,也称非固定像素布局
- 通过盒子的宽度设置成百分比来根据屏幕的宽度来进行伸缩,不受固定像素的限制,内容向两侧填充
- 流式布局方式是移动web开发使用的比较常见的布局方式
<style>
* {
padding: 0;
margin: 0;
}
.box {
width: 100%;
max-width: 820px;
min-width: 100px;
margin: 0 auto;
}
.box div {
float: left;
width: 50%;
height: 300px;
}
.box div:first-child {
background-color: rgb(243, 181, 181);
}
.box div:last-child {
background-color: rgb(181, 243, 194);
}
</style>
</head>
<body>
<div class="box">
<div></div>
<div></div>
</div>
</body>
防止里面内容塌陷可以设置最大或最小宽度
- max-width:最大宽度(max-height 最大高度)
- min-width:最小宽度(min-height 最小高度)
2.京东移动端首页制作
3.flex布局
-
flex布局体验
<style> div { display: flex; width: 500px; height: 500px; background-color: rgb(216, 37, 37); justify-content: space-around; } div span { width: 150px; height: 100px; background-color: rgb(154, 218, 235); margin-right: 5px; /* flex: 1; */ } </style> </head> <body> <div