<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title>Culture27</title>
	<link rel="alternate" type="text/html" href="http://www.culture27.com/" />
	<link rel="self" type="application/atom+xml" href="http://www.culture27.com/atom.xml" />
	<id>tag:www.culture27.com,2011-01-16://1</id>
	<updated>2011-12-12T02:13:01Z</updated>
	
	<generator uri="http://www.sixapart.com/movabletype/">Movable Type Pro 5.04</generator>

<entry>
	<title>Sass(Scss) Memo: 出力形式 compressed - Blog</title>
	<link rel="alternate" type="text/html" href="http://www.culture27.com/blog/2011/12/sass_memo_6.php" />
	<id>tag:www.culture27.com,2011:/blog//3.18</id>

	<published>2011-12-11T13:32:35Z</published>
	<updated>2011-12-12T02:13:01Z</updated>

	<summary>Sassにはいくつかの出力形式がありますが、今回はcompressedについてで...</summary>
	<author>
		<name>kosei27</name>
		
	</author>
	
		<category term="web" scheme="http://www.sixapart.com/ns/types#category" />
	
	<category term="htmlcss" label="html-css" scheme="http://www.sixapart.com/ns/types#tag" />
	<category term="sass" label="sass" scheme="http://www.sixapart.com/ns/types#tag" />
	
	<content type="html" xml:lang="ja" xml:base="http://www.culture27.com/blog/">

		

		<![CDATA[<p>Sassには<a href="http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#output_style">いくつかの出力形式</a>がありますが、今回は<a href="http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#id17">compressed</a>についてです。<br>どのように出力されるのか見ていきます。</p>

<section>
<h2>よくありそうなスタイルの記述</h2>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre class="brush: css">
element+element {
    margin: 0.5em 0;
    padding: 0px;;;
    border: none;
    background-color: rgb(0,0,0);
    color: #ffffff; ;;

}
selector {
; // 空の宣言ブロック
}
</pre>
</div>
</figure>
<figure>
<figcaption>
CSS
</figcaption>
<div class="figContent">
<pre class="brush: css">
element + element{margin:0.5em 0;padding:0px;border:none;background-color:black;color:#ffffff}
</pre>
</div>
</figure>

<ul>
<li>余計な改行や空白は削除されます。<br>
例外として、セレクタの結合子(+ や &gt;)の前後には空白が挿入されます。</li>
<li>最後のプロパティのセミコロン(;)や余分なセミコロンが削除されます。</li>
<li>カラーコードは6桁のまま出力されます。3桁にはなりません。<br>
ただし、Mixinを通したものはどの出力形式でも条件によって出力される値が変わります。</li>
<li>rgbは可能なものはカラーコードに変換されます。</li>
<li>0pxは0にはならず、そのまま0pxで出力されます。</li>
<li>noneは0にならず、そのままnoneで出力されます。</li>
<li>0.5emは.5emにはならず、そのまま0.5emで出力されます。</li>
<li>空の宣言ブロックは出力されません。</li>
</ul>
</section>

<section>
<h2>CSS/Sassコメント</h2>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre>
selector-1 {
    margin: 0;
}
/*
 * 複数行CSSコメント
 * 複数行CSSコメント
 */
selector-2 {
    /* 1行CSSコメント */
    // Sassコメント
    padding: 0;
}
/*!
 * !付きの複数行CSSコメント
 * !付きの複数行CSSコメント
 */
selector-3 {
    /*! !付きの1行CSSコメント */
    color: red;
}
body /*! */ element {
    width: 100px;
}
</pre>
</div>
</figure>
<figure>
<figcaption>
CSS
</figcaption>
<div class="figContent">
<pre>
selector-1{margin:0}selector-2{padding:0}/*
 * !付きの複数行CSSコメント
 * !付きの複数行CSSコメント
 */selector-3{/* !付きの1行CSSコメント */;color:red}body element{width:100px}
</pre>
</div>
</figure>
<ul>
<li>CSSコメントは削除されます（Sassコメントはどのコンパイル形式でも削除されます）。</li>
<li>「/*!」から始まるCSSコメントはそのまま残ります。ただし、セレクタ部分に入れた場合は削除されます。</li>
</ul>

<p>コメント（「/*!」から始めたコメントも）が削除されるので、次に挙げるハックは使用できません。</p>

<section>
<h3>使用できないコメントを利用したハック</h3>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre>
html[xmlns] &gt; /**/body elements { property: value; }
html &gt; /**/ body elements { property: value; }
/* \*//*/ selector { property: value; } /**/
/* \*/ selector { property: value; } /**/
など
</pre>
</div>
</figure>
</section>

<p><strong>コメントの削除には例外があります。</strong>プロパティの後ろにいれたコメントは削除されないので、次に挙げるハックは使用することができます。</p>

<section>
<h3>使用できるコメントを利用したハック</h3>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre>
selector {
    color/**/: red; // IE7,8,9と他のモダンブラウザ
    color/*\**/: green\9; // IE7,8,9
}
</pre>
</div>
</figure>
<figure>
<figcaption>
CSS
</figcaption>
<div class="figContent">
<pre>
selector{color/**/:red;color/*\**/:green\9}
</pre>
</div>
</figure>
</section>

</section>

<p>ほかのハックはどうでしょうか。気になりますね。。</p>

<section>
<h2>IE6 スターハック</h2>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre>
* html element { // IE6
    color: red;
}
</pre>
</div>
</figure>
<figure>
<figcaption>
CSS
</figcaption>
<div class="figContent">
<pre>
* html element{color:red}
</pre>
</div>
</figure>
<p>問題なし。</p>
</section>

<section>
<h2>IE6 アンダースコアハック</h2>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre>
selector {
    _color: red; // IE6
}
</pre>
</div>
</figure>
<figure>
<figcaption>
CSS
</figcaption>
<div class="figContent">
<pre>
selector{_color:red}
</pre>
</div>
</figure>
<p>問題なし。</p>
</section>

<section>
<h2>IE7 スターハック</h2>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre>
*:first-child + html element { // IE7
    color: red;
}
</pre>
</div>
</figure>
<figure>
<figcaption>
CSS
</figcaption>
<div class="figContent">
<pre>
*:first-child + html element{color:red}
</pre>
</div>
</figure>
<p>問題なし。</p>
</section>

<section>
<h2>IE6,7 アスタリスクハック</h2>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre>
selector {
    *color: red; // IE6,7
}
</pre>
</div>
</figure>
<figure>
<figcaption>
CSS
</figcaption>
<div class="figContent">
<pre>
selector{*color:red}
</pre>
</div>
</figure>
<p>問題なし。</p>
</section>

<section>
<h2>IE6,7 スラッシュハック</h2>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre>
selector {
    /color: red; // IE6,7
}
</pre>
</div>
</figure>
<p>エラーになります。<br>
変数を使いましょう。でも一番早いのは / の代わりに * を使うことです。</p>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre>
$slash: "/";

selector {
    #{$slash}color: red; // IE6,7
}
</pre>
</div>
</figure>
<figure>
<figcaption>
CSS
</figcaption>
<div class="figContent">
<pre>
selector{/color:red}
</pre>
</div>
</figure>
<p>これで問題なし。</p>
</section>

<section>
<h2>IE \9ハック</h2>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre>
selector {
    color: red\9; // IE6,7,8,9 (10も??)
}
</pre>
</div>
</figure>
<figure>
<figcaption>
CSS
</figcaption>
<div class="figContent">
<pre>
selector{color:red\9}
</pre>
</div>
</figure>
<p>問題なし。</p>
</section>

<section>
<h2>IE \0/ハック</h2>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre>
selector {
    font-family: Meiryo, sans-serif\0/; // IE6,7,8,9 (10も??)
}
</pre>
</div>
</figure>

<p>エラーになります。<br>
変数を使いましょう。</p>

<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre>
$hack-ie6to9: "\0/";

selector {
    font-family: Meiryo, sans-serif#{$hack-ie6to9}; // IE6,7,8,9 (10も??)
}
</pre>
</div>
</figure>
<figure>
<figcaption>
CSS
</figcaption>
<div class="figContent">
<pre>
selector{font-family:Meiryo,sans-serif\0/}
</pre>
</div>
</figure>
<p>これで問題なし。</p>
</section>

<section>
<h2>セレクタハック 1</h2>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre>
html &gt; body element { // IE7と他のモダンブラウザ
    color: red;
}
</pre>
</div>
</figure>
<figure>
<figcaption>
CSS
</figcaption>
<div class="figContent">
<pre>
html &gt; body element{color:red}
</pre>
</div>
</figure>
<p>問題なし。</p>
</section>

<section>
<h2>セレクタハック 2</h2>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre>
html + body element { // IE7と他のモダンブラウザ
    color: red;
}
</pre>
</div>
</figure>
<figure>
<figcaption>
CSS
</figcaption>
<div class="figContent">
<pre>
html + body element{color:red}
</pre>
</div>
</figure>
<p>問題なし。</p>
</section>

<section>
<h2>Firefox moz-any-linkハック</h2>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre>
element, x:-moz-any-link {
    color: red;
}
</pre>
</div>
</figure>
<figure>
<figcaption>
CSS
</figcaption>
<div class="figContent">
<pre>
element,x:-moz-any-link{color:red}
</pre>
</div>
</figure>
<p>問題なし。</p>
</section>

<section>
<h2>WebKit mediaqueryハック</h2>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre>
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    selector {
      color: red;
    }
}
</pre>
</div>
</figure>
<figure>
<figcaption>
CSS
</figcaption>
<div class="figContent">
<pre>
@media screen and (-webkit-min-device-pixel-ratio: 0){selector{color:red}}
</pre>
</div>
</figure>
<p>問題なし。</p>
</section>

<section>
<h2>@importを使ったハック</h2>
<p>もう使うことはなさそうですが、これらのハックも使用できません。</p>
<pre>
@import'style.css'; → @import url(style.css); に整形される。
@import style.css;  → エラーになる。
など
</pre>
</section>

<section>
<h2>結論</h2>
<p>いくつかのハックが使用できなくなりますが、それ以外は特に問題なさそうです。</p>
<p>ただ、GitやSVNなどのバージョン管理ツールでのCSSの差分確認は難しくなると思いますのでご注意を。</p>
</section>
]]>
		
	</content>
</entry>

<entry>
	<title>font-familyの指定はウェイトなしのアルファベット表記のみでほぼよさそう - Blog</title>
	<link rel="alternate" type="text/html" href="http://www.culture27.com/blog/2011/12/font-family.php" />
	<id>tag:www.culture27.com,2011:/blog//3.17</id>

	<published>2011-12-03T16:12:45Z</published>
	<updated>2011-12-03T16:15:24Z</updated>

	<summary>下記のコードはフォントの指定によく使われていると思います。 font-famil...</summary>
	<author>
		<name>kosei27</name>
		
	</author>
	
		<category term="web" scheme="http://www.sixapart.com/ns/types#category" />
	
	<category term="htmlcss" label="html-css" scheme="http://www.sixapart.com/ns/types#tag" />
	
	<content type="html" xml:lang="ja" xml:base="http://www.culture27.com/blog/">

		

		<![CDATA[<p>下記のコードはフォントの指定によく使われていると思います。</p>
<figure>
<div class="figContent">
<pre class="brush: css">
font-family: 'ヒラギノ角ゴ Pro W3','Hiragino Kaku Gothic Pro','メイリオ',Meiryo,'ＭＳ Ｐゴシック','MS PGothic',sans-serif;
</pre>
</div>
</figure>
<p>同じフォントを日本語表記とアルファベット表記の両方で指定しているのは、各ブラウザの解釈や挙動が異なるなどの理由からです。ただ、最近のブラウザはどうなんだろうかとちょっと気になったので調べました。</p>
<p>結果としては下記の表になりました。詳細は<a href="/web/demo/201112_font-family/">デモページ</a>を見てください。</p>
<ul>
<li>Parallels上のWin7: IE6-8(IE6,7はIETester), Chrome15, Firefox8, Safari5, Opera11</li>
<li>Mac OS X 10.6.8: Chrome15, Firefox8, Safari5, Opera11</li>
<li>文字コード: UTF-8</li>
</ul>

<table>
<thead>
<tr>
<th rowspan="2" style="vertical-align:middle;">指定方法</th>
<th>IE</th>
<th colspan="2">Chrome</th>
<th colspan="2">Safari</th>
<th colspan="2">Firefox</th>
<th colspan="2">Opera</th>
</tr>
<tr>
<th>Win</th>
<th>Win</th><th>Mac</th>
<th>Win</th><th>Mac</th>
<th>Win</th><th>Mac</th>
<th>Win</th><th>Mac</th>
</tr>
</thead>
<tbody>
<tr>
<th>日本語表記</th>
<td>○</td>
<td>○</td><td>×</td>
<td>○</td><td>×</td>
<td>○</td><td>○</td>
<td>○</td><td>×</td>
</tr>
<tr>
<th>日本語表記（ウェイトあり）</th>
<td>-</td>
<td>-</td><td>×</td>
<td>-</td><td>×</td>
<td>-</td><td>△(*1)</td>
<td>-</td><td>×</td>
</tr>
<tr>
<th>アルファベット表記</th>
<td>○</td>
<td>○</td><td>○</td>
<td>○</td><td>○</td>
<td>○</td><td>○</td>
<td>○</td><td>△(*2)</td>
</tr>
<tr>
<th>アルファベット表記（ウェイトあり）</th>
<td>-</td>
<td>-</td><td>×</td>
<td>-</td><td>×</td>
<td>-</td><td>△(*1)</td>
<td>-</td><td>○</td>
</tr>
<tr>
<th>ポストスクリプト</th>
<td>×</td>
<td>×</td><td>×</td>
<td>×</td><td>×</td>
<td>×</td><td>×</td>
<td>×</td><td>×</td>
</tr>
<tr>
<th>ポストスクリプト（ウェイトあり）</th>
<td>-</td>
<td>-</td><td>○</td>
<td>-</td><td>○</td>
<td>-</td><td>×</td>
<td>-</td><td>×</td>
</tr>
</tbody>
</table>
<ul>
<li>*1: ウェイトは無視され、ウェイトなしのものが適用される。</li>
<li>*2: ウェイトありで指定しないと適用されないものもある。</li>
</ul>

<section class="conclusion">
<h2>まとめ</h2>
<p><strong>ウェイトなしのアルファベット表記だけ</strong>で多くのブラウザに対応できそうです。<br>問題が出るかもしれないのはMac Operaだけです。</p>
<p>記事の冒頭で挙げたコードは下記のようにすることができると思います。</p>
<pre>
font-family: 'Hiragino Kaku Gothic Pro',Meiryo,'MS PGothic',sans-serif;
</pre>
<p>Mac Operaですが、メイリオ、ＭＳ Ｐゴシックが入ってなければ、sans-serifが最後にあるのでヒラギノ角ゴ Pro W3が適用されます。もしくは、VerdanaやTahomaなどを指定すれば日本語部分はヒラギノになります...。</p>
<p>もしかすると今回の検証だけでは足りないかもしれませんが時間がないので今回はこのへんで。</p>
</section>
]]>
		
	</content>
</entry>

<entry>
	<title>iOS5なのにposition:fixed;が効かない時に確認すること - Blog</title>
	<link rel="alternate" type="text/html" href="http://www.culture27.com/blog/2011/10/ios5_position_fixed.php" />
	<id>tag:www.culture27.com,2011:/blog//3.16</id>

	<published>2011-10-26T16:37:57Z</published>
	<updated>2011-10-28T15:11:19Z</updated>

	<summary>なんだかんだでFirefoxメインで制作しているわけですが、とあるページでpos...</summary>
	<author>
		<name>kosei27</name>
		
	</author>
	
		<category term="web" scheme="http://www.sixapart.com/ns/types#category" />
	
	<category term="htmlcss" label="html-css" scheme="http://www.sixapart.com/ns/types#tag" />
	
	<content type="html" xml:lang="ja" xml:base="http://www.culture27.com/blog/">

		

		<![CDATA[<p>なんだかんだでFirefoxメインで制作しているわけですが、とあるページで<code>position:fixed;</code>が効いてないみたいだよ？と<a href="http://twitter.com/#!/e_luck">@e_luck</a>さんに教えてもらいまして、、、でちょっと調べてみて気づいたことです。</p>

<p><a href="http://www.html5rocks.com/en/tutorials/speed/html5/#toc-hardware-accell">HTML5 Rocks - Improving the Performance of your HTML5 App</a>の「The magic CSS bullet」で紹介されていた下記のコードは、指定するとGPUアクセラレーションが有効になるのでパフォーマンス向上の恩恵を受けることができるかもしれない、といったような事が言われています（アニメーションの描画がスムーズになる？）。</p>

<figure>
<figcaption>
GPUアクセラレーションを有効にするスタイル
</figcaption>
<div class="figContent">
<pre class="brush: css">
-webkit-transform: translateZ(0);
</pre>
</div>
</figure>

<p>ということで、これを<code>body</code>タグに指定してたんですが、、<code>position:fixed;</code>にならない原因はこのスタイルでした。これについてはW3CのWDに書いてありました。</p>

<div class="blockquote">
<blockquote cite="http://www.w3.org/TR/css3-3d-transforms/#introduction">
<p>The object acts as though position: relative has been specified, but also acts as a containing block for fixed positioned descendants. </p>
</blockquote>
<p class="cite"><cite><a href="http://www.w3.org/TR/css3-3d-transforms/#introduction">CSS 3D Transforms Module Level 3</a></cite></p>
</div>

<p>どおりで<code>fixed</code>を指定していた子孫要素が全部<code>relative</code>の振る舞いになっちゃってたわけですね。</p>

<p>次のデモページでは親要素に<code>-webkit-transform:translateZ(0);</code>の指定がある場合とない場合の子要素の挙動を確認できます。WebKit系のブラウザでみてください。</p>

<p class="viewDemo"><a href="/web/demo/201110_ios5_position_fixed">デモページをみる</a></p>

<p>新しいプロパティを使うときは仕様書をちゃんと読んだほうが良さそうですね...。</p>
]]>
		
	</content>
</entry>

<entry>
	<title>カフェオレ - Photo</title>
	<link rel="alternate" type="text/html" href="http://www.culture27.com/photo/2011/10/cafe_au_lait.php" />
	<id>tag:www.culture27.com,2011:/photo//2.15</id>

	<published>2011-10-23T14:36:49Z</published>
	<updated>2011-10-25T15:30:39Z</updated>

	<summary>てすと...</summary>
	<author>
		<name>kosei27</name>
		
	</author>
	
		<category term="One Day" scheme="http://www.sixapart.com/ns/types#category" />
	
	
	<content type="html" xml:lang="ja" xml:base="http://www.culture27.com/photo/">

		
			<p class="photo"><img src="/photo/images/2011/07/16-0013.jpg" alt=""></p>
		

		てすと
		
	</content>
</entry>

<entry>
	<title>Sass(Scss) Memo: @mixin - Blog</title>
	<link rel="alternate" type="text/html" href="http://www.culture27.com/blog/2011/09/sass_memo_5.php" />
	<id>tag:www.culture27.com,2011:/blog//3.14</id>

	<published>2011-09-27T14:06:07Z</published>
	<updated>2011-09-27T14:08:08Z</updated>

	<summary> 今回は@mixinについてです。 Mixinはスタイル（規則集合や宣言）を定義...</summary>
	<author>
		<name>kosei27</name>
		
	</author>
	
		<category term="web" scheme="http://www.sixapart.com/ns/types#category" />
	
	<category term="htmlcss" label="html-css" scheme="http://www.sixapart.com/ns/types#tag" />
	<category term="sass" label="sass" scheme="http://www.sixapart.com/ns/types#tag" />
	
	<content type="html" xml:lang="ja" xml:base="http://www.culture27.com/blog/">

		

		<![CDATA[

<p>今回は<a href="http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#mixins"><code>@mixin</code></a>についてです。<br>
Mixinはスタイル（規則集合や宣言）を定義し、それを再利用することができます。<br>
定義したMixinは<code>@include</code>でインクルードして使用します。また、Mixinには引数を渡すことができます。</p>

<section>
<h2>Mixinの利用例</h2>

<p>clearfix用のMixinを例に説明します。</p>
<p>まずはMixinを定義します。</p>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre class="brush: css">
@mixin <em>clearfix</em> {
    *zoom: 1;
    //
    &amp;:after {
        content: "";
        display: block;
        clear: both;
    }
}
</pre>
</div>
</figure>

<p>これをインクルードして利用します。</p>

<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre class="brush: css">
.clearfix {
    @include <em>clearfix</em>;
}
</pre>
</div>
</figure>

<p>これをコンパイルすると下記のようになります。</p>

<figure>
<figcaption>
CSS
</figcaption>
<div class="figContent">
<pre class="brush: css">
.clearfix {
  *zoom: 1;
}
.clearfix:after {
  content: "";
  display: block;
  clear: both;
}
</pre>
</div>
</figure>

<p>簡単だし、コード管理も楽ですね。</p>

<p>ただ、別のセレクタにも同じコードを適用する場合、<code>@extend</code>を利用することも検討してください。</p>

<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre class="brush: css">
.clearfix {
    @include clearfix;
}
.header {
    @extend <em>.clearfix</em>;
}
</pre>
</div>
</figure>

<p>これをコンパイルすると下記のようになります。</p>

<figure>
<figcaption>
CSS
</figcaption>
<div class="figContent">
<pre class="brush: css">
.clearfix, .header {
  *zoom: 1;
}
.clearfix:after, .header:after {
  content: "";
  display: block;
  clear: both;
}
</pre>
</div>
</figure>

<p>セレクタをグループ化して出力されるので、セレクタごとにコードが展開される<code>@mixin</code>よりも全体のコード量を減らすことができます。</p>

</section>

<section>
<h2>引数について</h2>

<p>引数はMixinの中で変数として使うことができ、CSSのプロパティやプロパティの値、<code>@if</code>の条件式などに利用することができます。</p>

<p>下記は引数を伴うMixinの例です。</p>

<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre class="brush: css">
@mixin sample-mixin(<em>$var1, $var2: margin, $var3: false</em>) {
    width: <em>$var1</em>;
    <em>#{$var2}</em>: 0;
    @if <em>$var3</em> {
        overflow: hidden;
    }
}
</pre>
</div>
</figure>

<ul>
<li>引数を複数指定する場合は<kbd>,</kbd>（カンマ）で区切ります。</li>
<li>初期値のない引数は初期値がある引数よりも必ず先に書かなければエラーになります（<code>$var1: false, $var2</code>だとエラー）。</li>
<li>初期値が指定されていない引数はインクルード時に値を指定しないとエラーになります。</li>
</ul>

<section>
<h3>インクルード時の引数の記述例</h3>
<p>前述の<code>sample-mixin</code>を例にします。</p>

<section>
<h4>Mixinの引数の順番通りに指定する</h4>
<p>単純にMixinの引数の順番通りに値を指定します。<br>
引数のキーワード（$var1や$var2など）を記述する必要がないのでタイプ数が少なくてすみます。<br>
ただ、コードを後で見返したときにMixinによっては引数の値が何なのかが分かりづらいかもしれません。</p>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre class="brush: css">
.selector {
    @include sample-mixin(<em>100px, padding, true</em>);
}
</pre>
</div>
</figure>
</section>

<section>
<h4>特定の引数だけ指定する</h4>
<p><var>$var2</var>は初期値を利用して、<var>$var3</var>の値だけ指定します。</p>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre class="brush: css">
.selector {
    @include sample-mixin(100px, <em>$var3: true</em>);
}
</pre>
</div>
</figure>
</section>

<section>
<h4>キーワードを使い、順不同で指定する</h4>
<p><var>$var3</var>を記述した後に<var>$var2</var>を記述します。<br>
引数のキーワードを記述すると引数の順番が関係なくなるようです。ただ、コードの見通しが悪くなりそうなので使わないほうが良さそうですが...。</p>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre class="brush: css">
.selector {
    @include sample-mixin(100px, <em>$var3: true, $var2: padding</em>);

    // 下記のように$var1を最後に記述してもエラーにはなりません。
    @include sample-mixin($var3: true, $var2: padding,<em> $var1: 100px</em>);
}
</pre>
</div>
</figure>
</section>

</section>

</section>

<p>Mixinを使えば作業をかなり効率化することができますが、複雑すぎると運用・管理のコストを増やしてしまう可能性があるのでバランスを考慮して利用したいですね。</p>
]]>
		
	</content>
</entry>

<entry>
	<title>Sass(Scss) Memo: @extend - Blog</title>
	<link rel="alternate" type="text/html" href="http://www.culture27.com/blog/2011/07/sass_memo_4.php" />
	<id>tag:www.culture27.com,2011:/blog//3.13</id>

	<published>2011-07-24T13:28:44Z</published>
	<updated>2011-07-24T13:32:04Z</updated>

	<summary>今回は@extendについてです。 別のセレクタの全てのスタイルを継承することが...</summary>
	<author>
		<name>kosei27</name>
		
	</author>
	
		<category term="web" scheme="http://www.sixapart.com/ns/types#category" />
	
	<category term="htmlcss" label="html-css" scheme="http://www.sixapart.com/ns/types#tag" />
	<category term="sass" label="sass" scheme="http://www.sixapart.com/ns/types#tag" />
	
	<content type="html" xml:lang="ja" xml:base="http://www.culture27.com/blog/">

		

		<![CDATA[<p>今回は<a href="http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#extend"><code>@extend</code></a>についてです。<br>
別のセレクタの全てのスタイルを継承することができます。</p>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre class="brush: css">
.borderRed {
    border: 1px solid red;
}
.selectorA {
    <em>@extend .borderRed;</em> // ここで.borderRedを継承指定
    padding: 2px;
}
</pre>
</div>
</figure>

<figure>
<figcaption>
出力結果のCSS
</figcaption>
<div class="figContent">
<pre class="brush: css">
.borderRed, <em>.selectorA</em> { /* ここに .selectorA が追加されます */
  border: 1px solid red;
}

.selectorA {
  padding: 2px;
}
</pre>
</div>
</figure>

<section>
<h2><code>@extend</code>に使用できるセレクタ</h2>
<p>1つの要素のみに関連するセレクタであればほとんど使用できます。
要素セレクタやid/classセレクタや擬似クラス、属性セレクタなども使用できますし、各セレクタを連結させたもの(<code>div#selectorA.selectorB</code>や<code>div.selectorA:first-child</code>など）も使用できます。</p>
<p>ただ、いまのところ（Sassバージョン3.1.1）は子孫／子／兄弟セレクタ（<code>E F</code>、<code>E &gt; F</code>、<code>E ~ F</code>）と隣接セレクタ（<code>E + F</code>）は使用できません。<br>
全称セレクタ（<code>*</code>）も使用できますが、使う場面はなさそうですね。</p>
<p>あと、<code>@extend .selectorA, .selectorB;</code>みたいに複数一括指定することはできないので分けて書きましょう。</p>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre class="brush: css">
.selectorA {
    @extend div;
    @extend #id;
    @extend .class;
    @extend div.class; // 要素も指定しているので、p.classがあっても継承しません
    @extend #id.class;
    @extend .class-1.class-2;
    @extend .selector:hover;
    @extend .selector[attr];
    @extend *; // これは使うことなさそうだけど...

    // ここから下はエラーになります
    @extend div .class; // E F
    @extend div &gt; .class; // E &gt; F
    @extend div + .class; // E + F
    @extend div ~ .class; // E ~ F
}
</pre>
</div>
</figure>
</section>

<p><code>@extend</code>をうまく使えば、<strong>セレクタのグループ化によってCSSのファイルサイズを減量したり、スプライト用の画像の読み込み指定をまとめてhttpリクエストを減らすこともできるのでとても便利</strong>です。</p>
<p>が、、気をつけなければいけないことがあります。</p>

<section>
<h2>気をつけること 1</h2>
<p>継承するのは<code>@extend</code>で指定したセレクタ自身のスタイルだけではなく、その子要素などのスタイルも継承するということです。</p>

<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre class="brush: css">
.selectorA {
    padding: 20px;
    border: 1px solid #333;
    //
    h2 {
        font-weight: bold;
        font-size: 20px;
    }
    p {
        color: #666;
    }
}
body.firefox .selectorA {
    padding: 10px;
}
.selectorB {
    <em>@extend .selectorA;</em> // ここで.selectorAを継承指定
    background: #eee;
    //
    h2 {
        font-size: 14px;
    }
}
</pre>
</div>
</figure>

<figure>
<figcaption>
CSS
</figcaption>
<div class="figContent">
<pre class="brush: css">
.selectorA, <em>.selectorB</em> {
  padding: 20px;
  border: 1px solid #333;
}
.selectorA h2, <em>.selectorB h2</em> { /* ここにも追加されました */
  font-size: 20px;
}
.selectorA p, <em>.selectorB p</em> { /* ここにも追加されました */
  color: #666;
}

body.firefox .selectorA, <em>body.firefox .selectorB</em> { /* ここにも追加されました */
  color: #666;
}

.selectorB {
  background: #eee;
}

.selectorB h2 {
  font-size: 14px;
}
</pre>
</div>
</figure>

<p>こういう問題があるかもしれません。</p>
<ul>
<li><code>.selectorA h2</code>は太字にしたいけど、<code>.selectorB h2</code>はスタイルリセット時に<code>font-weight: normal;</code>にしてるからそのままでよかったのに...。</li>
<li><code>.selectorB p</code>のテキストカラーは<code>body</code>で適用されてる色でよかったのに...。</li>
<li><code>body.firefox .selectorB</code>はスタイル変える必要がないのに...。</li>
<li>後日、<code>.selectorA h2</code>のテキストカラーを変更することになったのでスタイル追加したら、当然 <code>.selectorB h2</code>にも適用された...。<br>
複数人で制作していると、別のメンバーがつくったセレクタを継承してたらいつの間にか結構変わってたとかセレクタ自体が削除されてた（エラー出ないので気づかない）なんてこともあるかも。</li>
</ul>
</section>

<section>
<h3>気をつけること 2</h3>
<p><code>@extend</code>で指定したセレクタを含むセレクタも継承することです。</p>
<p>たとえば下記のような場合、要素指定なしの<code>.selectorA</code>のスタイルだけを継承したいとします。</p>

<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre class="brush: css">
.selectorA {
    text-decoration: none;
}
a.selectorA {
    text-decoration: underline;
}
.selectorB {
    <em>@extend .selectorA;</em> // ここで.selectorAを継承指定
}
</pre>
</div>
</figure>

<p>ところが、期待通りの出力結果になりませんでした。</p>
<figure>
<figcaption>
CSS
</figcaption>
<div class="figContent">
<pre class="brush: css">
.selectorA, .selectorB {
  text-decoration: none;
}

a.selectorA, <em>a.selectorB</em> { /* こちらにも追加されている */
  text-decoration: underline;
}
</pre>
</div>
</figure>

<p>さらに属性セレクタに関してはバグ（？）があるようです。</p>
<p><code>.selectorB</code>で属性セレクタ<code>.selectorA</code>を<code>@extend</code>します。</p>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre class="brush: css">
a.selectorA {
    text-decoration: none;
    //
    &amp;[href] {
        text-decoration: underline;
    }
}
.selectorB {
    <em>@extend .selectorA;</em>
}
</pre>
</div>
</figure>

<p>期待する出力結果は下記になります。</p>
<figure>
<figcaption>
CSS
</figcaption>
<div class="figContent">
<pre class="brush: css">
a.selectorA, <em>a.selectorB</em> {
  text-decoration: none;
}

a.selectorA[href], <em>a.selectorB[href]</em> {
  text-decoration: underline;
}
</pre>
</div>
</figure>

<p>実際の出力結果では、意図しないセレクタが出力されます。</p>
<figure>
<figcaption>
CSS
</figcaption>
<div class="figContent">
<pre class="brush: css">
a.selectorA, a.selectorB {
  text-decoration: none;
}

a.selectorA[href], <em>a[href].selectorB</em> { /* これはどういうことですか... */
  text-decoration: underline;
}
</pre>
</div>
</figure>
</section>

<p>複雑なセレクタに使うとややこしいですね。。<br>
<code>@extend</code>を使用するルールは決めておいたほうが良いと思います。</p>

<dl>
<dt><code>@extend</code>の使用ルール案</dt>
<dd>
<ul>
<li><code>@extend</code>で使用するセレクタはスタイルや要素が、ある程度固定されたものにする。<br>
おなじみの<code>clearfix</code>やスプライト用の指定とか。</li>
<li><code>@extend</code>専用のセレクタ（<code>.extend-foo</code>とか）を用意して利用する。<br>
このセレクタに対するあらゆる変更は、それを利用している他のセレクタにも影響することが分かるので、変更は注意しておこなうだろうし、変更前に影響範囲を確認するというフローをつくることもできると思います。</li>
</ul>
</dd>
</dl>
]]>
		
	</content>
</entry>

<entry>
	<title>Sass(Scss) Memo: @if - Blog</title>
	<link rel="alternate" type="text/html" href="http://www.culture27.com/blog/2011/07/sass_memo_3.php" />
	<id>tag:www.culture27.com,2011:/blog//3.12</id>

	<published>2011-07-06T15:58:11Z</published>
	<updated>2011-07-22T16:27:34Z</updated>

	<summary>今回は@ifについてです。 @if、@else if、@elseが使えます。 こ...</summary>
	<author>
		<name>kosei27</name>
		
	</author>
	
		<category term="web" scheme="http://www.sixapart.com/ns/types#category" />
	
	<category term="htmlcss" label="html-css" scheme="http://www.sixapart.com/ns/types#tag" />
	<category term="sass" label="sass" scheme="http://www.sixapart.com/ns/types#tag" />
	
	<content type="html" xml:lang="ja" xml:base="http://www.culture27.com/blog/">

		

		<![CDATA[<p>今回は<a href="http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#id10"><code>@if</code></a>についてです。<br>

<p><code>@if</code>、<code>@else if</code>、<code>@else</code>が使えます。<br>
こんな感じ。</p>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre class="brush: css">
$var1: aaa;

<em>@if</em> $var1 == 'bbb' {
    /* A:$var1 が bbb の場合に出力される */
} <em>@else if</em> $var1 == 'ccc' {
    /* B:最初の条件を満たさず、$var1 が ccc の場合に出力される */
} <em>@else if</em> $var1 == 'aaa' {
    /* C:2つの条件を満たさず、$var1 が aaa の場合に出力される */
} <em>@else</em> {
    /* D:それ以外の場合に出力される */
}
</pre>
</div>
</figure>

<figure>
<figcaption>
出力結果のCSS
</figcaption>
<div class="figContent">
<pre class="brush: css">
/* C:2つの条件を満たさず、$var1 が aaa の場合に出力される */
</pre>
</div>
</figure>


<p>条件の判別には<code>==</code>だけでなく他の比較演算子(<code>&lt;</code>, <code>&lt;=</code>, <code>&gt;</code>, <code>&gt;=</code>, <code>!=</code>)も使えます。</p>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre class="brush: css">
$var1: aaa;
$var2: 5;
$var3: true;

@if $var2 <em>!=</em> 1 {
    /* A:$var2 が 1 以外の場合に出力される */
}

@if $var2 <em>&gt;</em> 10 {
    /* B:$var2 が 10よりも多い場合に出力される */
} @else if $var2 <em>&lt;</em> 10 {
    /* C:$var2 が 10よりも少ない場合に出力される */
} @else if $var2 <em>&gt;=</em> 10 {
    /* D:$var2 が 10以上の場合に出力される */
} @else if $var2 <em>&lt;=</em> 10 {
    /* E:$var2 が 10以下の場合に出力される */
}

@if <em>$var3</em> {
    /* F:$var3 が trueか何か値が入ってれば出力される */
}
</pre>
</div>
</figure>

<figure>
<figcaption>
出力結果のCSS
</figcaption>
<div class="figContent">
<pre class="brush: css">
/* A:$var2 が 1 以外の場合に出力される */
/* C:$var2 が 10よりも少ない場合に出力される */
/* F:$var3 が trueか何か値が入ってれば出力される */
</pre>
</div>
</figure>


<p>論理演算子の<code>&amp;&amp;</code>や<code>||</code>、<code>!</code>は使えませんでしたが、<code>and</code>や<code>or</code>、<code>not</code>を使うことができました。</p>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre class="brush: css">
$var1: aaa;
$var2: 5;
$var3: true;
$var4: false;

@if $var1 <em>and</em> $var3 {
    /* $var1 と $var4 がどちらも true であれば出力される */
}

@if $var1 <em>or</em> $var4 {
    /* $var1 か $var4 のいずれかが true であれば出力される */
}

@if <em>not</em> $var4 {
    /* $var4 が true でなければ出力される */
}

@if ((not $var1) or $var3) and $var2 {
    /* 組み合わせてみたり... */
}
</pre>
</div>
</figure>

<figure>
<figcaption>
出力結果のCSS
</figcaption>
<div class="figContent">
<pre class="brush: css">
/* $var1 と $var3 がどちらも true であれば出力される */
/* $var1 か $var4 のいずれかが true であれば出力される */
/* $var4 が true でなければ出力される */
/* 組み合わせてみたり... */
</pre>
</div>
</figure>

<p>と、色々できますが後で読みづらくならないように気をつけたいですね、複数人で作業する場合は特に。</p>
]]>
		
	</content>
</entry>

<entry>
	<title>Sass(Scss) Memo: 変数 - Blog</title>
	<link rel="alternate" type="text/html" href="http://www.culture27.com/blog/2011/07/sass_memo_2.php" />
	<id>tag:www.culture27.com,2011:/blog//3.11</id>

	<published>2011-06-30T15:55:28Z</published>
	<updated>2011-07-22T16:25:34Z</updated>

	<summary>今回は変数についてです。 $ から始めて、値はCSSと同じようにして設定します。...</summary>
	<author>
		<name>kosei27</name>
		
	</author>
	
		<category term="web" scheme="http://www.sixapart.com/ns/types#category" />
	
	<category term="htmlcss" label="html-css" scheme="http://www.sixapart.com/ns/types#tag" />
	<category term="sass" label="sass" scheme="http://www.sixapart.com/ns/types#tag" />
	
	<content type="html" xml:lang="ja" xml:base="http://www.culture27.com/blog/">

		

		<![CDATA[<p>今回は<a href="http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#variables_">変数</a>についてです。<br>
<code>$</code> から始めて、値はCSSと同じようにして設定します。<br>
こんな感じ。</p>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre class="brush: css">
<em>$margin: 2em 0;</em>  // $margin に "2em 0" をいれて定義する。
h1 {
    margin: <em>$margin</em>;
}
</pre>
</div>
</figure>
<figure>
<figcaption>
CSS
</figcaption>
<div class="figContent">
<pre class="brush: css">
h1 {
  margin: 2em 0;
}
</pre>
</div>
</figure>

<p>変数はそれが記述された<code>{}</code>内でのみ有効になります。<br>
どのCSSルールセットやmixinにも含まれない場合、どこでも使えるグローバルな変数になります。<br>
こんな感じ。</p>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre class="brush: css">
h1 {
    <em>$margin: 2em 0;</em>  // ここで$marginを定義する。
    margin: <em>$margin</em>;
}
p {
    margin: <em>$margin</em>; // ここでは使えない！コンパイル時にエラーになります。
}
</pre>
</div>
</figure>

<section>
<h2>インターポレーション</h2>
<p>変数はプロパティの値だけでなく、セレクター名やプロパティ名にも使うことができます。<br>
その場合、<code>#{}</code>を使う<a href="http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#interpolation_">インターポレーション</a>と呼ばれる書き方をします。<br>
こんな感じ。</p>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre class="brush: css">
<em>$class: title;</em>
<em>$property: top;</em>
h1.<em>#{$class}</em> {
    margin-<em>#{$property}</em>: 2em 0;
}
</pre>
</div>
</figure>
<figure>
<figcaption>
CSS
</figcaption>
<div class="figContent">
<pre class="brush: css">
h1.<em>title</em> {
  margin-<em>top</em>: 2em 0;
}
</pre>
</div>
</figure>

<p>インターポレーションを使った場合、変数内の引用符は自動的に削除されます。<br>
mixinの引数をセレクターに利用するなんて時にやりやすくするためらしいです。<br>
.(ドット)から始まる文字列はmixinの引数にはできないので引用符で囲んであげる必要があるわけです。<br>
こんな感じ。</p>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre class="brush: css">
@mixin color-red($selector) {
    <em>#{$selector}</em> {
        color: red;
    }
}
@include color-red(<em>".title"</em>);  // 引用符で囲む。
</pre>
</div>
</figure>
<figure>
<figcaption>
CSS
</figcaption>
<div class="figContent">
<pre class="brush: css">
<em>.title</em> {  /* 引用符が削除されました。 */
  color: red;
}
</pre>
</div>
</figure>

<p>インターポレーションを使うとその近くの算術演算(<code>+</code>, <code>-</code>, <code>*</code>, <code>/</code>など)は通常のテキストとして扱われます。<br>
こんな感じ。
</p>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre class="brush: css">
$font-size: 24px;
$line-height: 1.2;
h1 {
    font: <em>$font-size/$line-height</em>;  // ふつうに記述。
    font: <em>#{$font-size}/#{$line-height}</em>;  // インターポレーションをつかう。
}

$img-path: "/shared/img";
.header {
    background-image: url(<em>#{$img-path}/</em>bg_header.png);  // 画像のパスに使うときにも。
}

$var1: foo;
$var2: bar;
.test {
    content: $var1 + $var2;
    content: #{$var1} + #{$var2};

    content: $var1 - $var2;
    content: #{$var1} - #{$var2};
}
</pre>
</div>
</figure>
<figure>
<figcaption>
CSS
</figcaption>
<div class="figContent">
<pre class="brush: css">
h1 {
  font: <em>20px</em>;  /* 計算されてしまいました。 */
  font: <em>24px/1.2</em>;
}

.header {
  background-image: url(<em>/shared/img/</em>bg_header.png);
}

.test {
  content: foobar;     /* +とスペースがなくなり連結された。 */
  content: foo + bar;  /* +とスペースはそのまま。 */
  content: foo-bar;    /* -はそのままで、スペースがなくなった。 */
  content: foo - bar;  /* -とスペースはそのまま。 */
}
</pre>
</div>
</figure>
<p><strong>計算や結合させたければ普通に記述して、そうでない場合はインターポレーションで記述</strong>すれば大丈夫ですね。</p>
</section>

<section>
<h2>変数のデフォルト値</h2>
<p>変数には <code>!default</code> で初期値を設定することができます。<br>
変数にすでに値が代入されている場合、その値を上書きしません。値がすでに代入されていない場合は通常通り指定された値を代入します。<br>
こんな感じ。</p>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre class="brush: css">
$var1: foo;
$var1: bar <em>!default</em>;
.test {
    content: $var1;  // 通常なら後で代入した bar が出力されるが、、
}

$var2: bar <em>!default</em>;
.test {
    content: $var2;  // 先に値が代入されていなければ、、
}
</pre>
</div>
</figure>

<figure>
<figcaption>
CSS
</figcaption>
<div class="figContent">
<pre class="brush: css">
.test {
  content: foo;  /* foo が出力されました。 */
}

.test {
  content: bar;  /* bar が出力されました。 */
}
</pre>
</div>
</figure>
<p><code>!default</code> はCSSでいう <code>!important</code> の逆みたいなもんですかね。</p>
</section>
]]>
		
	</content>
</entry>

<entry>
	<title>Sass(Scss) Memo: 親セレクタの参照 - Blog</title>
	<link rel="alternate" type="text/html" href="http://www.culture27.com/blog/2011/06/sass_memo_1.php" />
	<id>tag:www.culture27.com,2011:/blog//3.10</id>

	<published>2011-06-26T13:18:39Z</published>
	<updated>2011-07-22T16:22:30Z</updated>

	<summary>Sass(Scss)について覚えたことを少しずつ書いていきたいと思います。 今回...</summary>
	<author>
		<name>kosei27</name>
		
	</author>
	
		<category term="web" scheme="http://www.sixapart.com/ns/types#category" />
	
	<category term="htmlcss" label="html-css" scheme="http://www.sixapart.com/ns/types#tag" />
	<category term="sass" label="sass" scheme="http://www.sixapart.com/ns/types#tag" />
	
	<content type="html" xml:lang="ja" xml:base="http://www.culture27.com/blog/">

		

		<![CDATA[<p><abbr title="Syntactically Awesome StyleSheets">Sass</abbr>(<abbr title="Sassy CSS">Scss</abbr>)について覚えたことを少しずつ書いていきたいと思います。</p>
<p>今回は親セレクタの参照についてです。<br>
Sassでは<a href="http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#referencing_parent_selectors_" title="Referencing Parent Selectors: &amp; - File: SASS_REFERENCE"> <code>&amp;</code> を使って親セレクタを参照することができます</a>。</p>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre class="brush: css">
div {
    a {
        text-decoration: none;

        <em>&amp;:hover</em> {
            text-decoration: underline;
        }
    }
}
</pre>
</div>
</figure>

<p>こうするとCSSは下記のように出力されます。</p>
<figure>
<figcaption>
CSS
</figcaption>
<div class="figContent">
<pre class="brush: css">
div a {
  text-decoration: none;
}
<em>div a:hover</em> {
  text-decoration: underline;
}
</pre>
</div>
</figure>

<p><code>&amp;</code> が <code>div a</code> に置換されています。<br>
親セレクタを繰り返し記述しなくても良いので便利です。</p>

<p>ただ、隣接セレクタを使うときにはちょっと不便です。<br>
例えば、下記のようなCSSをScss記法に書き換える場合。</p>
<figure>
<figcaption>
CSS
</figcaption>
<div class="figContent">
<pre class="brush: css">
div h1 {
  font-size: 20px;
}
div ul {
  margin: 2em 0;
}
div <em>h1 + ul</em> {
  margin-top: 1em;
}
</pre>
</div>
</figure>

<p>Scssで下記のように記述した時、<code>h1 + &amp;</code> は <code>div h1 + ul</code> となって欲しいところです。</p>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre class="brush: css">
div {
    h1 {
        font-size: 20px;
    }
    ul {
        margin: 2em 0;

        <em>h1 + &amp;</em> {
            margin-top: 1em; // override
        }
    }
}
</pre>
</div>
</figure>

<p>ですが、<code>&amp;</code> は親セレクタの <code>div ul</code> に置換されますので、実際には <code>h1 + div ul</code> と出力されてしまいます。</p>
<figure>
<figcaption>
CSS
</figcaption>
<div class="figContent">
<pre class="brush: css">
div h1 {
  font-size: 20px;
}
div ul {
  margin: 2em 0;
}
<em>h1 + div ul</em> {
  margin-top: 1em;
}
</pre>
</div>
</figure>

<p> <code>&amp;</code> を使いたい場合は、下記のように記述するとうまくいきます。</p>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre class="brush: css">
div {
    h1 {
        font-size: 20px;

        <em>&amp; + ul</em> {
            margin-top: 1em; // override
        }
    }
    ul {
        margin: 2em 0;
    }
}
</pre>
</div>
</figure>

<figure>
<figcaption>
CSS
</figcaption>
<div class="figContent">
<pre class="brush: css">
div h1 {
  font-size: 20px;
}
<em>div h1 + ul</em> {
  margin-top: 1em;
}
div ul {
  margin: 2em 0;
}
</pre>
</div>
</figure>

<p>ただ、スタイルの上書きは後に書くことが多いので少し違和感があるかもしれません。<br>
その場合、若干冗長ですが下記のように記述するといいと思います。</p>
<figure>
<figcaption>
Scss
</figcaption>
<div class="figContent">
<pre class="brush: css">
div {
    h1 {
        font-size: 20px;
    }
    ul {
        margin: 2em 0;
    }
    <em>h1 + ul</em> {
        margin-top: 1em; // override
    }
}
</pre>
</div>
</figure>

<figure>
<figcaption>
CSS
</figcaption>
<div class="figContent">
<pre class="brush: css">
div h1 {
  font-size: 20px;
}
div ul {
  margin: 2em 0;
}
<em>div h1 + ul</em> {
  margin-top: 1em;
}
</pre>
</div>
</figure>

<p>どちらかお好きなほうでどうぞ。</p>
]]>
		
	</content>
