0%

css百宝箱

flex布局:垂直加水平居中

1
2
3
4
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;

div或img图片高度随宽度自适应

http://blog.csdn.net/zh_rey/article/details/69666232

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
.el-carousel__item{  
width: 100%;
position:relative;
z-index:2;
display: block;
}
.el-carousel__item img{
position:absolute;
top:0;
bottom:0 ;
left:0 ;
right:0 ;
width:100% ;
margin:auto ;
z-index: 1 ;
*zoom:1 ;
}
.el-carousel__item:before {
content: "";
display: inline-block;
padding-bottom: 100%;
width: 0.1px; /*必须要有数值,否则无法把高度撑起来*/
vertical-align: middle;
}
.el-carousel__container{height: 100% !important}

scss语法

https://www.sassmeister.com/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
@mixin center($width,$height)
{
width: $width;
height: $height;
position: absolute;
top: 50%;
left: 50%;
margin-top: -($height) / 2;
margin-left: -($width) / 2;
}
div
{
@include center(100px,80px);
}
p{
@include center(80,40px);
}


%spriteAll
{
bakckground:url(images/sprite.png) no-repeat;
color:blue;
}
.sprite-1
{
@extend %spriteAll;
background-position:0 -30px;
}
.sprite-2
{
@extend %spriteAll;
background-position:0 -60px;
}


$color1:red;
$color2:green;
$color3:blue;
body
{
color:$color1;
.column
{
color:$color2;
.content-title
{
color:$color3;
}
}
}

div
{
width:100px;
height:100px;
font:
{
family:Arial;
size:14px;
weight:bold;
}
}

div
{
width:(100px + 23px);
}