Skip to content

Instantly share code, notes, and snippets.

@Clarence-pan
Last active August 14, 2017 02:01
Show Gist options
  • Save Clarence-pan/d5c3922486b9b62934eb8dc203dfd472 to your computer and use it in GitHub Desktop.
Save Clarence-pan/d5c3922486b9b62934eb8dc203dfd472 to your computer and use it in GitHub Desktop.
左上角的促销折扣信息
<!doctype html>
<html>
<head>
<title>Product Discount On Top Left Corner</title>
<style>
.product{
border: 1px solid black;
width: 400px;
height: 300px;
position: relative;
}
.discount{
position:absolute;
color: transparent;
transform: rotate(-45deg);
top: -2.88em;
left: -2.2em;
}
.discount::before{
content: attr(data-content);
color: #fff;
position: relative;
z-index: 3;
left: 1.2em;
top: 3.7em;
}
.discount::after{
content: '';
display: block;
border: 2.4em solid black;
border-color: transparent transparent black transparent ;
width: 0;
height: 0;
position: relative;
top: -1em;
z-index: 1;
}
</style>
</head>
<body>
<div class="product">
<div class="discount" data-content="77折"></div>
</div>
</body>
</html>
@Clarence-pan
Copy link
Author

Final result:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment