前端网页学习(html)
DAY49
今日内容:
z-index属性
flex布局
响应式布局
过渡
动画
z-index属性
脱离文档流的标签,具有z-index属性,可以用来控制显示层次的优先级,值为任意的正整数
<!-- 需求1:d1,d2,d3均为box的一半大小 --> <!-- 需求2:d1左上角,d2居中,d3右下角 --> <!-- 需求3:d2区域在最上方(会覆盖d1,d3的重叠部分) --> <div class="box"> <div class="d1"></div> <div class="d2"></div> <div class="d3"></div> </div>
CSS样式
<style type="text/css"> .box { /*辅助子级进行绝对定位*/ position: relative; width: 400px; height: 400px; background-color: red; margin: 0 auto; } .d1, .d2, .d3 { width: 200px; height: 200px; position: absolute; } .d1 { background-color: orange; } .d2 { background-color: blue; top: calc(50% - 100px); left: calc(50% - 100px); } .d3 { background-color: black; right: 0; bottom: 0; } .d2 { z-index: 88888; } .d3 { z-index: 666; } </style>
flex布局
作用:能够方便的实现块的垂直居中
flex布局:意为”弹性布局”,用来为盒状模型提供最大的灵活性。
任何一个容器都可以指定为Flex布局。
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>flex布局</title> <style type="text/css"> .container