Skip to content

Instantly share code, notes, and snippets.

@YeomanYe
Last active October 16, 2017 07:20
Show Gist options
  • Save YeomanYe/828b5ec83d59d5e1ce388b3c929f8038 to your computer and use it in GitHub Desktop.
Save YeomanYe/828b5ec83d59d5e1ce388b3c929f8038 to your computer and use it in GitHub Desktop.
HTML:font ringWords
<div class="circular">
circular reasoning works because
</div>
<script>
document.querySelectorAll('.circular').forEach(function(el) {
var NS = "http://www.w3.org/2000/svg";
var xlinkNS = "http://www.w3.org/1999/xlink";
var svg = document.createElementNS(NS, "svg");
var circle = document.createElementNS(NS, "path");
var text = document.createElementNS(NS, "text");
var textPath = document.createElementNS(NS, "textPath");
svg.setAttribute("viewBox", "0 0 100 100");
circle.setAttribute("d", "M0,50 a50,50 0 1,1 0,1z");
circle.setAttribute("id", "circle");
textPath.textContent = el.textContent;
textPath.setAttributeNS(xlinkNS, "xlink:href", "#circle");
text.appendChild(textPath);
svg.appendChild(circle);
svg.appendChild(text);
el.textContent = '';
el.appendChild(svg);
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment