Skip to content

Instantly share code, notes, and snippets.

@ioslh
Last active October 23, 2019 06:33
Show Gist options
  • Save ioslh/c7fba82dba2913d2a6cbf903738b0212 to your computer and use it in GitHub Desktop.
Save ioslh/c7fba82dba2913d2a6cbf903738b0212 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no,viewport-fit=cover">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
.dice {
position: fixed;
width: 150px;
height: 100px;
top: 40px;
left: 160px;
background: rgba(255, 0, 0, 0.6);
color: #fff;
font-size: 10px;
}
.footer {
position: relative;
width: 100vw;
height: 150px;
background: rgba(0, 0, 255, 0.6);
color: #fff;
}
.ctrl {
position: fixed;
top: 10px;
right: 10px;
}
.header {
width: 100%;
height: 150px;
background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.1));
transition: margin-top .3s;
margin-top: 0px;
}
</style>
<script>
</script>
</head>
<body>
<div>
<div class="header"><b>A</b></div>
<div class="dice">
<b>B</b>
<pre>position: fixed;
width: 150px;
height: 100px;
top: 40px;
left: 160px;</pre>
</div>
<div class="footer"><b>C</b><pre>position: relative;
width: 100vw;
height: 150px;</pre></div>
</div>
<div class="ctrl">
<button onclick="window.location.reload()">refresh</button>
<button onclick="up()">up</button>
<button onclick="down()">down</button>
</div>
<script>
var moveNode = document.querySelector('.header')
var up = () => {
moveNode.style['margin-top'] = '-60px'
}
var down = () => {
moveNode.style['margin-top'] = '0'
}
// up()
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment