Skip to content

Instantly share code, notes, and snippets.

@sardinecan
Last active May 3, 2019 12:09
Show Gist options
  • Save sardinecan/290cd82ca8f823785d3b95aef83571f7 to your computer and use it in GitHub Desktop.
Save sardinecan/290cd82ca8f823785d3b95aef83571f7 to your computer and use it in GitHub Desktop.
Button cross/close - pure CSS
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
button {
position:relative;
border:0;
border-radius:100%;
background-color:#d44949;
width:32px;
height:32px;
}
.delete button span {
visibility:hidden;
opacity: 1;
}
.delete button span:hover {
opacity: 1;
border:0;
}
.delete button span:before, button span:after {
position: absolute;
visibility:visible;
left: 15px;
content: ' ';
height: 15px;
width: 3px;
background-color: white;
}
.delete button span:before {
transform: rotate(45deg);
}
.delete button span:after {
transform: rotate(-45deg);
}
</style>
</head>
<body>
<span class="delete">
<button>
<span>+</span>
</button>
</span>
<script id="jsbin-source-css" type="text/css">button {
position:relative;
border:0;
border-radius:100%;
background-color:#d44949;
width:32px;
height:32px;
}
.delete button span {
visibility:hidden;
opacity: 1;
}
.delete button span:hover {
opacity: 1;
border:0;
}
.delete button span:before, button span:after {
position: absolute;
visibility:visible;
left: 15px;
content: ' ';
height: 15px;
width: 3px;
background-color: white;
}
.delete button span:before {
transform: rotate(45deg);
}
.delete button span:after {
transform: rotate(-45deg);
}
</script>
</body>
</html>
button {
position:relative;
border:0;
border-radius:100%;
background-color:#d44949;
width:32px;
height:32px;
}
.delete button span {
visibility:hidden;
opacity: 1;
}
.delete button span:hover {
opacity: 1;
border:0;
}
.delete button span:before, button span:after {
position: absolute;
visibility:visible;
left: 15px;
content: ' ';
height: 15px;
width: 3px;
background-color: white;
}
.delete button span:before {
transform: rotate(45deg);
}
.delete button span:after {
transform: rotate(-45deg);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment