Skip to content

Instantly share code, notes, and snippets.

@mforando
Created March 27, 2020 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mforando/58f4f2db49fdbfa625acd6c1164cca44 to your computer and use it in GitHub Desktop.
Save mforando/58f4f2db49fdbfa625acd6c1164cca44 to your computer and use it in GitHub Desktop.
Div Diagonal Hack
license: mit
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<style>
body { margin:60px;position:fixed;top:0;right:0;bottom:0;left:0; }
.one {width:100px}
.card{
width:60px;
font-size:100px;
vertical-align:middle;
display:inline-block;
}
.cont{
position:relative;
}
.one {
display:inline-block;
height:100px;
vertical-align:middle;
top:50%;
}
.equal{
margin-left:20px;
margin-right:20px;
font-size:70px;
vertical-align:middle;
display:inline-block;
}
.one, .two {
background:linear-gradient(105deg,white 47%,black 49%, black 51%, white 53%);
}
</style>
</head>
<div class="cont">
<div class="card">A</div>
<div class="one"></div>
<div class="card">B</div>
<div class="equal">=</div>
<div class="card">C</div>
<div>
<body>
<script>
// Feel free to change or delete any of the code you see in this editor!
var svg = d3.select("body").append("svg")
.attr("width", 960)
.attr("height", 500)
svg.append("text")
.text("Edit the code below to change me!")
.attr("y", 200)
.attr("x", 120)
.attr("font-size", 36)
.attr("font-family", "monospace")
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment