cheatsheets/css-tricks.md

107 lines
1.9 KiB
Markdown
Raw Permalink Normal View History

2013-10-14 02:36:58 +00:00
---
2014-09-17 06:44:04 +00:00
title: CSS tricks
2015-11-24 04:48:01 +00:00
category: CSS
2012-07-03 08:09:36 +00:00
---
### Heading kerning pairs and ligature
2017-08-29 21:52:27 +00:00
```css
2018-05-02 01:59:19 +00:00
h1, h2, h3 {
text-rendering: optimizeLegibility;
}
2017-08-29 21:52:27 +00:00
```
2012-07-03 08:09:36 +00:00
### Native-like iOS scrolling
2017-08-29 21:52:27 +00:00
```css
-webkit-overflow-scrolling: touch;
overflow-y: auto;
```
2012-07-03 08:09:36 +00:00
### Gradient text
2017-08-29 21:52:27 +00:00
```css
background: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#333));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
```
2012-07-03 08:09:36 +00:00
### Text stroke
2017-08-29 21:52:27 +00:00
```css
-webkit-text-stroke: 3px black;
```
See: [Introducing text stroke](http://www.webkit.org/blog/85/introducing-text-stroke/)
2012-10-11 08:13:19 +00:00
### iOS Scrolling prevention
2017-08-29 21:52:27 +00:00
```css
document.ontouchstart = (e) ->
$pane = $(e.target).closest('.scrollable>div')
if $pane.length is 0 or $pane[0].scrollHeight <= $pane.innerHeight()
e.preventDefault()
```
```scss
%ios-scrollable {
&, >div {
-webkit-overflow-scrolling: touch;
overflow: auto;
}
2012-10-11 08:13:19 +00:00
2017-08-29 21:52:27 +00:00
>div {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
}
```
2012-10-11 08:13:19 +00:00
2017-08-29 21:52:27 +00:00
Relevant in iOS6, but maybe not anymore.
2012-10-11 08:13:19 +00:00
### UIWebView optimizations
2017-08-29 21:52:27 +00:00
```css
* {
-webkit-tap-highlight-color: rgba(0,0,0,0);
-webkit-user-select: none; /* disable text select */
-webkit-touch-callout: none; /* disable callout, image save panel (popup) */
-webkit-tap-highlight-color: transparent; /* "turn off" link highlight */
}
a:focus {
outline: 0; // Firefox (remove border on link click)
}
```
2012-10-11 08:13:19 +00:00
2017-08-29 21:52:27 +00:00
See: <http://www.bitsandpix.com/entry/ios-webkit-uiwebview-remove-tapclick-highlightborder-with-css/>
2012-10-11 08:13:19 +00:00
2017-08-29 21:52:27 +00:00
See: <http://www.yuiblog.com/blog/2010/10/01/quick-tip-customizing-the-mobile-safari-tap-highlight-color/>
2013-01-24 21:04:38 +00:00
Browser hacks
-------------
2017-08-29 21:52:27 +00:00
{: .-three-column}
### Disclaimer
2013-01-24 21:04:38 +00:00
2018-05-02 01:59:19 +00:00
Not recommended, but here they are if you ever need them. Note that vendor
2013-01-24 21:04:38 +00:00
prefixes may go away eventually.
### Mozilla-only
2017-08-29 21:52:27 +00:00
```css
@-moz-document url-prefix() {
.box { color: blue; }
}
```
2013-01-24 21:04:38 +00:00
### Webkit-only
2017-08-29 21:52:27 +00:00
```css
@media all and (-webkit-min-device-pixel-ratio: 1) {
}
```