Skip to content

Instantly share code, notes, and snippets.

@RyoSugimoto
RyoSugimoto / ellipsis.css
Created October 14, 2014 04:43
ボックスの幅を超えたテキストの省略。
.ellipsis {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
@RyoSugimoto
RyoSugimoto / liquid_2_columns
Created October 14, 2014 04:52
ブラウザのウィンドウのサイズに応じて、幅が可変する、2カラムのリキッドレイアウトだが、サイドバーの幅は常に固定させる。
<div id="container">
<!-- サイドバー(幅を固定) -->
<div id="sidebar">
</div>
<!-- メインカラム(幅可変) -->
<div id="main">
<div id="main-content">
</div>
@RyoSugimoto
RyoSugimoto / ol_counter.css
Created October 14, 2014 04:55
ol 要素のカウンターを途中から始める。
ol {
counter-reset: item 2;
}
li:before {
content: counter(item)".";
counter-increment: item;
}
@RyoSugimoto
RyoSugimoto / link.html
Created October 14, 2014 05:00
様々な役割のリンク要素。
@RyoSugimoto
RyoSugimoto / boolmark.js
Created October 14, 2014 05:10
ブックマークレットのテンプレート。
javascript: (function () {
var d = document;
if(!window.jQuery){
var s = d.createElement('script');
s.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js';
d.body.appendChild(s);
}
setTimeout(function(){
// ここに処理を書きます。
}, 1000);
@RyoSugimoto
RyoSugimoto / get_bg_position.js
Created October 14, 2014 05:21
background-positionを取得するjQueryメソッド。
;(function () {
$.fn.getBgPosition = function () {
var $elm = $(this).eq(0);
var defVal = $elm.css('background-position');
var positions = {};
if (defVal) {
var valAry = defVal.split(' ');
positions = {
x: parseInt(valAry[0], 10),
y: parseInt(valAry[1], 10)
@RyoSugimoto
RyoSugimoto / kerning.css
Last active August 29, 2015 14:10
テキストをカーニングする。
.kern {
text-rendering: optimizeLegibility;
}
@RyoSugimoto
RyoSugimoto / ua.js
Created November 23, 2014 22:37
スマートフォンかどうかを判別する。
function isSp () {
var ua = navigator.userAgent;
if (ua.indexOf('iPhone') > 0 || ua.indexOf('Android') > 0) {
return true;
} else {
return false;
}
}
var throttle = (function () {
var interval = 500; // 間引き間隔
var lastTime = new Date().getTime() - interval;
return function () {
// 最後に実行した時間から間引きしたい時間が経過していたら実行
if ((lastTime + interval) <= new Date().getTime()) {
lastTime = new Date().getTime();
// 処理
@RyoSugimoto
RyoSugimoto / add
Last active August 29, 2015 14:12
URLを「www」付きに統一する(またはその逆)。
# add www
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mysite\.com [NC]
RewriteRule (.*) http://www.mysite.com/$1 [L,R=301]