</entry>

<entry>
	<title>IEのz-indexのバグを思い出す - Blog</title>
	<link rel="alternate" type="text/html" href="http://www.culture27.com/blog/2011/04/z-index.php" />
	<id>tag:www.culture27.com,2011:/blog//3.9</id>

	<published>2011-04-06T12:53:28Z</published>
	<updated>2011-07-22T16:17:40Z</updated>

	<summary>つい最近、IE6ってz-indexのバグがあったよな...って思ったけど、ぼんや...</summary>
	<author>
		<name>kosei27</name>
		
	</author>
	
		<category term="web" scheme="http://www.sixapart.com/ns/types#category" />
	
	<category term="htmlcss" label="html-css" scheme="http://www.sixapart.com/ns/types#tag" />
	
	<content type="html" xml:lang="ja" xml:base="http://www.culture27.com/blog/">

		

		<![CDATA[<p>つい最近、IE6ってz-indexのバグがあったよな...って思ったけど、ぼんやりとしか思い出せなかったので今さらですが検証してみました。。</p>
<p>結論としてはIE6だけじゃなくてIE7にも同じバグがありました。<br>
2つのdivの親要素が別々でz-indexは指定しない場合、<strong>IE6とIE7以外のブラウザは子要素のz-indexの値が優先されるが、IE6とIE7は親要素の出現順が影響します。</strong>後から出現した親と子要素が手前になります。</p>
<p class="viewDemo"><a href="/web/demo/201104_z-index">デモページをみる</a></p>
<figure>
<figcaption>
Google ChromeやFirefoxなどの場合
</figcaption>
<div class="figContent">
<p class="img"><img src="/blog/img/2011/04/z-index01.png" alt=""></p>
</div>
</figure>
<figure>
<figcaption>
IE6とIE7の場合
</figcaption>
<div class="figContent">
<p class="img"><img src="/blog/img/2011/04/z-index02.png" alt=""></p>
</div>
</figure>
]]>
		
	</content>
