Last active
August 14, 2017 02:01
-
-
Save Clarence-pan/d5c3922486b9b62934eb8dc203dfd472 to your computer and use it in GitHub Desktop.
左上角的促销折扣信息
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Final result: