代码拉取完成,页面将自动刷新
同步操作将从 doudoucode/javascript_design_patterns 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
<!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>
.containers {
display: flex;
flex-direction: row;
position: relative;
margin-left: 50px;
margin-top: 2em;
}
.box {
width: 100px;
height: 100px;
background: blue;
position: relative;
}
.box1 {
width: 100px;
height: 100px;
background: green;
position: relative;
}
.box2 {
width: 100px;
height: 100px;
background: rgb(235, 62, 10);
position: relative;
z-index: 1000;
margin-left: 100px;
}
.box2::before {
content: '';
position: absolute;
display: block;
width: 100px;
height: var(--height);
background: #FFF;
left: -50%;
top: 50%;
transform: translateY(-50%);
}
.box1::before {
content: '';
position: absolute;
display: block;
width: 100px;
height: 50px;
background: #FFF;
left: -50%;
top: 50%;
transform: translateY(-50%);
}
.box1::after {
content: '';
position: absolute;
display: block;
width: 100px;
height: 20px;
background: green;
right: -50%;
top: 50%;
transform: translateY(-50%);
}
.box::after {
content: '';
position: absolute;
display: block;
width: 100px;
height: 50px;
background: blue;
right: -50%;
top: 50%;
transform: translateY(-50%);
z-index: 1;
}
.boxs {
display: flex;
flex-direction: row;
left: 0px;
position: relative;
z-index: 111111;
transition: all 1s ease-in-out;
}
button {
width: 300px;
height: 50px;
margin: 10px 0;
margin-left: 50px;
}
</style>
</head>
<body>
<div class="containers">
<div class="boxs">
<div class="box">
</div>
</div>
<div class="box2"></div>
</div>
<button id="start">Start</button>
<script>
class Source {
constructor(el) {
this.el = el;
}
connectTo(target) {
this.el.style.left = `${target.num}px`;
target.connect();
}
}
class Target {
constructor(el) {
this.el = el;
this.num = 100;
this.height = 20;
this.el.style.cssText = `--height:${this.height}px`;
}
connect() {
this.el.style.background = "orange"
}
}
class Adapter extends Source{
constructor(el){
super(el);
this.createElement()
}
createElement(){
const div = document.createElement("div");
div.className = "box1";
this.el.append(div);
}
connectTo(target){
super.connectTo(target);
console.log("hello");
}
}
var ele = new Adapter(document.querySelector(".boxs"));
var target = new Target(document.querySelector(".box2"));
document.querySelector("#start").addEventListener("click", () => {
ele.connectTo(target);
})
</script>
</body>
</html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。