</entry>

<entry>
	<title>QuickSilverのトリガー機能でアプリを素早く切り替える - Blog</title>
	<link rel="alternate" type="text/html" href="http://www.culture27.com/blog/2011/04/quicksilver_triggers.php" />
	<id>tag:www.culture27.com,2011:/blog//3.8</id>

	<published>2011-04-05T11:24:12Z</published>
	<updated>2011-07-22T16:16:22Z</updated>

	<summary>タイトル通りQuicksilverのトリガー機能を使えばよく使うアプリに素早く切...</summary>
	<author>
		<name>kosei27</name>
		
	</author>
	
		<category term="web" scheme="http://www.sixapart.com/ns/types#category" />
	
	<category term="mac" label="mac" scheme="http://www.sixapart.com/ns/types#tag" />
	
	<content type="html" xml:lang="ja" xml:base="http://www.culture27.com/blog/">

		

		<![CDATA[<p>タイトル通り<a href="http://www.blacktree.com/?quicksilver">Quicksilver</a>のトリガー機能を使えばよく使うアプリに素早く切り替えられます、ってだけです。が、地味だけどほんとに便利です。</p>

<p>メインのエディタはMacVimなので押しやすい<kbd>Cmd</kbd>+<kbd>;</kbd>で、Chromeはひとつ隣の<kbd>Cmd</kbd>+<kbd>:</kbd>、Firefoxは<kbd>Cmd</kbd>+<kbd>.</kbd>(ドット)といった感じで適当に割り当てています。</p>

<figure>
<figcaption>
QuickSilverのTriggers設定画面
</figcaption>
<div class="figContent">
<p class="img"><img src="/blog/img/2011/04/quicksilver_triggers01.png" alt=""></p>
</div>
</figure>
]]>
		
	</content>
</entry>

