Skip to content

Instantly share code, notes, and snippets.

@iam4x
iam4x / autosizetext.coffee
Last active August 2, 2018 19:36
I wrote this simple function in CoffeeScript which tests if the text overflow the div and it will decrement his size until it fits!
autoSizeText = ->
elements = $('.resize')
return if elements.length < 0
for el in elements
do (el) ->
resizeText = ->
elNewFontSize = (parseInt($(el).css('font-size'), 10) - 1)
$(el).css('font-size', elNewFontSize)
resizeText() while el.scrollHeight > el.offsetHeight
@amolk
amolk / remove-rubber-band-web-apps-ios
Last active May 8, 2024 17:47
Remove rubberband scrolling from web apps on mobile safari (iOS)
<!DOCTYPE html>
<html>
<head>
<title>Remove rubberband scrolling from web apps on mobile safari (iOS)</title>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta id="extViewportMeta" name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<style>
html, body {margin: 0; padding: 0; overflow: hidden}