<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>understandard &#187; CSS</title>
	<atom:link href="http://www.understandard.net/category/css/feed" rel="self" type="application/rss+xml" />
	<link>http://www.understandard.net</link>
	<description>雑記と HTML、CSS、WordPress について</description>
	<lastBuildDate>Thu, 02 Feb 2012 05:56:04 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>clearfix のアレンジ版作ってみました</title>
		<link>http://www.understandard.net/css/css013.html</link>
		<comments>http://www.understandard.net/css/css013.html#comments</comments>
		<pubDate>Wed, 01 Feb 2012 08:32:00 +0000</pubDate>
		<dc:creator>じゅん</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.understandard.net/?p=806</guid>
		<description><![CDATA[Firefox 3.6 が clearfix の影響で margin-bottom が margin-top にもかかるという話を聞いて、普段使ってた clearfix で試してみたところ、同様の現象が出たので、対応版を [...]<dl class="relatives">
<dt><span>関連投稿</span></dt>
<dd><ul>
<li>
<a href="http://www.understandard.net/css/css011.html" rel="bookmark">display: inline-block を使う（修正版）</a><!-- (15.8)-->
<div class="info">
<span class="category">category: <a href="http://www.understandard.net/category/css" title="CSS の投稿をすべて表示" rel="category tag">CSS</a></span>
<span class="tags">tags: <a href="http://www.understandard.net/tag/css" rel="tag">CSS</a>+<a href="http://www.understandard.net/tag/tips" rel="tag">tips</a>.</span>
</div>
</li>
<li>
<a href="http://www.understandard.net/css/css008.html" rel="bookmark">display:inline-block; を使う</a><!-- (15.5)-->
<div class="info">
<span class="category">category: <a href="http://www.understandard.net/category/css" title="CSS の投稿をすべて表示" rel="category tag">CSS</a></span>
<span class="tags">tags: <a href="http://www.understandard.net/tag/css" rel="tag">CSS</a>+<a href="http://www.understandard.net/tag/tips" rel="tag">tips</a>.</span>
</div>
</li>
<li>
<a href="http://www.understandard.net/tool/tool001.html" rel="bookmark">Dreamweaver の作業効率を上げるためのメモ</a><!-- (11.2)-->
<div class="info">
<span class="category">category: <a href="http://www.understandard.net/category/tool" title="tool の投稿をすべて表示" rel="category tag">tool</a></span>
<span class="tags">tags: <a href="http://www.understandard.net/tag/dreamweaver" rel="tag">Dreamweaver</a>+<a href="http://www.understandard.net/tag/tips" rel="tag">tips</a>+<a href="http://www.understandard.net/tag/tools" rel="tag">tools</a>.</span>
</div>
</li>
</ul>
</dd>
</dl>
]]></description>
			<content:encoded><![CDATA[<p>Firefox 3.6 が clearfix の影響で margin-bottom が margin-top にもかかるという話を聞いて、普段使ってた clearfix で試してみたところ、同様の現象が出たので、対応版を作ってみました。</p>
<p>ネタ元の記事は以下。<br />
<a href="http://blog.sakurachiro.com/2011/03/firefox-margin/">firefoxでmargin-bottomがmargin-top | 乱雑モックアップ</a></p>
<p>この記事で紹介されていた clearfix は以下ようなもの。<br />
僕はこの指定から <code>height:0;</code> を抜いたものを使っていました。</p>
<pre>.clearfix:after{
content:'';
display:block;
clear:both;
height:0;
}
.clearfix{
/zoom:1;
}</pre>
<p>そして、解決方法として教えてもらったのが hail2u.net さんのデモ。<br />
<a href="http://hail2u.net/pub/test/199.html">firefoxでmargin-bottomがmargin-topになったりするのを回避する</a></p>
<p>この解決方法は、<code>height:0;</code> を <code>height:0.01px;</code> にしています。</p>
<pre>.clearfix:after{
content:'';
display:block;
clear:both;
height:0.01px;
}
.clearfix{
/zoom:1;
}</pre>
<p>この記事の公開時点（2012年2月1日）の最新版 <strong>Firefox 10.0 でも 3.6 と同様の挙動で、hail2u.net さんの方法で解決できます</strong>。</p>
<h2>アレンジ版作ってみました</h2>
<p><code>height:0.01px;</code> の指定で解決できますが、他の解決方法がないかと試してみました。<br />
なお、<code>zoom:1;</code> の部分は共通なので、以下のコードでは省略しています。</p>
<p>検証ブラウザは以下の通り。<br />
※ Mac: Mac OS X Lion、Win: Windows 7</p>
<ul>
<li>Firefox 3.6.25 (Mac, Win)</li>
<li>Firefox 4.0.1 (Mac, Win)</li>
<li>Firefox 9.0.1 (Mac, Win)</li>
<li>Firefox 10.0 (Mac, Win)</li>
<li>Chrome 16.0.912.77 (Mac, Win)</li>
<li>Safari 5.1.2 (Mac, Win)</li>
<li>Opera 11.61 (Mac, Win)</li>
<li>Internet Explorer 8 (Win)</li>
<li>Internet Explorer 9 (Win)</li>
</ul>
<p>Internet Explorer 6、7 は関係しない変更なので、検証はしていません。<br />
また、検証したのは Firefox の4つのバージョンのみで、バージョン 5 〜 8 では未検証です。<br />
リリース直前だったので、バージョン 9.0.1 と 10.0 で検証していますが、これに深い意味はないです。</p>
<h3>元記事コメント欄版</h3>
<p>元記事で、<code>.clearfix:after</code> に <code>overflow:hidden;</code> を指定すれば、<code>height:0;</code> の指定は必要なくなるとのコメントが書かれていたので試してみたところ、問題なく動作しました。<br />
また、<code>overflow:auto;</code> を指定してもうまくいきました。</p>
<pre>.clearfix:after{
content:"";
display:block;
clear:both;
overflow:hidden;
}</pre>
<p>この2つは、「clearfix を使わずに <code>float</code> を解除する」みたいなやつと同じってことですかねってことで、深く追ってません。</p>
<h3>height:0; を別のプロパティに変えてみた版</h3>
<p>clearfix のバリエーションのうち、<code>.clearfix</code> 側に <code>min-height:1%;</code> って使ってたなーと思って試したらうまくいっちゃった版。</p>
<pre>.clearfix:after{
content:"";
display:block;
clear:both;
min-height:1%;
}</pre>
<p><code>visibility:hidden;</code> など他のプロパティも試してみましたが、うまくいかず。<br />
複数のプロパティの組み合わせでうまくコントロールできるかもしれませんが、コードがどんどん長くなりそうだったので、このパターンはここまで。</p>
<h3>display:block; を違うものにしてみた版</h3>
<p>元記事で <code>.clearfix</code> 側に <code>display:inline-block;</code> を指定すると直ると書かれていました。<br />
確かに変なマージンは取れましたが、これはこれで違う余白の問題が出る可能性高いので、あまり使いたくないかなと。<br />
ということで、1つ前のパターン同様、<code>.clearfix:after</code> のほうに指定してみたところ、期待通りの動作になりました。</p>
<pre>.clearfix:after{
content:"";
display:inline-block;
clear:both;
}</pre>
<p>また、<code>display:table;</code> or <code>display:inline-table;</code> でもうまくいきました。<br />
<code>display:table;</code> のほうは、<a href="http://nicolasgallagher.com/micro-clearfix-hack/">A new micro clearfix hack – Nicolas Gallagher</a> と同じような感じになりました。<br />
<code>display:inline-table;</code> はなんとなくやってみたら効いてくれた程度のものです。</p>
<h2>まとめ</h2>
<p>行数（覚える量）が増えずに意図した挙動をしてくれるということで、<code>display:inline-block;</code> を指定する版をしばらく使ってみようかなと思います。<br />
一番コード量が少ないのは <code>display:table;</code> ですが、なんとなく気持ち悪いので。</p>
<p>ということで、以下のコードが現時点でのオレオレ clearfix になりました。</p>
<pre>.clearfix:after{
content:"";
display:inline-block;
clear:both;
}
.clearfix{
/zoom:1;
}</pre>
<p>なお、Firefox 2 では、<code>display:inline-block;</code> に対応していないので、上記の指定ではマージンの挙動がコントロールできません。要件に組み込まれている際にはそのまま使わないように注意してください。<br />
<code></code></p>
<p><code>min-height:1%;</code> のほうなら大丈夫みたいですが、Firefox 2 は、2008年末で開発とサポートを終了しており、アップデートできない場合は他のブラウザを使用するようアナウンスしているので、対応することはないと思います。</p>
<p>ブラウザの種類、バージョンでうまくいかなかったり、新しい解決方法を見つけた方は教えてください。</p>
<dl class="relatives">
<dt><span>関連投稿</span></dt>
<dd><ul>
<li>
<a href="http://www.understandard.net/css/css011.html" rel="bookmark">display: inline-block を使う（修正版）</a><!-- (15.8)-->
<div class="info">
<span class="category">category: <a href="http://www.understandard.net/category/css" title="CSS の投稿をすべて表示" rel="category tag">CSS</a></span>
<span class="tags">tags: <a href="http://www.understandard.net/tag/css" rel="tag">CSS</a>+<a href="http://www.understandard.net/tag/tips" rel="tag">tips</a>.</span>
</div>
</li>
<li>
<a href="http://www.understandard.net/css/css008.html" rel="bookmark">display:inline-block; を使う</a><!-- (15.5)-->
<div class="info">
<span class="category">category: <a href="http://www.understandard.net/category/css" title="CSS の投稿をすべて表示" rel="category tag">CSS</a></span>
<span class="tags">tags: <a href="http://www.understandard.net/tag/css" rel="tag">CSS</a>+<a href="http://www.understandard.net/tag/tips" rel="tag">tips</a>.</span>
</div>
</li>
<li>
<a href="http://www.understandard.net/tool/tool001.html" rel="bookmark">Dreamweaver の作業効率を上げるためのメモ</a><!-- (11.2)-->
<div class="info">
<span class="category">category: <a href="http://www.understandard.net/category/tool" title="tool の投稿をすべて表示" rel="category tag">tool</a></span>
<span class="tags">tags: <a href="http://www.understandard.net/tag/dreamweaver" rel="tag">Dreamweaver</a>+<a href="http://www.understandard.net/tag/tips" rel="tag">tips</a>+<a href="http://www.understandard.net/tag/tools" rel="tag">tools</a>.</span>
</div>
</li>
</ul>
</dd>
</dl>
]]></content:encoded>
			<wfw:commentRss>http://www.understandard.net/css/css013.html/feed</wfw:commentRss>
		<slash:comments>49</slash:comments>
		</item>
		<item>
		<title>Mac 版 Safari でフォーカスしても placeholder が消えないときの対処法</title>
		<link>http://www.understandard.net/css/css012.html</link>
		<comments>http://www.understandard.net/css/css012.html#comments</comments>
		<pubDate>Wed, 26 Oct 2011 07:30:10 +0000</pubDate>
		<dc:creator>じゅん</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Safari]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.understandard.net/?p=789</guid>
		<description><![CDATA[Mac 版 Safari で、フォーカスしても placeholder 属性に入れたテキストが消えない現象を見つけました。 現象を確認したのは、Mac 版 Safari 5.1.1 (7534.51.22) です。 対応 [...]<dl class="relatives">
<dt><span>関連投稿</span></dt>
<dd><ul>
<li>
<a href="http://www.understandard.net/css/css004.html" rel="bookmark">デフォルトスタイルのリセット</a><!-- (9.8)-->
<div class="info">
<span class="category">category: <a href="http://www.understandard.net/category/css" title="CSS の投稿をすべて表示" rel="category tag">CSS</a></span>
<span class="tags">tags: <a href="http://www.understandard.net/tag/css" rel="tag">CSS</a>+<a href="http://www.understandard.net/tag/tips" rel="tag">tips</a>.</span>
</div>
</li>
<li>
<a href="http://www.understandard.net/css/css011.html" rel="bookmark">display: inline-block を使う（修正版）</a><!-- (6.4)-->
<div class="info">
<span class="category">category: <a href="http://www.understandard.net/category/css" title="CSS の投稿をすべて表示" rel="category tag">CSS</a></span>
<span class="tags">tags: <a href="http://www.understandard.net/tag/css" rel="tag">CSS</a>+<a href="http://www.understandard.net/tag/tips" rel="tag">tips</a>.</span>
</div>
</li>
<li>
<a href="http://www.understandard.net/css/css009.html" rel="bookmark">table に指定しておきたい CSS メモ</a><!-- (5.6)-->
<div class="info">
<span class="category">category: <a href="http://www.understandard.net/category/css" title="CSS の投稿をすべて表示" rel="category tag">CSS</a></span>
<span class="tags">tags: <a href="http://www.understandard.net/tag/css" rel="tag">CSS</a>+<a href="http://www.understandard.net/tag/tips" rel="tag">tips</a>.</span>
</div>
</li>
</ul>
</dd>
</dl>
]]></description>
			<content:encoded><![CDATA[<p><img alt="placeholder が消えない" src="http://understandard.net/images/post/css/012/css012.png" title="placeholder が消えない" class="alignnone" width="630" height="100" /></p>
<p>Mac 版 Safari で、フォーカスしても <code>placeholder</code> 属性に入れたテキストが消えない現象を見つけました。<br />
現象を確認したのは、Mac 版 Safari 5.1.1 (7534.51.22) です。</p>
<p>対応している他のブラウザでは、フォーカスした時点で <code>placeholder</code> は隠れますが、Mac 版 Safari 5.1.1 (7534.51.22) ではテキストを入力し始めるまで隠れてくれません。<br />
なお、Chrome 12.0.835.202 ( Windows、Mac ともに )、Windwos 版 Safari 5.1.1 (7534.51.22) では発生しませんでした。<br />
<del datetime="2011-10-26T08:40:53+00:00">そんな状態なので、バージョンアップしたら直るんじゃないかと思いますが、一応メモ。</del></p>
<p><ins datetime="2011-10-26T08:40:53+00:00"><span>追記: </span>バグではなく、OS X Lion 上の Safari の仕様みたいです。言われるまで気づいていませんでしたが、iOS でも同じ挙動をしていました。矢倉さん、ありがとうございます。<br />
参考: プレースホルダとHTML5のplaceholder属性<br />
<a href="http://myakura.github.com/n/placeholder.html">http://myakura.github.com/n/placeholder.html<br />
</a></ins></p>
<h2>対処法</h2>
<p>Safari のユーザ・エージェント・スタイルシートに以下のような指定があります。</p>
<pre>input::-webkit-input-placeholder,
isindex::-webkit-input-placeholder,
textarea::-webkit-input-placeholder{
    color: #A9A9A9;
}</pre>
<p>これを参考にして、<code>:focus</code> 状態の <code>placeholder</code> に対して、<code>color: transparent;</code> を指定。</p>
<pre>input:focus::-webkit-input-placeholder,
isindex:focus::-webkit-input-placeholder,
textarea:focus::-webkit-input-placeholder {
    color: transparent;
}</pre>
<p>上記の指定をしておけば、フォーカスした時点でテキストが隠れます。</p>
<p><img alt="placeholder が消えない: 対処済み" src="http://understandard.net/images/post/css/012/css012-2.png" title="placeholder が消えない: 対処済み" class="alignnone" width="630" height="100" /></p>
<h2>サンプル</h2>
<p><script type="text/javascript" src="http://jsdo.it/blogparts/1DOG/js?view=design"></script>
<p class="ttlBpJsdoit" style="width:465px; text-align: right; font-size: 11px;"><a href="http://jsdo.it/understandard/1DOG" title="Mac 版 Safari でフォーカス時に placeholder が消えない">Mac 版 Safari でフォーカス時に placeholder が消えない &#8211; jsdo.it &#8211; share JavaScript, HTML5 and CSS</a></p>
<p>背景色が白のサイトだったので、最初は <code>color: #ffffff;</code> にしてましたが、まとりん ( @ub_pnr ) に <code>transparent</code> でもいけるんじゃない？とアドバイスをもらい、試してみたところ問題なさそうだったので、<code>transparent</code> を採用しました。ありがとう、まとりん！</p>
<p>ちなみに、<code>opacity: 0;</code> も試してみましたが、こちらはうまくいきませんでした。</p>
<dl class="relatives">
<dt><span>関連投稿</span></dt>
<dd><ul>
<li>
<a href="http://www.understandard.net/css/css004.html" rel="bookmark">デフォルトスタイルのリセット</a><!-- (9.8)-->
<div class="info">
<span class="category">category: <a href="http://www.understandard.net/category/css" title="CSS の投稿をすべて表示" rel="category tag">CSS</a></span>
<span class="tags">tags: <a href="http://www.understandard.net/tag/css" rel="tag">CSS</a>+<a href="http://www.understandard.net/tag/tips" rel="tag">tips</a>.</span>
</div>
</li>
<li>
<a href="http://www.understandard.net/css/css011.html" rel="bookmark">display: inline-block を使う（修正版）</a><!-- (6.4)-->
<div class="info">
<span class="category">category: <a href="http://www.understandard.net/category/css" title="CSS の投稿をすべて表示" rel="category tag">CSS</a></span>
<span class="tags">tags: <a href="http://www.understandard.net/tag/css" rel="tag">CSS</a>+<a href="http://www.understandard.net/tag/tips" rel="tag">tips</a>.</span>
</div>
</li>
<li>
<a href="http://www.understandard.net/css/css009.html" rel="bookmark">table に指定しておきたい CSS メモ</a><!-- (5.6)-->
<div class="info">
<span class="category">category: <a href="http://www.understandard.net/category/css" title="CSS の投稿をすべて表示" rel="category tag">CSS</a></span>
<span class="tags">tags: <a href="http://www.understandard.net/tag/css" rel="tag">CSS</a>+<a href="http://www.understandard.net/tag/tips" rel="tag">tips</a>.</span>
</div>
</li>
</ul>
</dd>
</dl>
]]></content:encoded>
			<wfw:commentRss>http://www.understandard.net/css/css012.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>display: inline-block を使う（修正版）</title>
		<link>http://www.understandard.net/css/css011.html</link>
		<comments>http://www.understandard.net/css/css011.html#comments</comments>
		<pubDate>Mon, 04 Apr 2011 08:24:27 +0000</pubDate>
		<dc:creator>じゅん</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.understandard.net/?p=528</guid>
		<description><![CDATA[週末に @nagomu さんと @terkel さんが YUI grids.css や stacklayout.css で指定している word-spacing と letter-spacing の値はなんでこの値なんだ [...]<dl class="relatives">
<dt><span>関連投稿</span></dt>
<dd><ul>
<li>
<a href="http://www.understandard.net/css/css008.html" rel="bookmark">display:inline-block; を使う</a><!-- (36.8)-->
<div class="info">
<span class="category">category: <a href="http://www.understandard.net/category/css" title="CSS の投稿をすべて表示" rel="category tag">CSS</a></span>
<span class="tags">tags: <a href="http://www.understandard.net/tag/css" rel="tag">CSS</a>+<a href="http://www.understandard.net/tag/tips" rel="tag">tips</a>.</span>
</div>
</li>
<li>
<a href="http://www.understandard.net/css/css007.html" rel="bookmark">CSS でグラフを描く</a><!-- (9.5)-->
<div class="info">
<span class="category">category: <a href="http://www.understandard.net/category/css" title="CSS の投稿をすべて表示" rel="category tag">CSS</a></span>
<span class="tags">tags: <a href="http://www.understandard.net/tag/css" rel="tag">CSS</a>.</span>
</div>
</li>
<li>
<a href="http://www.understandard.net/css/css004.html" rel="bookmark">デフォルトスタイルのリセット</a><!-- (9.1)-->
<div class="info">
<span class="category">category: <a href="http://www.understandard.net/category/css" title="CSS の投稿をすべて表示" rel="category tag">CSS</a></span>
<span class="tags">tags: <a href="http://www.understandard.net/tag/css" rel="tag">CSS</a>+<a href="http://www.understandard.net/tag/tips" rel="tag">tips</a>.</span>
</div>
</li>
</ul>
</dd>
</dl>
]]></description>
			<content:encoded><![CDATA[<p>週末に <a href="http://twitter.com/#!/nagomu">@nagomu</a> さんと <a href="http://twitter.com/#!/terkel">@terkel</a> さんが <a href="http://yui.yahooapis.com/3.3.0/build/cssgrids/grids.css">YUI grids.css </a>や <a href="http://www.stacklayout.com/stacklayout.css">stacklayout.css</a> で指定している word-spacing と letter-spacing の値はなんでこの値なんだろうね、という話をされていて、おもしろそうだったので、数字の原因を探ったり、いろいろなブラウザーでチェックしてました。</p>
<p>いろいろなブラウザーでチェックをしている時に、以前書いた記事 <a href="http://www.understandard.net/css/css008.html">display:inline-block; を使う</a>で紹介していた CSS ではブラウザーごとに微妙な誤差があったので、修正版を書いてみました。</p>
<h2>以前書いていたコード</h2>
<pre>.parent {
letter-spacing: -.40em;
}

.child {
letter-spacing: normal;
vertical-align: top;
display: inline-block;
/display: inline;
/zoom: 1;
width: 100px; /* 任意の値 */
}</pre>
<div id="old" class="samplecode">
<ul class="parent">
<li class="child">古いバージョン古いバージョン古いバージョン</li>
<li class="child">古いバージョン</li>
<li class="child">古いバージョン古いバージョン</li>
<li class="child">古いバージョン</li>
</ul>
</div>
<p>こちらのコードでもうまくいくことが多いのですが、Windows 版の Opera で&lt;li&gt;の右側に空白が発生してしまいました（バージョン、ビルドが同じ Mac 版の Opera では問題なし）。</p>
<h2>YUI と StackLayout を参考にしてみたものの版</h2>
<p>次に YUI grids.css、stacklayout.css を参考に word-spacing を追加してみました。</p>
<p>word-spacing の値については、冒頭で紹介した @nagomu さんの記事で stacklayout.css と同じ（-0.65em）でいいんじゃないかという結論が出ていました。</p>
<p>なお、YUI grids.css の値だと、WebKit 系ブラウザーで以下の問題が出ました。</p>
<ul>
<li>文字サイズを拡大縮小した際に空白ができる</li>
<li>display: inline-block; された要素の親要素の文字サイズを変更する（font-size: 120% とか）と空白が出ることがある</li>
</ul>
<pre>.parent {
letter-spacing: -1em;
word-spacing: -1em;
width: 600px; /* 任意の値 */
}

.child {
letter-spacing: normal;
word-spacing: normal;
display: inline-block;
vertical-align: top;
/display: inline;
/zoom: 1;
width: 100px; /* 任意の値 */
}</pre>
<div id="test" class="samplecode">
<ul class="parent">
<li class="child">試してみたバージョン試してみたバージョン試してみたバージョン</li>
<li class="child">試してみたバージョン</li>
<li class="child">試してみたバージョン試してみたバージョン</li>
<li class="child">試してみたバージョン</li>
</ul>
</div>
<p>いろいろ試してみてた結果、上記の CSS を適用すれば Windows 版 Opera でもうまくいきましたが、WebKit 系のブラウザーで子要素が前にめり込むようになってしまいました。</p>
<p>WebKit 系向けの指定部分の letter-spacing: -1em; を削除するとめり込まなくなりますが、当然 WebKit 系の空白が埋められず。</p>
<h2>ちょっとチカラ技な気がするけどうまくいった版</h2>
<p>なんとかできないかといろいろ試した結果、以下の指定でなんとかなりました。<br />
1つ上のコードとの違いは、letter-spacing: -1em; を削除したことと display: table; を追加したこと。</p>
<pre>.parent {
word-spacing: -1em;
display: table;
width: 600px; /* 任意の値 */
}

.child {
word-spacing: normal;
display: inline-block;
vertical-align: top;
/display: inline;
/zoom: 1;
width: 100px; /* 任意の値 */
}</pre>
<div id="test2" class="samplecode">
<ul class="parent">
<li class="child">チカラ技バージョンチカラ技バージョンチカラ技バージョン</li>
<li class="child">チカラ技バージョン</li>
<li class="child">チカラ技バージョンチカラ技バージョン</li>
<li class="child">チカラ技バージョン</li>
</ul>
</div>
<p>word-spacing の値については、細かい検証は行なってません。<br />
数字が単純で、ちゃんと効いているようなのでひとまず。</p>
<p>動作は以下のブラウザーでチェック。</p>
<p>Windows: IE 6〜9, Firefox 4, Opera 11.01, Safari 5.0.4, Chrome 10.0<br />
Mac: Firefox 4, Opera 11.01, Safari 5.0.4, Chrome 10.0</p>
<p>うまく効いていない環境などありましたらご連絡いただければと思います。</p>
<p><ins datetime="2011-04-21T06:43:23+00:00"><span>※ 2011年4月21日</span>@terkel さんからのおかしくなるパターンと解決方法を教えていただきました。</ins></p>
<p>IE 8と IE 9で発生。<br />
子要素（ここでは .child ）に :hover を指定すると、親要素に :hover した際に最初の子要素が :hover 状態になってしまう。<br />
文章では分かりにくいので、サンプルを見てみてください。</p>
<pre>.parent {
word-spacing: -1em;
display: table;
width: 600px; /* 任意の値 */
}

.child {
word-spacing: normal;
display: inline-block;
vertical-align: top;
/display: inline;
/zoom: 1;
width: 100px; /* 任意の値 */
}

.child:hover {
cursor: pointer;
background: red;
}
</pre>
<div id="test3" class="samplecode">
<ul class="parent">
<li class="child">:hover を指定しておかしくなるパターン</li>
<li class="child">:hover を指定しておかしくなるパターン。:hover を指定しておかしくなるパターン</li>
<li class="child">:hover を指定しておかしくなるパターン</li>
<li class="child">:hover を指定しておかしくなるパターン。:hover を指定しておかしくなるパターン</li>
</ul>
</div>
<p>このサンプルで、子要素がないエリアでも ：hover が反応してしまっているのが分かるかと思います。</p>
<p>そして、これの解決方法は、親要素に display:block\9; を指定すること。<br />
「\9」の部分は IE 8と9用のハックです。</p>
<pre>.parent {
word-spacing: -1em;
display: table;
display: block\9; /* IE 8, 9用の指定 */
width: 600px; /* 任意の値 */
}

.child {
word-spacing: normal;
display: inline-block;
vertical-align: top;
/display: inline;
/zoom: 1;
width: 100px; /* 任意の値 */
}

.child:hover {
cursor: pointer;
background: red;
}
</pre>
<div id="test4" class="samplecode">
<ul class="parent">
<li class="child">:hover を指定しておかしくなるパターン解決版</li>
<li class="child">:hover を指定しておかしくなるパターン解決版。:hover を指定しておかしくなるパターン解決版</li>
<li class="child">:hover を指定しておかしくなるパターン解決版</li>
<li class="child">:hover を指定しておかしくなるパターン解決版。:hover を指定しておかしくなるパターン解決版</li>
</ul>
</div>
<p>問題の発見と解決方法を教えてくださった @terkel さん、ありがとうございます。</p>
<p>その他、うまく効いていない環境、パターンなどがありましたら教えてください。</p>
<dl class="relatives">
<dt><span>関連投稿</span></dt>
<dd><ul>
<li>
<a href="http://www.understandard.net/css/css008.html" rel="bookmark">display:inline-block; を使う</a><!-- (36.8)-->
<div class="info">
<span class="category">category: <a href="http://www.understandard.net/category/css" title="CSS の投稿をすべて表示" rel="category tag">CSS</a></span>
<span class="tags">tags: <a href="http://www.understandard.net/tag/css" rel="tag">CSS</a>+<a href="http://www.understandard.net/tag/tips" rel="tag">tips</a>.</span>
</div>
</li>
<li>
<a href="http://www.understandard.net/css/css007.html" rel="bookmark">CSS でグラフを描く</a><!-- (9.5)-->
<div class="info">
<span class="category">category: <a href="http://www.understandard.net/category/css" title="CSS の投稿をすべて表示" rel="category tag">CSS</a></span>
<span class="tags">tags: <a href="http://www.understandard.net/tag/css" rel="tag">CSS</a>.</span>
</div>
</li>
<li>
<a href="http://www.understandard.net/css/css004.html" rel="bookmark">デフォルトスタイルのリセット</a><!-- (9.1)-->
<div class="info">
<span class="category">category: <a href="http://www.understandard.net/category/css" title="CSS の投稿をすべて表示" rel="category tag">CSS</a></span>
<span class="tags">tags: <a href="http://www.understandard.net/tag/css" rel="tag">CSS</a>+<a href="http://www.understandard.net/tag/tips" rel="tag">tips</a>.</span>
</div>
</li>
</ul>
</dd>
</dl>
]]></content:encoded>
			<wfw:commentRss>http://www.understandard.net/css/css011.html/feed</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>マウスオーバー画像を作るのが面倒なとき用 CSS メモ</title>
		<link>http://www.understandard.net/css/css010.html</link>
		<comments>http://www.understandard.net/css/css010.html#comments</comments>
		<pubDate>Sun, 26 Dec 2010 13:48:52 +0000</pubDate>
		<dc:creator>じゅん</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.understandard.net/?p=429</guid>
		<description><![CDATA[サムネイルなどの画像の数が多くて、マウスオーバー用の画像を作るのが面倒なときに、CSS だけでそれっぽく見せるための方法。 ものすごく個人的メモ。 参考にさせていただいたのは、こちらの記事。 指定した要素を半透明にできる [...]<dl class="relatives">
<dt><span>関連投稿</span></dt>
<dd><ul>
<li>
<a href="http://www.understandard.net/css/css008.html" rel="bookmark">display:inline-block; を使う</a><!-- (3.8)-->
<div class="info">
<span class="category">category: <a href="http://www.understandard.net/category/css" title="CSS の投稿をすべて表示" rel="category tag">CSS</a></span>
<span class="tags">tags: <a href="http://www.understandard.net/tag/css" rel="tag">CSS</a>+<a href="http://www.understandard.net/tag/tips" rel="tag">tips</a>.</span>
</div>
</li>
<li>
<a href="http://www.understandard.net/css/css004.html" rel="bookmark">デフォルトスタイルのリセット</a><!-- (3)-->
<div class="info">
<span class="category">category: <a href="http://www.understandard.net/category/css" title="CSS の投稿をすべて表示" rel="category tag">CSS</a></span>
<span class="tags">tags: <a href="http://www.understandard.net/tag/css" rel="tag">CSS</a>+<a href="http://www.understandard.net/tag/tips" rel="tag">tips</a>.</span>
</div>
</li>
<li>
<a href="http://www.understandard.net/css/css009.html" rel="bookmark">table に指定しておきたい CSS メモ</a><!-- (3)-->
<div class="info">
<span class="category">category: <a href="http://www.understandard.net/category/css" title="CSS の投稿をすべて表示" rel="category tag">CSS</a></span>
<span class="tags">tags: <a href="http://www.understandard.net/tag/css" rel="tag">CSS</a>+<a href="http://www.understandard.net/tag/tips" rel="tag">tips</a>.</span>
</div>
</li>
</ul>
</dd>
</dl>
]]></description>
			<content:encoded><![CDATA[<p>サムネイルなどの画像の数が多くて、マウスオーバー用の画像を作るのが面倒なときに、CSS だけでそれっぽく見せるための方法。<br />
ものすごく個人的メモ。</p>
<p>参考にさせていただいたのは、こちらの記事。<br />
<a href="http://codersnote.com/archives/css-opacity"> 指定した要素を半透明にできるopacity（IEでも使える） | Coder&#8217;s Note</a></p>
<blockquote><pre><code>opacity: 0.5;
-moz-opacity: 0.5; /* Firefox */
filter: alpha(opacity=50); /* IE6/7 */
-ms-filter: "alpha(opacity=50)"; /* IE8 */</code></pre>
</blockquote>
<p>これの適用先をマウスオーバー時の画像にする。</p>
<pre>.hover a:hover img{
    opacity: 0.75;
    -moz-opacity: 0.75; /* Firefox */
    filter: alpha(opacity=75); /* IE6/7 */
    -ms-filter: "alpha(opacity=75)"; /* IE8 */
}</pre>
<p>50％だとさすがに透明すぎるので、75%くらいに設定することが多いですが、基本的にはこれをコピペで数字を変えるだけでオッケーなのです。ナイス！</p>
<p>毎回新規の id や class を作るのは CSS が長くなるだけなので、.hover のような class を作って指定したい箇所に付与していくのが無難な使い方になるのかなと思います。</p>
<p>ただし、これがうまくいくのは背景が単色の時だけです（特に白系の時）。<br />
画像半透明にしているので、背景が黒なら画像はグレーっぽくなるし、背景が画像ならそれが透けて見えてしまいます。<br />
そういった場合は、画像の1つ外側を囲むタグ（例えば div）の背景に白を指定することで解決。</p>
<p>場合によっては本来必要がなかったタグを追加したり、使用しにくい構造だったりしますが、画像を毎回作る手間を考えれば小さい手間じゃないでしょうか。</p>
<dl class="relatives">
<dt><span>関連投稿</span></dt>
<dd><ul>
<li>
<a href="http://www.understandard.net/css/css008.html" rel="bookmark">display:inline-block; を使う</a><!-- (3.8)-->
<div class="info">
<span class="category">category: <a href="http://www.understandard.net/category/css" title="CSS の投稿をすべて表示" rel="category tag">CSS</a></span>
<span class="tags">tags: <a href="http://www.understandard.net/tag/css" rel="tag">CSS</a>+<a href="http://www.understandard.net/tag/tips" rel="tag">tips</a>.</span>
</div>
</li>
<li>
<a href="http://www.understandard.net/css/css004.html" rel="bookmark">デフォルトスタイルのリセット</a><!-- (3)-->
<div class="info">
<span class="category">category: <a href="http://www.understandard.net/category/css" title="CSS の投稿をすべて表示" rel="category tag">CSS</a></span>
<span class="tags">tags: <a href="http://www.understandard.net/tag/css" rel="tag">CSS</a>+<a href="http://www.understandard.net/tag/tips" rel="tag">tips</a>.</span>
</div>
</li>
<li>
<a href="http://www.understandard.net/css/css009.html" rel="bookmark">table に指定しておきたい CSS メモ</a><!-- (3)-->
<div class="info">
<span class="category">category: <a href="http://www.understandard.net/category/css" title="CSS の投稿をすべて表示" rel="category tag">CSS</a></span>
<span class="tags">tags: <a href="http://www.understandard.net/tag/css" rel="tag">CSS</a>+<a href="http://www.understandard.net/tag/tips" rel="tag">tips</a>.</span>
</div>
</li>
</ul>
</dd>
</dl>
]]></content:encoded>
			<wfw:commentRss>http://www.understandard.net/css/css010.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>table に指定しておきたい CSS メモ</title>
		<link>http://www.understandard.net/css/css009.html</link>
		<comments>http://www.understandard.net/css/css009.html#comments</comments>
		<pubDate>Wed, 30 Jun 2010 14:55:33 +0000</pubDate>
		<dc:creator>じゅん</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.understandard.net/?p=339</guid>
		<description><![CDATA[table 関係で調べ物をしていたときに見かけた、Takazudo さんの zudolog » tableのcellspacing=”0″を消すためにという記事の中で tableのcellspacing=&#8221;0 [...]<dl class="relatives">
<dt><span>関連投稿</span></dt>
<dd><ul>
<li>
<a href="http://www.understandard.net/css/css004.html" rel="bookmark">デフォルトスタイルのリセット</a><!-- (9.8)-->
<div class="info">
<span class="category">category: <a href="http://www.understandard.net/category/css" title="CSS の投稿をすべて表示" rel="category tag">CSS</a></span>
<span class="tags">tags: <a href="http://www.understandard.net/tag/css" rel="tag">CSS</a>+<a href="http://www.understandard.net/tag/tips" rel="tag">tips</a>.</span>
</div>
</li>
<li>
<a href="http://www.understandard.net/firefox/firefox010.html" rel="bookmark">Firefox のキーボードショートカットのチートシート</a><!-- (5.6)-->
<div class="info">
<span class="category">category: <a href="http://www.understandard.net/category/firefox" title="Firefox の投稿をすべて表示" rel="category tag">Firefox</a></span>
<span class="tags">tags: <a href="http://www.understandard.net/tag/firefox" rel="tag">Firefox</a>+<a href="http://www.understandard.net/tag/tips" rel="tag">tips</a>.</span>
</div>
</li>
<li>
<a href="http://www.understandard.net/css/css008.html" rel="bookmark">display:inline-block; を使う</a><!-- (3)-->
<div class="info">
<span class="category">category: <a href="http://www.understandard.net/category/css" title="CSS の投稿をすべて表示" rel="category tag">CSS</a></span>
<span class="tags">tags: <a href="http://www.understandard.net/tag/css" rel="tag">CSS</a>+<a href="http://www.understandard.net/tag/tips" rel="tag">tips</a>.</span>
</div>
</li>
</ul>
</dd>
</dl>
]]></description>
			<content:encoded><![CDATA[<p>table 関係で調べ物をしていたときに見かけた、Takazudo さんの <a href="http://zudolab.net/blog/?p=12">zudolog » tableのcellspacing=”0″を消すために</a>という記事の中で</p>
<blockquote title="zudolog » tableのcellspacing=”0″を消すために" cite="http://zudolab.net/blog/?p=12"><p>tableのcellspacing=&#8221;0&#8243;が必要なことはかなり多い。<br />
しかし、これと同じことをしてくれるCSSのプロパティ、border-spacing:0 は、IE7以下では対応していない。そこで登場するのがborder-collapse:collapse なのだけれど、これにもまた問題がある。そんなこんなを解決するTips。やりたいのはcellspacing=&#8221;0&#8243;を入れたくないってだけですが。</p></blockquote>
<p>という一文。一文というより最後の一言がグッときましたね。<br />
そうそう、<strong>HTML 側に余計なもの書き込みたくない</strong>んですよね。それだけ。</p>
<p>できるだけキレイな HTML、CSS を組みたいものです。<br />
このブログはいろいろ汚いとこがあるので、ちょっとずつ直していきます…。</p>
<p>ということで、Takazudo さんの書いていた CSS を自分向けに改変したものをメモ。</p>
<pre>table{
width:auto;
border-spacing:0;
border-collapse:separate;
/border-collapse:collapse; /* ie6,7 */
border-right:1px solid #333333;
border-bottom:1px solid #333333;
table-layout:fixed;
word-break:break-all;
word-wrap:break-word;
}

th, td{
border-top:1px solid #333333;
border-left:1px solid #333333;
padding:5px;
}</pre>
<p>Takazudo さんのサンプルに追加して、「table-layout:fixed;」、「word-break:break-all;」、「word-wrap:break-word;」を指定しています（プロパティの順番も変更）。</p>
<h2>追加したもの</h2>
<h3>table-layout:fixed;</h3>
<p>この指定を入れておくと、セルの横幅が以下のようになります。</p>
<ul>
<li>各セルの幅を指定していればそのサイズに</li>
<li>指定していない場合はセルの数で均等に分割</li>
</ul>
<p>table-layout はデフォルトが auto なので、自動で幅を調整してくれる方がいいなら、この指定を外すか該当する箇所で上書きすればいいと思います。</p>
<p>また、この指定をしておくと最初の一行目を読み込んだ時点で各列の幅を固定して表示を開始するため、 表示が速くなるメリットがあるそうです（参考: <a href="http://www.htmq.com/style/table-layout.shtml">table-layout－スタイ ルシートリファレンス</a>）。</p>
<p>回線速度自体が結構早くなっているので、そこまで気にする必要はないかもしれないですが。</p>
<h3>word-break:break-all; と word-wrap:break-word;</h3>
<p>これらの指定は、セル幅を超える長い単語や URL を強制的に折り返させるために入れています。<br />
日本語をエンコードした URL が表示された場合などに word-wrap:break-word; の指定をしていないとセルを突き破って表示しちゃいます。</p>
<dl>
<dt>指定なし</dt>
<dd>IE6, IE8, Fx 3.6, Chrome 6.0, Safari 5 で突き破る</dd>
<dt>word-wrap:break-word; のみ指定</dt>
<dd>IE6, IE8, Fx 3.6, Chrome 6.0, Safari 5 でオッケー</dd>
<dt>word-break:break-all; のみ指定</dt>
<dd>Fx 3.6 で突き破る</dd>
<dt>両方指定</dt>
<dd>IE6, IE8, Fx 3.6, Chrome 6.0, Safari 5 でオッケー</dd>
</dl>
<p>ということで、セル内で改行させるという本来の目的は果たせているので、word-wrap:break-word; の指定だけでもいいのですが、その場合には <strong>IE だけ改行位置が変わってしまいます</strong>。</p>
<p>そもそもなんでこの指定（word-break:break-all;）を入れたのかを覚えていないのですが、word-break:break-all; を加えると、IE と他のモダンブラウザ間で表示が近くなるので外さずに残しています。</p>
<p>原因が分からないので、また時間があるときにでも調べてみようと思います。<br />
原因が分かる方、うまくいかないパターンを発見された方がいらっしゃいましたら、ぜひ教えていただければと思います。</p>
<dl class="relatives">
<dt><span>関連投稿</span></dt>
<dd><ul>
<li>
<a href="http://www.understandard.net/css/css004.html" rel="bookmark">デフォルトスタイルのリセット</a><!-- (9.8)-->
<div class="info">
<span class="category">category: <a href="http://www.understandard.net/category/css" title="CSS の投稿をすべて表示" rel="category tag">CSS</a></span>
<span class="tags">tags: <a href="http://www.understandard.net/tag/css" rel="tag">CSS</a>+<a href="http://www.understandard.net/tag/tips" rel="tag">tips</a>.</span>
</div>
</li>
<li>
<a href="http://www.understandard.net/firefox/firefox010.html" rel="bookmark">Firefox のキーボードショートカットのチートシート</a><!-- (5.6)-->
<div class="info">
<span class="category">category: <a href="http://www.understandard.net/category/firefox" title="Firefox の投稿をすべて表示" rel="category tag">Firefox</a></span>
<span class="tags">tags: <a href="http://www.understandard.net/tag/firefox" rel="tag">Firefox</a>+<a href="http://www.understandard.net/tag/tips" rel="tag">tips</a>.</span>
</div>
</li>
<li>
<a href="http://www.understandard.net/css/css008.html" rel="bookmark">display:inline-block; を使う</a><!-- (3)-->
<div class="info">
<span class="category">category: <a href="http://www.understandard.net/category/css" title="CSS の投稿をすべて表示" rel="category tag">CSS</a></span>
<span class="tags">tags: <a href="http://www.understandard.net/tag/css" rel="tag">CSS</a>+<a href="http://www.understandard.net/tag/tips" rel="tag">tips</a>.</span>
</div>
</li>
</ul>
</dd>
</dl>
]]></content:encoded>
			<wfw:commentRss>http://www.understandard.net/css/css009.html/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: www.understandard.net @ 2012-02-05 22:41:34 -->