<entry>
	<title>VimでCSSルールセットを選択する - Blog</title>
	<link rel="alternate" type="text/html" href="http://www.culture27.com/blog/2011/03/vim_select_css_rule_set.php" />
	<id>tag:www.culture27.com,2011:/blog//3.7</id>

	<published>2011-03-11T22:36:57Z</published>
	<updated>2011-07-22T16:15:28Z</updated>

	<summary>Vimではvatと入力するだけでカーソル位置から直近のHTMLの要素を選択できる...</summary>
	<author>
		<name>kosei27</name>
		
	</author>
	
		<category term="web" scheme="http://www.sixapart.com/ns/types#category" />
	
	<category term="htmlcss" label="html-css" scheme="http://www.sixapart.com/ns/types#tag" />
	<category term="vim" label="vim" scheme="http://www.sixapart.com/ns/types#tag" />
	
	<content type="html" xml:lang="ja" xml:base="http://www.culture27.com/blog/">

		

		<![CDATA[<p>Vimでは<kbd>vat</kbd>と入力するだけでカーソル位置から直近のHTMLの要素を選択できるのですが、CSSのルールセットを選択するものがありません。<kbd>viB</kbd>や<kbd>vi{</kbd>とすれば、{}内のテキストは選択できますが、カーソルが{}内にないと機能しません。なのでVim scriptをパクリながらはじめて書いてみました。</p>

<p>git submoduleでインストールすることができます。下記は<a href="http://www.vim.org/scripts/script.php?script_id=2332">pathogen.vim</a>を使っている場合です。</p>
<figure>
<div class="figContent">
<pre>
git submodule add git@github.com:kosei27/vim-selectCssRuleSet.git ~/path/to/bundle/vim-selectcssruleset
</pre>
</div>
</figure>

<figure>
<div class="figContent">
<pre>
" Select CSS Rule Set
" カーソルから一番近いCSSルールセットを選択する
"
" nnoremap &lt;silent&gt; var  :&lt;C-u&gt;call SelectCssRuleSet()&lt;CR&gt;
" vimrcに&uarr;を追加して、varと入力します。
function! SelectCssRuleSet()
    let save_reg = @@

    silent normal $va{Voy
    let first_yank = @@

    " 最初にヤンクした内容に'{'が含まれるかどうかチェック
    let chk_first_yank = matchstr(first_yank, '{')
    if chk_first_yank == ''
        " 最初にヤンクした内容に'{'が含まれない場合は次の行をチェックする
        let chk_next_line = matchstr(getline(line(".")+1), '{')
        while chk_next_line == '' " 次の行に'{'がない場合は見つかるまで繰り返す
            silent normal j
            " ファイルの最終行に来たらループ抜けてエラーメッセージを表示する
            if line(".")==line("$")
                execute "normal \&lt;Esc&gt;"
                echohl ErrorMsg
                echo 'no match css rule sets.'
                echohl None
                return
                break
            endif
            let chk_next_line = matchstr(getline(line(".")+1), '{')
        endwhile
        silent normal j
    endif

    execute "normal \&lt;Esc&gt;"
    silent normal $va{Vo
    let chk_prev_line = matchstr(getline(line(".")-1), ',')
    while chk_prev_line != '' " 上の行に','があればセレクタグループとして選択する
        silent normal k
        let chk_prev_line = matchstr(getline(line(".")-1), ',')
    endwhile

    let @@ = save_reg
endfunction
</pre>
</div>
</figure>

<p>vimrcに下記を追加して、<kbd>var</kbd>と入力するとカーソルから直近のルールセットが選択されると思います（<code>&lt;plug&gt;</code>とか使うんですよね？ほんとは...）。</p>
<figure>
<div class="figContent">
<pre>
nnoremap &lt;silent&gt; var  :&lt;C-u&gt;call SelectCssRuleSet()&lt;CR&gt;
</pre>
</div>
</figure>
]]>
		
	</content>
</entry>

<entry>
	<title>Cmd+wしようとしてCmd+qでブラウザを閉じてしまうのを防ぐ方法 - Blog</title>
	<link rel="alternate" type="text/html" href="http://www.culture27.com/blog/2011/03/prevent_browser_close.php" />
	<id>tag:www.culture27.com,2011:/blog//3.6</id>

	<published>2011-03-09T13:07:54Z</published>
	<updated>2011-07-22T16:12:52Z</updated>

	<summary>Cmd+qではなくCmd+Ctrl+qで閉じるようにします。 システム環境設定か...</summary>
	<author>
		<name>kosei27</name>
		
	</author>
	
		<category term="web" scheme="http://www.sixapart.com/ns/types#category" />
	
	<category term="mac" label="mac" scheme="http://www.sixapart.com/ns/types#tag" />
	
	<content type="html" xml:lang="ja" xml:base="http://www.culture27.com/blog/">

		

		<![CDATA[<p><kbd>Cmd+q</kbd>ではなく<kbd>Cmd+Ctrl+q</kbd>で閉じるようにします。</p>

<p>システム環境設定からキーボード設定画面を開きます。キーボードショートカットの画面で、「アプリケーション」を選択し、「＋」ボタンを押してキーを追加します。</p>
<figure>
<figcaption>キーボード設定画面のスクリーンショット</figcaption>
<div class="figContent">
<p class="img"><img src="/blog/img/2011/03/prevent_browser_close01.png" alt=""></p>
</div>
</figure>

<p>ダイアログが表示されるので、それぞれの項目を設定します。</p>
<ul>
<li>アプリケーションは今回はGoogle Chromeにします。</li>
<li>メニューのタイトルにはメニューの文字列を正確に入力します。なので、「Google Chrome を終了」となります。</li>
<li>キーボードショートカットは<kbd>Cmd+Ctrl+q</kbd>にします。</li>
</ul>
<figure>
<div class="figContent">
<p class="img"><img src="/blog/img/2011/03/prevent_browser_close02.png" alt=""></p>
<p class="img"><img src="/blog/img/2011/03/prevent_browser_close03.png" alt=""></p>
</div>
</figure>

<p>各項目の設定のあと「追加」ボタンを押すと、ショートカットが追加されます。</p>
<figure>
<div class="figContent">
<p class="img"><img src="/blog/img/2011/03/prevent_browser_close04.png" alt=""></p>
</div>
</figure>

<p>メニューの項目を見るとショートカットのところが変更されてますね。</p>
<figure>
<div class="figContent">
<p class="img"><img src="/blog/img/2011/03/prevent_browser_close05.png" alt=""></p>
</div>
</figure>

<p>FirefoxやVim、Photoshopなども設定しておくといいかもしれません。</p>
]]>
		
	</content>
</entry>

<entry>
	<title>WebKitの画像置換のバグの解決方法 - Blog</title>
	<link rel="alternate" type="text/html" href="http://www.culture27.com/blog/2011/03/webkit_image_replacement.php" />
	<id>tag:www.culture27.com,2011:/blog//3.5</id>

	<published>2011-03-03T15:45:25Z</published>
	<updated>2011-07-22T16:09:55Z</updated>

	<summary> バグの内容 下記のように画像置換した場合、WebKitではspan要素のテキス...</summary>
	<author>
		<name>kosei27</name>
		
	</author>
	
		<category term="web" scheme="http://www.sixapart.com/ns/types#category" />
	
	<category term="htmlcss" label="html-css" scheme="http://www.sixapart.com/ns/types#tag" />
	
	<content type="html" xml:lang="ja" xml:base="http://www.culture27.com/blog/">

		

		<![CDATA[<section id="sec1">
<h2>バグの内容</h2>
<p>下記のように画像置換した場合、WebKitでは<code>span要素</code>のテキスト分の幅が保持されて<code>a</code>要素の幅が広がってしまいます。</p>

<figure>
<figcaption>
HTML
</figcaption>
<div class="figContent">
<pre class="brush: xml">
&lt;p&gt;&lt;a href="#" class="ir"&gt;&lt;span&gt;画像置換テキスト&lt;/span&gt;&lt;/a&gt;左のボタンは画像置換をおこなっています。&lt;/p&gt;
&lt;p style="padding-left:102px;"&gt;画像置換テキスト&lt;/p&gt;
</pre>
</div>
</figure>

<figure>
<figcaption>
CSS
</figcaption>
<div class="figContent">
<pre class="brush: css">
.ir {
    display: inline-block;
    *display: inline;
    *zoom: 1;
}
.ir span {
    display: inline-block;
    *display: inline;
    *zoom: 1;
    width: 0;
    height: 32px; /* ボタン画像の高さ */
    overflow: hidden;
    padding: 0 0 0 102px; /* ボタン画像の幅 */
    background: url(..) no-repeat 0 0;
}
</pre>
</div>
</figure>

<p class="viewDemo"><a href="/web/demo/201103_webkit_image_replacement#sec1">デモページをみる</a></p>
<figure>
<figcaption>
Google Chromeでのスクリーンショット
</figcaption>
<div class="figContent">
<p class="img"><img src="/blog/img/2011/03/webkit_image_replacement01.png" alt=""></p>
</div>
</figure>
</section>

<section id="sec2">
<h2>解決方法</h2>
<p>これを解決するには、画像置換をしている<code>span</code>要素に<code>max-width: 0;</code>を指定します。</p>

<figure>
<figcaption>
CSS
</figcaption>
<div class="figContent">
<pre class="brush: css">
.ir span {
    display: inline-block;
    *display: inline;
    *zoom: 1;
    width: 0;
    max-width: 0; /* for WebKit bug */
    height: 32px;
    overflow: hidden;
    padding: 0 0 0 102px;
    background: url(..) no-repeat 0 0;
}
</pre>
</div>
</figure>
<p class="viewDemo"><a href="/web/demo/201103_webkit_image_replacement#sec2">デモページをみる</a></p>
<figure>
<figcaption>
Google Chromeでのスクリーンショット
</figcaption>
<div class="figContent">
<p class="img"><img src="/blog/img/2011/03/webkit_image_replacement02.png" alt=""></p>
</div>
</figure>

<p>まさか<code>max-width</code>を<var>0</var>にすることになるなんて...。</p>
</section>

<section id="sec3">
<h2>おまけ</h2>
<figure>
<figcaption>
Vimのプラグインneocomplcache.vimのスニペット。css.snipにコピペして、<kbd>ir</kbd>と入力して展開です。
</figcaption>
<div class="figContent">
<pre class="brush: css">
snippet	imagereplacement
alias	ir
    display: inline-block;
    ${1:*}display: inline;
    $1zoom: 1;
    width: 0;
    max-width: 0; /* for WebKit bug */
    height: ${2}px;
    overflow: hidden;
    padding: 0 0 0 ${3:$2}px;
    background: url(${4}) no-repeat ${5:0 0};
</pre>
</div>
</figure>

</section>
]]>
		
	</content>
</entry>

<entry>
	<title>MacBook AirのPowerボタンを何かに変えたい - Blog</title>
	<link rel="alternate" type="text/html" href="http://www.culture27.com/blog/2011/03/macbook_air_power_button.php" />
	<id>tag:www.culture27.com,2011:/blog//3.4</id>

	<published>2011-03-01T15:57:46Z</published>
	<updated>2011-07-22T16:05:47Z</updated>

	<summary>が、いまんとこできなそう...。 会社ではiMacの標準キーボードを使ってて、d...</summary>
	<author>
		<name>kosei27</name>
		
	</author>
	
		<category term="web" scheme="http://www.sixapart.com/ns/types#category" />
	
	<category term="mac" label="mac" scheme="http://www.sixapart.com/ns/types#tag" />
	
	<content type="html" xml:lang="ja" xml:base="http://www.culture27.com/blog/">

		

		<![CDATA[<p>が、いまんとこできなそう...。</p>
<p>会社ではiMacの標準キーボードを使ってて、deleteキーの上にあるEjectキーをもったいないので<a href="http://pqrs.org/macosx/keyremap4macbook/index.html.ja">KeyRemap4MacBook</a>でForward Deleteキー（WindowsでいうDeleteキー）にしてる。</p>
<p>でもMacBook AirはそこにEjectキーじゃなくてPowerボタンがあるので、押し間違えたりしそうだし、不便なので変えたいなーと思ってKeyRemap4MacBookの設定を見てみた。</p>
<figure>
<figcaption>
KeyRemap4MacBookの設定画面。検索窓に「Power」と入力して絞り込んだ状態。
</figcaption>
<div class="figContent">
<p class="img"><img src="/blog/img/2011/03/keyremap_power01.png" alt=""></p>
</div>
</figure>
<p>Power to Forward Delete (+ Fn+Power to Power)にチェックを入れてできたできたー、と思ったけど効かない...。なんでだろと思ってよく見ると注意書きが。</p>
<div class="blockquote">
<blockquote lang="en">
This setting does not work with MacBook Air 2010.<br>
This &quot;Power Key&quot; is the key in the old ADB keyboard.
</blockquote>
</div>
<p>これ、Air用じゃなかったよ...。</p>
]]>
		
	</content>
</entry>

</feed>

