Created
July 16, 2013 01:37
-
-
Save johnlouie04/6005103 to your computer and use it in GitHub Desktop.
Using content attr of psuedo elements dynamically
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
<!-- first create a div element --> | |
<div class="myClass" data-text="put the message here"><!-- You can call the data attr using content attr in css --> | |
</div> |
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
/* call you class name here */ | |
.myClass { | |
border-top: 1px solid #e1e1e1; | |
height: 1px; | |
display: block; | |
margin: 15px 0; | |
position: relative; | |
text-align: center; | |
} | |
/* now create the psuedo element of your class so that we can call the data attr here */ | |
.myClass:after { | |
content: attr(data-text);/* call the data-text attr here */ | |
color: #c0c0c0; | |
padding: 10px; | |
background: #f0f6f6; | |
display: inline-block; | |
position: relative; | |
top: -20px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment