好久没更新了
This commit is contained in:
52
csspress/demo/absolute.html
Normal file
52
csspress/demo/absolute.html
Normal file
@@ -0,0 +1,52 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
div {
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
}
|
||||
|
||||
.box1 {
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
background: yellow;
|
||||
margin: 20px;
|
||||
/* position:static */
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.box2 {
|
||||
background: red;
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="box1">
|
||||
<div class="box2"></div>
|
||||
</div>
|
||||
<p>
|
||||
<p> 注:这里红色的div是依据 body定位的,而不是根据父元素黄色的div 定位,</p>
|
||||
<p> 加上position static 后也是根据body 定位,</p>
|
||||
<p>当父元素的Position声明为 absolute 时,红色会依据父级黄色定位,但是会超脱文档流,影响下面的元素</p>
|
||||
|
||||
|
||||
|
||||
|
||||
</p>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
46
csspress/demo/fixed.html
Normal file
46
csspress/demo/fixed.html
Normal file
@@ -0,0 +1,46 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
body{
|
||||
overflow: auto;
|
||||
}
|
||||
.box1 {
|
||||
background: yellow;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
/* height: 50px; */
|
||||
}
|
||||
|
||||
.box2 {
|
||||
height: 20px;
|
||||
position: fixed;
|
||||
top: 30px;
|
||||
width: 100%;
|
||||
background: red;
|
||||
}
|
||||
.box3{
|
||||
width: 60px;
|
||||
height: 900px;
|
||||
background: pink;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="box1">暖暖</div>
|
||||
<div class="box2"></div>
|
||||
<div class="box3"></div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,57 +1,107 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
<style>
|
||||
*{
|
||||
margin:0;
|
||||
padding:0;
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.box{
|
||||
|
||||
.box {
|
||||
width: 1000px;
|
||||
height: 500px;
|
||||
background: pink;
|
||||
display:flex;
|
||||
display: flex;
|
||||
/* 通过display:flex来把目标元素设置成flex布局 */
|
||||
flex-direction: row;
|
||||
/* align-items: center; */
|
||||
justify-content: space-between;
|
||||
/* flex-direction 属性决定主轴的方向,值为row的时候水平排列 起点在左 */
|
||||
}
|
||||
.box1{
|
||||
|
||||
.box1 {
|
||||
width: 1000px;
|
||||
height: 500px;
|
||||
background: gold;
|
||||
display:flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
/*
|
||||
justify-content: space-between;
|
||||
justify-content: space-around;
|
||||
justify-content: space-center;
|
||||
*/
|
||||
display: flex;
|
||||
flex-direction: row-reverse;
|
||||
}
|
||||
.left,.left1{
|
||||
|
||||
.left,
|
||||
.left1 {
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
background: red;
|
||||
}
|
||||
.right,.right1{
|
||||
|
||||
.right,
|
||||
.right1 {
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
background: blue;
|
||||
}
|
||||
|
||||
.box3 {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.box4 {
|
||||
flex-direction: column-reverse;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="box">
|
||||
<div class="box" style="margin-bottom: 15px;">
|
||||
|
||||
<div class="left"></div>
|
||||
<div class="right"></div>
|
||||
<div>
|
||||
这里是flex-direction:row的状况 即水平排列 起点在左侧
|
||||
</div>
|
||||
</div>
|
||||
<div class="box">
|
||||
<div class="left"></div>
|
||||
<div class="left"></div>
|
||||
<div class="left"></div>
|
||||
<div class="left"></div>
|
||||
<div class="left"></div>
|
||||
<div class="left"></div>
|
||||
<div class="right"></div>
|
||||
<div>
|
||||
这里是flex-direction:row的状况 即水平排列 起点在左侧
|
||||
对于溢出的状况,flex-wrap 可以定义是否换行
|
||||
<P>默认属性值为 nowrap 不换行;其他属性还有wrap(换行), wrap-reverse(换行,第二行反向排列)</P>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="box1">
|
||||
<div class="left1"></div>
|
||||
|
||||
<div class="right1"></div>
|
||||
<div class="left1"></div>
|
||||
<div>
|
||||
这里是flex-direction:column的状况 即垂直排列 起点在上面
|
||||
</div>
|
||||
</div>
|
||||
<div class="box box3">
|
||||
<div class="left"></div>
|
||||
<div class="right"></div>
|
||||
<div>
|
||||
这里是flex-direction:column的状况 即垂直排列 起点在下面
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="box1 box4">
|
||||
|
||||
<div class="right1"></div>
|
||||
<div class="left1"></div>
|
||||
<div>
|
||||
这里是flex-direction:column-reverse的状况 即垂直排列 起点在下面
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
86
csspress/demo/flex1pailie.html
Normal file
86
csspress/demo/flex1pailie.html
Normal file
@@ -0,0 +1,86 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
<style>
|
||||
*{
|
||||
margin:0;
|
||||
padding:0;
|
||||
}
|
||||
.box{
|
||||
width: 1000px;
|
||||
height: 500px;
|
||||
background: pink;
|
||||
|
||||
display:flex;
|
||||
/* 通过display:flex来把目标元素设置成flex布局 */
|
||||
flex-direction: row;
|
||||
/* flex-direction 属性决定主轴的方向,值为row的时候水平排列 起点在左 */
|
||||
|
||||
justify-content: center;
|
||||
}
|
||||
.box1{
|
||||
width: 1000px;
|
||||
height: 500px;
|
||||
background: gold;
|
||||
display:flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
|
||||
}
|
||||
.left,.left1{
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
background: red;
|
||||
}
|
||||
.right,.right1{
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
background: blue;
|
||||
}
|
||||
.box3{
|
||||
justify-content: space-around;
|
||||
}
|
||||
.box4{
|
||||
flex-direction: column-reverse;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div style="margin-bottom: 50px;">
|
||||
注:以下所有实例 基于flex-direction:row的情况,即水平排列 起点在左边
|
||||
</div>
|
||||
<div class="box">
|
||||
<div class="left"></div>
|
||||
<div class="right"></div>
|
||||
|
||||
</div>
|
||||
<div style=" margin-bottom: 30px;">
|
||||
上面是 justify-content:center 居中的状况
|
||||
</div>
|
||||
|
||||
<div class="box1">
|
||||
<div class="left"></div>
|
||||
<div class="right"></div>
|
||||
|
||||
</div>
|
||||
<div style=" margin-bottom: 30px;">
|
||||
上面是 justify-content:space-between 居中的状况
|
||||
两端对齐 项目之间的间隔都相等
|
||||
</div>
|
||||
|
||||
<div class="box box3">
|
||||
<div class="left"></div>
|
||||
<div class="right"></div>
|
||||
|
||||
</div>
|
||||
<div style=" margin-bottom: 30px;">
|
||||
上面是 justify-content:space-around 居中的状况
|
||||
每个项目两侧的间隔相等 项目到边框有间距
|
||||
即两端不对齐
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
112
csspress/demo/flexjiaochazhou.html
Normal file
112
csspress/demo/flexjiaochazhou.html
Normal file
@@ -0,0 +1,112 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
<style>
|
||||
*{
|
||||
margin:0;
|
||||
padding:0;
|
||||
}
|
||||
.box{
|
||||
width: 1000px;
|
||||
height: 500px;
|
||||
background: pink;
|
||||
display:flex;
|
||||
/* 通过display:flex来把目标元素设置成flex布局 */
|
||||
flex-direction: row;
|
||||
/* flex-direction 属性决定主轴的方向,值为row的时候水平排列 起点在左 */
|
||||
|
||||
align-items: center;
|
||||
}
|
||||
.box1{
|
||||
width: 1000px;
|
||||
height: 500px;
|
||||
background: gold;
|
||||
display:flex;
|
||||
flex-direction: row;
|
||||
align-items: flex-start;
|
||||
|
||||
}
|
||||
.left,.left1{
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
background: red;
|
||||
}
|
||||
.right,.right1{
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
background: blue;
|
||||
}
|
||||
.box3{
|
||||
align-items: flex-end;
|
||||
}
|
||||
.box4{
|
||||
align-items: baseline ;
|
||||
}
|
||||
.box5{
|
||||
align-items: stretch;
|
||||
}
|
||||
.lefta{
|
||||
height:auto
|
||||
}
|
||||
.boxfin{
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div style="margin-bottom: 50px;">
|
||||
注:以下所有实例 基于flex-direction:row的情况,即水平排列 起点在左边
|
||||
且 主轴为默认
|
||||
</div>
|
||||
<div class="box">
|
||||
<div class="left"></div>
|
||||
<div class="right"></div>
|
||||
</div>
|
||||
<div style=" margin-bottom: 30px;">
|
||||
上面是 align-items:center 居中的状况
|
||||
</div>
|
||||
|
||||
<div class="box1">
|
||||
<div class="left"></div>
|
||||
<div class="right"></div>
|
||||
|
||||
</div>
|
||||
<div style=" margin-bottom: 30px;">
|
||||
上面是 align-items: flex-start; 起点在上面
|
||||
</div>
|
||||
|
||||
<div class="box box4">
|
||||
<div class="left"></div>
|
||||
<div class="right"></div>
|
||||
|
||||
</div>
|
||||
<div style=" margin-bottom: 30px;">
|
||||
上面是 align-items:base-line 项目的第一行文字的基线对齐的情况
|
||||
</div>
|
||||
|
||||
<div class="box1 box5">
|
||||
<div class="left lefta"></div>
|
||||
<div class="right lefta"></div>
|
||||
|
||||
</div>
|
||||
<div style=" margin-bottom: 30px;">
|
||||
上面是 align-items:stretch(默认值) 如果项目未设置高度或设为auto,将占满整个容器的高度。
|
||||
</div>
|
||||
|
||||
<div class="box1 boxfin">
|
||||
<div class="left"></div>
|
||||
<div class="right"></div>
|
||||
|
||||
</div>
|
||||
<div class="zong">
|
||||
总结1:flex-direction属性定义的是主轴方向,默认为水平,所以 交叉轴方向默认为垂直;
|
||||
<p>当 flex-direction的值为column的时候,align-items决定的就是垂直方向的排列方式</p>
|
||||
<b>align-items决定的是交叉轴的排列方式 而不一定是单指 垂直的排列方式</b>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,11 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
35
csspress/demo/relative.html
Normal file
35
csspress/demo/relative.html
Normal file
@@ -0,0 +1,35 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
div{
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
}
|
||||
.box1 {
|
||||
background: yellow;
|
||||
}
|
||||
|
||||
.box2 {
|
||||
background: red;
|
||||
position: relative;
|
||||
top: 20px;
|
||||
left: 30px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="box1">暖暖</div>
|
||||
<div class="box2"></div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -38,6 +38,6 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
媒体查询实现自适应
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,50 +1,35 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
<script>
|
||||
document.querySelectorAll
|
||||
</script>
|
||||
<style>
|
||||
*{
|
||||
margin:0px;
|
||||
margin:0;
|
||||
padding: 0;
|
||||
}
|
||||
html , body{
|
||||
width:100% ;
|
||||
html,
|
||||
body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.box{
|
||||
width: 100%;
|
||||
height: 60%;
|
||||
border: 1px solid black;
|
||||
}
|
||||
.content{
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
width: 30%;
|
||||
height: 30%;
|
||||
background: pink;
|
||||
margin: 30px;
|
||||
}
|
||||
/* @media (max-width: 780px) {
|
||||
.box{
|
||||
width: 600px;
|
||||
}
|
||||
.content{
|
||||
background: skyblue;
|
||||
}
|
||||
}
|
||||
@media (max-width: 600px) {
|
||||
.box{
|
||||
width: 500px;
|
||||
}
|
||||
.content{
|
||||
background: rgb(135, 235, 202);
|
||||
}
|
||||
} */
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="box">
|
||||
<!-- <div class="content"></div> -->
|
||||
</div>
|
||||
百分比实现自适应
|
||||
<div class="box"></div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user