Created
July 29, 2016 21:33
-
-
Save AlbinoDrought/1aa714790deafd985937e00ee7bb47e1 to your computer and use it in GitHub Desktop.
Separate elements only if both are not empty, using only CSS
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
<html> | |
<head> | |
<style type="text/css"> | |
.s:not(:empty)+.s:not(:empty):before { | |
content: " / "; | |
} | |
</style> | |
</head> | |
<body> | |
<div> | |
<span class="s">ABC</span><span class="s">DEF</span> | |
</div> | |
<div> | |
<span class="s"></span><span class="s">DEF</span> | |
</div> | |
<div> | |
<span class="s">ABC</span><span class="s"></span> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Was refactoring some old code and noticed the "separator" generation logic seemed too complex. I knew there had to be an easier way.
This is spotty with more than two elements.