.mixin() {
box-shadow+: inset 0 0 10px #555;
}
.myclass {
.mixin();
box-shadow+: 0 0 20px black;
}
.myclass {
box-shadow: inset 0 0 10px #555, 0 0 20px black;
}
.mixin() {
transform+_: scale(2);
}
.myclass {
.mixin();
transform+_: rotate(15deg);
}
.myclass {
transform: scale(2) rotate(15deg);
}
// HTML
<div id="wrap">
<div class="inner">inner1</div>
<div class="inner">inner2</div>
</div>
#wrap {
position: relative;
width: 300px;
height: 300px;
border: 1px solid;
margin: 0 auto;
.inner {
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
margin: auto;
&:nth-child(1) {
width: 100px;
height: 100px;
}
&:nth-child(2) {
width: 50px;
height: 50px;
}
}
}
.taCenter(@width, @height) {
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
margin: auto;
width: @width;
height: @height;
}
#wrap {
position: relative;
width: 300px;
height: 300px;
margin: 0 auto;
.inner {
&:nth-child(1) {
.taCenter(100px, 100px)
}
&:nth-child(2) {
.taCenter(50px, 50px)
}
}
}
#wrap {
position: relative;
width: 300px;
height: 300px;
margin: 0 auto;
}
#wrap .inner:nth-child(1) {
// |↓-↓-重复的代码-↓-↓|
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
margin: auto;
// |↑-↑-重复的代码-↑-↑|
width: 100px;
height: 100px;
}
#wrap .inner:nth-child(2) {
// |↓-↓-重复的代码-↓-↓|
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
margin: auto;
// |↑-↑-重复的代码-↑-↑|
width: 50px;
height: 50px;
}
#wrap .inner:nth-child(1),
#wrap .inner:nth-child(2) {
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
margin: auto;
}
#wrap .inner:nth-child(1) {
width: 100px;
height: 100px;
}
#wrap .inner:nth-child(2) {
width: 50px;
height: 50px;
}
.taCenter {
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
margin: auto;
}
#wrap {
position: relative;
width: 300px;
height: 300px;
margin: 0 auto;
// 这里的意思就是会将.inner和.taCenter用逗号连接在一起,有.taCenter的样式
.inner:extend(.taCenter) {
&:nth-child(1) {
width: 100px;
height: 100px;
}
&:nth-child(2) {
width: 50px;
height: 50px;
}
}
}
// 上面说了,会用逗号连接在一起继承.taCenter的样式
// 有4个的原因是因为&:nth-child(1),&:nth-child(2)和.inner平级了,都会继承
// 这里虽然实现了但是还是不大友好,后面优化
.taCenter,
#wrap .inner,
#wrap .inner:nth-child(1),
#wrap .inner:nth-child(2) {
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
margin: auto;
}
#wrap {
position: relative;
width: 300px;
height: 300px;
margin: 0 auto;
}
#wrap .inner:nth-child(1) {
width: 100px;
height: 100px;
}
#wrap .inner:nth-child(2) {
width: 50px;
height: 50px;
}
.taCenter {
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
margin: auto;
}
#wrap {
position: relative;
width: 300px;
height: 300px;
margin: 0 auto;
.inner {
/* 将继承写在inner里面 */
&:extend(.taCenter);
&:nth-child(1) {
width: 100px;
height: 100px;
}
&:nth-child(2) {
width: 50px;
height: 50px;
}
}
}
.taCenter {
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
margin: auto;
}
// .taCenter的hover和focus状态
.taCenter:hover {
width: 20px!important;
}
.taCenter:focus {
width: 30px!important;
}
#wrap {
position: relative;
width: 300px;
height: 300px;
margin: 0 auto;
.inner {
// 加个all,继承所有的状态
&:extend(.taCenter all);
&:nth-child(1) {
width: 100px;
height: 100px;
}
&:nth-child(2) {
width: 50px;
height: 50px;
}
}
}
.taCenter,
#wrap .inner {
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
margin: auto;
}
// |↓-↓-继承了所有的状态-↓-↓|
.taCenter:hover,
#wrap .inner:hover {
width: 20px !important;
}
.taCenter:focus,
#wrap .inner:focus {
width: 30px !important;
}
// |↑-↑-继承了所有的状态-↑-↑|
#wrap {
position: relative;
width: 300px;
height: 300px;
margin: 0 auto;
}
#wrap .inner:nth-child(1) {
width: 100px;
height: 100px;
}
#wrap .inner:nth-child(2) {
width: 50px;
height: 50px;
}
此页面不支持夜间模式!
已进入夜间模式!
已进入普通模式!
搜索框不允许为空
签到成功!经验+5!芋圆币+2!
签到失败!今日已签到!
需要登录社区账号才可以进入!