CircleType
How do I make an circletype?
A slight improvement on this approach: http://css-tricks.com/set-text-on-a-circle/With a little help from JS, the character widths are calculated so that you don't need to use a monospaced font.. What is a circletype? How do you make a circletype? This script and codes were developed by Peter Hrynkow on 14 September 2022, Wednesday.
CircleType - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>CircleType</title> <script src="https://s.codepen.io/assets/libs/modernizr.js" type="text/javascript"></script>
<link href='https://fonts.googleapis.com/css?family=Cinzel+Decorative' rel='stylesheet' type='text/css'> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ html,body { width: 100%; height: 100%; font: 32px/1.4 georgia, serif; letter-spacing: 0;
}
#curved1 { position: absolute; top: 32px; left: 0; width: 400px;
}
#curved2 { position: absolute; top: 32px; left: 400px; width: 400px;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <div id="curved2">Here is a small arc</div>
<div id="curved1">Here is some curved text that goes all the way around.</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/lettering.js/0.6.1/jquery.lettering.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
CircleType - Script Codes CSS Codes
html,body { width: 100%; height: 100%; font: 32px/1.4 georgia, serif; letter-spacing: 0;
}
#curved1 { position: absolute; top: 32px; left: 0; width: 400px;
}
#curved2 { position: absolute; top: 32px; left: 400px; width: 400px;
}
CircleType - Script Codes JS Codes
/* * CircleType 0.34 * Peter Hrynkow * Copyright 2013, Licensed GPL & MIT *
*/
$.fn.circleType = function(options) { var settings = { dir: 1, position: 'relative' }; if (typeof($.fn.lettering) !== 'function') { console.log('Lettering.js is required'); return; } return this.each(function () { if (options) { $.extend(settings, options); } var elem = this, delta = (180 / Math.PI), ch = parseInt($(elem).css('line-height'), 10), fs = parseInt($(elem).css('font-size'), 10), txt = elem.innerHTML.replace(/^\s+|\s+$/g, '').replace(/\s/g, ' '), letters, center; elem.innerHTML = txt $(elem).lettering(); elem.style.position = settings.position; letters = elem.getElementsByTagName('span'); center = Math.floor(letters.length / 2) var layout = function () { var tw = 0, i, offset = 0, minRadius, origin, innerRadius, l, style, r, transform; for (i = 0; i < letters.length; i++) { tw += letters[i].offsetWidth; } minRadius = (tw / Math.PI) / 2 + ch; if (settings.fluid && !settings.fitText) { settings.radius = Math.max(elem.offsetWidth / 2, minRadius); } else if (!settings.radius) { settings.radius = minRadius; } if (settings.dir === -1) { origin = 'center ' + (-settings.radius + ch) / fs + 'em'; } else { origin = 'center ' + settings.radius / fs + 'em'; } innerRadius = settings.radius - ch; for (i = 0; i < letters.length; i++) { l = letters[i]; offset += l.offsetWidth / 2 / innerRadius * delta; l.rot = offset; offset += l.offsetWidth / 2 / innerRadius * delta; } for (i = 0; i < letters.length; i++) { l = letters[i] style = l.style r = (-offset * settings.dir / 2) + l.rot * settings.dir transform = 'rotate(' + r + 'deg)'; style.position = 'absolute'; style.left = '50%'; style.marginLeft = -(l.offsetWidth / 2) / fs + 'em'; style.webkitTransform = transform; style.MozTransform = transform; style.OTransform = transform; style.msTransform = transform; style.transform = transform; style.webkitTransformOrigin = origin; style.MozTransformOrigin = origin; style.OTransformOrigin = origin; style.msTransformOrigin = origin; style.transformOrigin = origin; if(settings.dir === -1) { style.bottom = 0; } } if (settings.fitText) { if (typeof($.fn.fitText) !== 'function') { console.log('FitText.js is required when using the fitText option'); } else { $(elem).fitText(); $(window).resize(function () { updateHeight(); }); } } updateHeight(); }; var getBounds = function (elem) { var docElem = document.documentElement, box = elem.getBoundingClientRect(); return { top: box.top + window.pageYOffset - docElem.clientTop, left: box.left + window.pageXOffset - docElem.clientLeft, height: box.height }; }; var updateHeight = function () { var mid = getBounds(letters[center]), first = getBounds(letters[0]), h; if (mid.top < first.top) { h = first.top - mid.top + first.height; } else { h = mid.top - first.top + first.height; } elem.style.height = h + 'px'; } if (settings.fluid && !settings.fitText) { $(window).resize(function () { layout(); }); } if (document.readyState !== "complete") { elem.style.visibility = 'hidden'; $(window).load(function () { elem.style.visibility = 'visible'; layout(); }); } else { layout(); } });
};
$('#curved1').circleType({position: 'absolute'});
$('#curved2').circleType({position: 'absolute', dir: 1, radius: 200});

Developer | Peter Hrynkow |
Username | peterhry |
Uploaded | September 14, 2022 |
Rating | 4 |
Size | 3,535 Kb |
Views | 44,506 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Rolldown List | 3,158 Kb |
T-Shape Visualization | 3,883 Kb |
Curved type with SVG | 2,922 Kb |
CSS Starbursts | 2,605 Kb |
Dot Ripple CSS | 9,856 Kb |
CSS Button with Angled Sides | 2,338 Kb |
A Pen by Peter Hrynkow | 2,125 Kb |
Hardward Accelerate Mask Reveal | 2,083 Kb |
Cross-browser vertical centering without Javascript and almost no CSS. | 1,800 Kb |
Holographic Projection | 7,177 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Slider css only | Armandobau | 2,161 Kb |
Weird glowy CSS3 game | Toneworm | 3,684 Kb |
Birthday Party Starter | Aussieyang | 1,629 Kb |
Twinner Spinner II | Katydecorah | 2,974 Kb |
Resume | Rottingroom | 5,483 Kb |
Draggable directive | YahyaKacem | 2,277 Kb |
Placeholder support for contentEditable elements, without JavaScript | Flesler | 1,863 Kb |
Particle Motion trajectories | Sniejadlik | 5,899 Kb |
Expandable Left Side Bar with jQuery animate | Retrofuturistic | 2,483 Kb |
Sass Get Function | Lukewatts | 2,155 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!