console
function RandomBorderColor() {
let boxes = document.getElementsByClassName('box');
for (let box of boxes) {
let r = Math.round(Math.random() * 256);
let g = Math.round(Math.random() * 256);
let b = Math.round(Math.random() * 256);
box.style.borderStyle = "solid";
box.style.borderSize = "1px";
box.style.borderColor = "rgb(" + r + "," + g + "," + b + ")";
}
}
RandomBorderColor()
<aside class="box sidebar">
侧边栏
</aside>
<main class="box content">
内容
</main>
html,
body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
* {
box-sizing: border-box;
}
.sidebar {
position: absolute;
left: 0;
top: 0;
bottom: 0;
width: 100px;
}
.content {
position: absolute;
left: 102px;
top: 0;
right: 0;
bottom: 0;
width: auto;
}