html {
font-size:16px;
}
body,ul {
margin:0
}
ul {
padding-left:0;
list-style:none;
display:flex;
}
li {
flex:1;
text-align:center;
line-height:40px;
}
.layer .list {
background-color:cornsilk;
}
.list .text {
display:inline-block;
margin-left:10px;
background-color:#eee;
}
.defined-area {
margin-top:20px;
background-color:dodgerblue;
color:#fff;
font-size:18px;
text-align:center;
line-height:40px;
}
.constract {
margin-top:20px;
}
.constract .judge {
background-color:#ffb340;
}
.judge > span {
color:#fff;
font-weight:700;
}
更新时间:2020-06-01 00:13:48
说明:
1、element.prototype.closest本为浏览器自带方法,用于向上遍历(查找)最近的祖先元素。使用:
、若查询到了,返回查到的祖先元素(包括元素本身);
、否则返回null
缺点:但不兼容ie,且其匹配模式(参数)仅支持css选择器,如:".list'、'#id'、':not(#id)'等;
2、element.prototype.closestreplenish为自定方法,replenish意'补足',即对closest的完善。补足点:
、兼容ie9及以上;
、其匹配模式除了支持css选择器,还包括htmlelement、nodelist、htmlcollection、array(内为htmlelement)四类,使用更灵活、方便。