<?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>OTCHY.NET &#187; html</title>
	<atom:link href="http://www.otchy.net/tag/html/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.otchy.net</link>
	<description>Otchy の技術ネタ。JavaScript 率と Twitter 率がやや高く、他にも PHP/Java/Perl などなど。共通点は Web。</description>
	<lastBuildDate>Wed, 01 Feb 2012 14:39:17 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>プログラマにも書ける！画像を使わずCSS3でつくる今風のタブ＋ツールバー</title>
		<link>http://www.otchy.net/20110906/css3-tab-toolbar/</link>
		<comments>http://www.otchy.net/20110906/css3-tab-toolbar/#comments</comments>
		<pubDate>Tue, 06 Sep 2011 05:31:25 +0000</pubDate>
		<dc:creator>Otchy</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>

		<guid isPermaLink="false">http://www.otchy.net/?p=1408</guid>
		<description><![CDATA[TwitMgrのリニューアルに際して、今風のタブとツールバーを CSS3 だけで書いたので、その内容を順を追って説明してみます。
完成品
こんな感じのタブとツールバーを、CSS 3 だけで書いていきます。

.finis [...]]]></description>
			<content:encoded><![CDATA[<p><a href="/twitmgr/" target="_blank">TwitMgr</a>のリニューアルに際して、今風のタブとツールバーを CSS3 だけで書いたので、その内容を順を追って説明してみます。</p>
<h4>完成品</h4>
<p>こんな感じのタブとツールバーを、CSS 3 だけで書いていきます。</p>
<style>
.finish .tab {
	margin: 10px 5px 0 0;
	padding: 5px 7px;
	float: left;
	height: 14px;
	color: #383;
	border-style: solid;
	border-color: #383;
	border-width: 1px 1px 0 1px;
	-webkit-border-top-left-radius: 5px;
	-moz-border-radius-topleft: 5px;
	border-top-left-radius: 5px;
	cursor: pointer;
}
.finish .tab:hover {
	padding-top: 7px;
	margin-top: 8px;
}
.finish .selected {
	height: 16px;
	margin-bottom: -2px;
	background-color: #5a5;
	border-color: #373;
	border-bottom: 1px #5a5;
	padding-right: 8px;
	-webkit-box-shadow: 1px 1px 0 #9c9 inset;
	-moz-box-shadow: 1px 1px 0 #9c9 inset;
	box-shadow: 1px 1px 0 #9c9 inset;
	color: #fff;
	text-shadow: 0 1px 0 #333;
}
.finish .toolbar {
	clear: both;
	background-color: #5a5;
	background: -webkit-linear-gradient(top, #5a5 1%, #383 100%);
	background: -moz-linear-gradient(top, #5a5 1%, #383 100%);
	background: linear-gradient(top, #5a5 1%,#383 100%);
	border: solid 1px #373;
	-webkit-box-shadow: 1px 1px 0 #9c9 inset;
	-moz-box-shadow: 1px 1px 0 #9c9 inset;
	box-shadow: 1px 1px 0 #9c9 inset;
	height: 30px;
}
.finish .toolbar .pager {
	display: block;
	float: right;
	margin: 6px;
}
.finish .toolbar .pager li {
	display: block;
	float: left;
	margin-left: 2px;
	text-align: center;
	font-size: 90%;
	color: #fff;
}
.finish .toolbar .pager li.button {
	width: 20px;
	padding: 1px;
	border: solid 1px;
	-webkit-border-radius: 3px;
	-moz-border-radius: 3px;
	border-radius: 3px;
}
.finish .toolbar .pager li.enable {
	cursor: pointer;
	border-color: rgba(255, 255, 255, 0.5);
}
.finish .toolbar .pager li.enable:hover {
	background-color: rgba(255, 255, 255, 0.3);
}
.finish .toolbar .pager li.current {
	border-color: rgba(255, 255, 255, 0.5);
	background-color: rgba(255, 255, 255, 0.3);
	text-shadow: 0 1px 0 #333;
}
.finish .toolbar .pager li.period {
	width: auto;
	padding: 1px 2px;
	border: 0;
}
</style>
<div class="finish">
<div class="tab selected">フォローしている</div>
<div class="tab">フォローされている</div>
<div class="toolbar">
<ul class="pager">
<li class="button enable">1</li>
<li class="button enable">2</li>
<li class="button current">3</li>
<li class="button enable">4</li>
<li class="button enable">5</li>
<li class="period">&#8230;</li>
<li class="button enable">≫</li>
</ul>
</div>
</div>
<h4>マークアップ</h4>
<p>実際の TwitMgr で使ってるものとは違いますが、説明の都合上 HTML は下記のようなマークアップで行います。まだ何も CSS を適用していない状態なので、何がなにやらという状態ですね。</p>
<pre>
&lt;div class=&quot;tab selected&quot;&gt;フォローしている&lt;/div&gt;
&lt;div class=&quot;tab&quot;&gt;フォローされている&lt;/div&gt;
&lt;div class=&quot;toolbar&quot;&gt;
&lt;ul class=&quot;pager&quot;&gt;
  &lt;li class=&quot;button enable&quot;&gt;1&lt;/li&gt;
  &lt;li class=&quot;button enable&quot;&gt;2&lt;/li&gt;
  &lt;li class=&quot;button current&quot;&gt;3&lt;/li&gt;
  &lt;li class=&quot;button enable&quot;&gt;4&lt;/li&gt;
  &lt;li class=&quot;button enable&quot;&gt;5&lt;/li&gt;
  &lt;li class=&quot;period&quot;&gt;...&lt;/li&gt;
  &lt;li class=&quot;button enable&quot;&gt;≫&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</pre>
<div class="step1">
<div class="tab selected">フォローしている</div>
<div class="tab">フォローされている</div>
<div class="toolbar">
<ul class="pager">
<li class="button enable">1</li>
<li class="button enable">2</li>
<li class="button current">3</li>
<li class="button enable">4</li>
<li class="button enable">5</li>
<li class="period">&#8230;</li>
<li class="button enable">≫</li>
</ul>
</div>
</div>
<h4>レイアウト</h4>
<p>各部品の場所を決めていきます。位置関係が分かりやすいよう、仮で青のボーダーを入れました。ここはあまり特筆する点がありませんね。display と float を使って、適切な位置に要素を配置していくだけです。</p>
<style>
.step2 * {border: solid 1px blue;}
.step2 .tab {
  margin: 10px 5px 0 0;
  padding: 5px 7px;
  float: left;
  height: 14px;
}
.step2 .toolbar {
  clear: both;
  height: 30px;
}
.step2 .toolbar .pager {
  display: block;
  float: right;
  margin: 6px;
}
.step2 .toolbar .pager li {
  display: block;
  float: left;
  margin-left: 2px;
}
.step2 .toolbar .pager li.button {
  width: 20px;
  padding: 1px;
}
.step2 .toolbar .pager li.period {
  width: auto;
  padding: 1px 2px;
}
</style>
<pre class="height_narrow">
.tab {
  margin: 10px 5px 0 0;
  padding: 5px 7px;
  float: left;
  height: 14px;
}
.toolbar {
  clear: both;
  height: 30px;
}
.toolbar .pager {
  display: block;
  float: right;
  margin: 6px;
}
.toolbar .pager li {
  display: block;
  float: left;
  margin-left: 2px;
}
.toolbar .pager li.button {
  width: 20px;
  padding: 1px;
}
.toolbar .pager li.period {
  width: auto;
  padding: 1px 2px;
}
</pre>
<div class="step2">
<div class="tab selected">フォローしている</div>
<div class="tab">フォローされている</div>
<div class="toolbar">
<ul class="pager">
<li class="button enable">1</li>
<li class="button enable">2</li>
<li class="button current">3</li>
<li class="button enable">4</li>
<li class="button enable">5</li>
<li class="period">&#8230;</li>
<li class="button enable">≫</li>
</ul>
</div>
</div>
<h4>色の指定</h4>
<p>文字の色と背景色を指定しました。普通に color と background-color を指定しただけですが、css3 らしい事としては、選択中のページを表す li.current に半透明の白色を指定する事で、その部分がハイライトされたような効果を出しています。<br />
このようにする事で、背景色が変わったとしてもハイライト色を変える必要が無くなります。</p>
<style>
.step3 .tab {
	margin: 10px 5px 0 0;
	padding: 5px 7px;
	float: left;
	height: 14px;
	color: #383;
}
.step3 .selected {
	background-color: #5a5;
	color: #fff;
}
.step3 .toolbar {
	clear: both;
	height: 30px;
	background-color: #5a5;
}
.step3 .toolbar .pager {
	display: block;
	float: right;
	margin: 6px;
}
.step3 .toolbar .pager li {
	display: block;
	float: left;
	margin-left: 2px;
	color: #fff;
}
.step3 .toolbar .pager li.button {
	width: 20px;
	padding: 1px;
}
.step3 .toolbar .pager li.current {
	background-color: rgba(255, 255, 255, 0.3);
}
.step3 .toolbar .pager li.period {
	width: auto;
	padding: 1px 2px;
}
</style>
<pre class="height_narrow">
.tab {
  margin: 10px 5px 0 0;
  padding: 5px 7px;
  float: left;
  height: 14px;
  color: #383;
}
.selected {
  background-color: #5a5;
  color: #fff;
}
.toolbar {
  clear: both;
  height: 30px;
  background-color: #5a5;
}
.toolbar .pager {
  display: block;
  float: right;
  margin: 6px;
}
.toolbar .pager li {
  display: block;
  float: left;
  margin-left: 2px;
  color: #fff;
}
.toolbar .pager li.button {
  width: 20px;
  padding: 1px;
}
.toolbar .pager li.current {
<span style="color:blue;">  background-color: rgba(255, 255, 255, 0.3);</span>
}
.toolbar .pager li.period {
  width: auto;
  padding: 1px 2px;
}
</pre>
<div class="step3">
<div class="tab selected">フォローしている</div>
<div class="tab">フォローされている</div>
<div class="toolbar">
<ul class="pager">
<li class="button enable">1</li>
<li class="button enable">2</li>
<li class="button current">3</li>
<li class="button enable">4</li>
<li class="button enable">5</li>
<li class="period">&#8230;</li>
<li class="button enable">≫</li>
</ul>
</div>
</div>
<h4>ボーダーの指定</h4>
<p>今度は各要素のボーダーを指定していきます。<br />
いわゆる角丸を多用しています。四隅の特定の角だけを丸める事もできるので、タブっぽいデザインを書く時に便利です。ここまでくると何となくそれらしくなってきますね。</p>
<p>ページャー部分のボーダーは、背景色に合わせて半透明の白色にしています。背景色も文字もそれに含まれる要素も、全て一斉に半透明にする時は opacity で、背景色・ボーダーなど部分に応じて半透明にする時は rgba という使い分けをすると吉です。</p>
<p>またベンダープレフィックスとしてここでは、webkit (Chrome / Safari 等) と moz (Firefox 等) を付けています。他にも o (Opera) や ms (IE8+) もあるので、必要に応じて使い分けて下さい。</p>
<p>ただ、この状態では当たり前なのですが、選択中のタブとツールバーの間にも線が見えてしまっていますね。ここは綺麗に繋がってくれないと困ります。この問題は後で解決します。</p>
<style>
.step4 .tab {
  margin: 10px 5px 0 0;
  padding: 5px 7px;
  float: left;
  height: 14px;
  color: #383;
  border-style: solid;
  border-color: #383;
  border-width: 1px 1px 0 1px;
  -webkit-border-top-left-radius: 5px;
  -moz-border-radius-topleft: 5px;
  border-top-left-radius: 5px;
}
.step4 .selected {
  background-color: #5a5;
  color: #fff;
  border-color: #373;
  border-bottom: 1px #5a5;
}
.step4 .toolbar {
  clear: both;
  height: 30px;
  background-color: #5a5;
  border: solid 1px #373;
}
.step4 .toolbar .pager {
  display: block;
  float: right;
  margin: 6px;
}
.step4 .toolbar .pager li {
  display: block;
  float: left;
  margin-left: 2px;
  color: #fff;
}
.step4 .toolbar .pager li.button {
  width: 20px;
  padding: 1px;
  border: solid 1px;
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  border-radius: 3px;
}
.step4 .toolbar .pager li.enable {
  border-color: rgba(255, 255, 255, 0.5);
}
.step4 .toolbar .pager li.current {
  background-color: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
}
.step4 .toolbar .pager li.period {
  width: auto;
  padding: 1px 2px;
  border: 0;
}
</style>
<pre class="height_narrow">
.tab {
  margin: 10px 5px 0 0;
  padding: 5px 7px;
  float: left;
  height: 14px;
  color: #383;
  border-style: solid;
  border-color: #383;
  border-width: 1px 1px 0 1px;
<span style="color:blue;">  -webkit-border-top-left-radius: 5px;</span>
<span style="color:blue;">  -moz-border-radius-topleft: 5px;</span>
<span style="color:blue;">  border-top-left-radius: 5px;</span>
}
.selected {
  background-color: #5a5;
  color: #fff;
  border-color: #373;
  border-bottom: 1px #5a5;
}
.toolbar {
  clear: both;
  height: 30px;
  background-color: #5a5;
  border: solid 1px #373;
}
.toolbar .pager {
  display: block;
  float: right;
  margin: 6px;
}
.toolbar .pager li {
  display: block;
  float: left;
  margin-left: 2px;
  color: #fff;
}
.toolbar .pager li.button {
  width: 20px;
  padding: 1px;
  border: solid 1px;
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  border-radius: 3px;
}
.toolbar .pager li.enable {
<span style="color:blue;">  border-color: rgba(255, 255, 255, 0.5);</span>
}
.toolbar .pager li.current {
  background-color: rgba(255, 255, 255, 0.3);
<span style="color:blue;">  border-color: rgba(255, 255, 255, 0.5);</span>
}
.toolbar .pager li.period {
  width: auto;
  padding: 1px 2px;
  border: 0;
}
</pre>
<div class="step4">
<div class="tab selected">フォローしている</div>
<div class="tab">フォローされている</div>
<div class="toolbar">
<ul class="pager">
<li class="button enable">1</li>
<li class="button enable">2</li>
<li class="button current">3</li>
<li class="button enable">4</li>
<li class="button enable">5</li>
<li class="period">&#8230;</li>
<li class="button enable">≫</li>
</ul>
</div>
</div>
<h4>グラデーションの指定</h4>
<p>ツールバー部分にグラデーションをかけました。グラデーションの上端の色を選択中のタブの色と合わせる事で、シームレスに繋がるようにします。<br />
このグラデーションの指定ですが、手作業で書くにはちょっと辛いので、<a href="http://www.colorzilla.com/gradient-editor/" target="_blank">Ultimate CSS Gradient Generator</a> のようなジェネレータを使って書くのが良いかと思います。<br />
ベンダープレフィックス付きの css を出力してくれるので、そのまま貼り付けるだけになります。</p>
<style>
.step5 .tab {
  margin: 10px 5px 0 0;
  padding: 5px 7px;
  float: left;
  height: 14px;
  color: #383;
  border-style: solid;
  border-color: #383;
  border-width: 1px 1px 0 1px;
  -webkit-border-top-left-radius: 5px;
  -moz-border-radius-topleft: 5px;
  border-top-left-radius: 5px;
}
.step5 .selected {
  background-color: #5a5;
  color: #fff;
  border-color: #373;
  border-bottom: 1px #5a5;
}
.step5 .toolbar {
  clear: both;
  height: 30px;
  background-color: #5a5;
  border: solid 1px #373;
  background: -webkit-linear-gradient(top, #5a5 1%, #383 100%);
  background: -moz-linear-gradient(top, #5a5 1%, #383 100%);
  background: linear-gradient(top, #5a5 1%,#383 100%);
}
.step5 .toolbar .pager {
  display: block;
  float: right;
  margin: 6px;
}
.step5 .toolbar .pager li {
  display: block;
  float: left;
  margin-left: 2px;
  color: #fff;
}
.step5 .toolbar .pager li.button {
  width: 20px;
  padding: 1px;
  border: solid 1px;
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  border-radius: 3px;
}
.step5 .toolbar .pager li.enable {
  border-color: rgba(255, 255, 255, 0.5);
}
.step5 .toolbar .pager li.current {
  background-color: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
}
.step5 .toolbar .pager li.period {
  width: auto;
  padding: 1px 2px;
  border: 0;
}
</style>
<pre class="height_narrow">
.tab {
  margin: 10px 5px 0 0;
  padding: 5px 7px;
  float: left;
  height: 14px;
  color: #383;
  border-style: solid;
  border-color: #383;
  border-width: 1px 1px 0 1px;
  -webkit-border-top-left-radius: 5px;
  -moz-border-radius-topleft: 5px;
  border-top-left-radius: 5px;
}
.selected {
  background-color: #5a5;
  color: #fff;
  border-color: #373;
  border-bottom: 1px #5a5;
}
.toolbar {
  clear: both;
  height: 30px;
  background-color: #5a5;
  border: solid 1px #373;
<span style="color:blue;">  background: -webkit-linear-gradient(top, #5a5 1%, #383 100%);</span>
<span style="color:blue;">  background: -moz-linear-gradient(top, #5a5 1%, #383 100%);</span>
<span style="color:blue;">  background: linear-gradient(top, #5a5 1%,#383 100%);</span>
}
.toolbar .pager {
  display: block;
  float: right;
  margin: 6px;
}
.toolbar .pager li {
  display: block;
  float: left;
  margin-left: 2px;
  color: #fff;
}
.toolbar .pager li.button {
  width: 20px;
  padding: 1px;
  border: solid 1px;
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  border-radius: 3px;
}
.toolbar .pager li.enable {
  border-color: rgba(255, 255, 255, 0.5);
}
.toolbar .pager li.current {
  background-color: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
}
.toolbar .pager li.period {
  width: auto;
  padding: 1px 2px;
  border: 0;
}
</pre>
<div class="step5">
<div class="tab selected">フォローしている</div>
<div class="tab">フォローされている</div>
<div class="toolbar">
<ul class="pager">
<li class="button enable">1</li>
<li class="button enable">2</li>
<li class="button current">3</li>
<li class="button enable">4</li>
<li class="button enable">5</li>
<li class="period">&#8230;</li>
<li class="button enable">≫</li>
</ul>
</div>
</div>
<h4>1px ラインの追加</h4>
<p>デザイン系の記事で良く取り上げられる、1px の魔法を css で追加します。<br />
具体的には右に 1px、下に 1px、ぼかし無しの状態で、要素の内側にボックスシャドウをかけます。こうするとちょうど、左上に 1px のラインを引いたような効果が出せます。</p>
<style>
.step6 .tab {
  margin: 10px 5px 0 0;
  padding: 5px 7px;
  float: left;
  height: 14px;
  color: #383;
  border-style: solid;
  border-color: #383;
  border-width: 1px 1px 0 1px;
  -webkit-border-top-left-radius: 5px;
  -moz-border-radius-topleft: 5px;
  border-top-left-radius: 5px;
}
.step6 .selected {
  background-color: #5a5;
  color: #fff;
  border-color: #373;
  border-bottom: 1px #5a5;
  padding-right: 8px;
  -webkit-box-shadow: 1px 1px 0 #9c9 inset;
  -moz-box-shadow: 1px 1px 0 #9c9 inset;
  box-shadow: 1px 1px 0 #9c9 inset;
}
.step6 .toolbar {
  clear: both;
  height: 30px;
  background-color: #5a5;
  border: solid 1px #373;
  background: -webkit-linear-gradient(top, #5a5 1%, #383 100%);
  background: -moz-linear-gradient(top, #5a5 1%, #383 100%);
  background: linear-gradient(top, #5a5 1%,#383 100%);
  -webkit-box-shadow: 1px 1px 0 #9c9 inset;
  -moz-box-shadow: 1px 1px 0 #9c9 inset;
  box-shadow: 1px 1px 0 #9c9 inset;
}
.step6 .toolbar .pager {
  display: block;
  float: right;
  margin: 6px;
}
.step6 .toolbar .pager li {
  display: block;
  float: left;
  margin-left: 2px;
  color: #fff;
}
.step6 .toolbar .pager li.button {
  width: 20px;
  padding: 1px;
  border: solid 1px;
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  border-radius: 3px;
}
.step6 .toolbar .pager li.enable {
  border-color: rgba(255, 255, 255, 0.5);
}
.step6 .toolbar .pager li.current {
  background-color: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
}
.step6 .toolbar .pager li.period {
  width: auto;
  padding: 1px 2px;
  border: 0;
}
</style>
<pre class="height_narrow">
.tab {
  margin: 10px 5px 0 0;
  padding: 5px 7px;
  float: left;
  height: 14px;
  color: #383;
  border-style: solid;
  border-color: #383;
  border-width: 1px 1px 0 1px;
  -webkit-border-top-left-radius: 5px;
  -moz-border-radius-topleft: 5px;
  border-top-left-radius: 5px;
}
.selected {
  background-color: #5a5;
  color: #fff;
  border-color: #373;
  border-bottom: 1px #5a5;
  padding-right: 8px;
<span style="color:blue;">  -webkit-box-shadow: 1px 1px 0 #9c9 inset;</span>
<span style="color:blue;">  -moz-box-shadow: 1px 1px 0 #9c9 inset;</span>
<span style="color:blue;">  box-shadow: 1px 1px 0 #9c9 inset;</span>
}
.toolbar {
  clear: both;
  height: 30px;
  background-color: #5a5;
  border: solid 1px #373;
  background: -webkit-linear-gradient(top, #5a5 1%, #383 100%);
  background: -moz-linear-gradient(top, #5a5 1%, #383 100%);
  background: linear-gradient(top, #5a5 1%,#383 100%);
<span style="color:blue;">  -webkit-box-shadow: 1px 1px 0 #9c9 inset;</span>
<span style="color:blue;">  -moz-box-shadow: 1px 1px 0 #9c9 inset;</span>
<span style="color:blue;">  box-shadow: 1px 1px 0 #9c9 inset;</span>
}
.toolbar .pager {
  display: block;
  float: right;
  margin: 6px;
}
.toolbar .pager li {
  display: block;
  float: left;
  margin-left: 2px;
  color: #fff;
}
.toolbar .pager li.button {
  width: 20px;
  padding: 1px;
  border: solid 1px;
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  border-radius: 3px;
}
.toolbar .pager li.enable {
  border-color: rgba(255, 255, 255, 0.5);
}
.toolbar .pager li.current {
  background-color: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
}
.toolbar .pager li.period {
  width: auto;
  padding: 1px 2px;
  border: 0;
}
</pre>
<div class="step6">
<div class="tab selected">フォローしている</div>
<div class="tab">フォローされている</div>
<div class="toolbar">
<ul class="pager">
<li class="button enable">1</li>
<li class="button enable">2</li>
<li class="button current">3</li>
<li class="button enable">4</li>
<li class="button enable">5</li>
<li class="period">&#8230;</li>
<li class="button enable">≫</li>
</ul>
</div>
</div>
<h4>タブとツールバーをつなぐ</h4>
<p>ボーダーを追加して以来ずっと気になっていた、選択中のタブとツールバーの間の線を隠します。<br />
まずタブの高さ自体がそもそも 14px になっているので、選択中のタブはそれにボーダー幅 1px と、ボックスシャドウ幅 1px を足した 16px にします。<br />
そのままだと、非選択のタブと選択中のタブの高さが変わって、片方が浮いてしまう感じになるので、さらに margin-bottom を -2px にします。</p>
<p>こうする事で選択中のタブが占める高さは非選択のタブと同じ高さになるものの、背景の描画自体は 2px 分下に伸びる形になるので、ツールバーとの間にあった線を隠す事ができます。</p>
<style>
.step7 .tab {
  margin: 10px 5px 0 0;
  padding: 5px 7px;
  float: left;
  height: 14px;
  color: #383;
  border-style: solid;
  border-color: #383;
  border-width: 1px 1px 0 1px;
  -webkit-border-top-left-radius: 5px;
  -moz-border-radius-topleft: 5px;
  border-top-left-radius: 5px;
}
.step7 .selected {
  height: 16px;
  margin-bottom: -2px;
  background-color: #5a5;
  color: #fff;
  border-color: #373;
  border-bottom: 1px #5a5;
  padding-right: 8px;
  -webkit-box-shadow: 1px 1px 0 #9c9 inset;
  -moz-box-shadow: 1px 1px 0 #9c9 inset;
  box-shadow: 1px 1px 0 #9c9 inset;
}
.step7 .toolbar {
  clear: both;
  height: 30px;
  background-color: #5a5;
  border: solid 1px #373;
  background: -webkit-linear-gradient(top, #5a5 1%, #383 100%);
  background: -moz-linear-gradient(top, #5a5 1%, #383 100%);
  background: linear-gradient(top, #5a5 1%,#383 100%);
  -webkit-box-shadow: 1px 1px 0 #9c9 inset;
  -moz-box-shadow: 1px 1px 0 #9c9 inset;
  box-shadow: 1px 1px 0 #9c9 inset;
}
.step7 .toolbar .pager {
  display: block;
  float: right;
  margin: 6px;
}
.step7 .toolbar .pager li {
  display: block;
  float: left;
  margin-left: 2px;
  color: #fff;
}
.step7 .toolbar .pager li.button {
  width: 20px;
  padding: 1px;
  border: solid 1px;
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  border-radius: 3px;
}
.step7 .toolbar .pager li.enable {
  border-color: rgba(255, 255, 255, 0.5);
}
.step7 .toolbar .pager li.current {
  background-color: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
}
.step7 .toolbar .pager li.period {
  width: auto;
  padding: 1px 2px;
  border: 0;
}
</style>
<pre class="height_narrow">
.tab {
  margin: 10px 5px 0 0;
  padding: 5px 7px;
  float: left;
<span style="color:blue;">  height: 14px;</span>
  color: #383;
  border-style: solid;
  border-color: #383;
  border-width: 1px 1px 0 1px;
  -webkit-border-top-left-radius: 5px;
  -moz-border-radius-topleft: 5px;
  border-top-left-radius: 5px;
}
.selected {
<span style="color:blue;">  height: 16px;</span>
<span style="color:blue;">  margin-bottom: -2px;</span>
  background-color: #5a5;
  color: #fff;
  border-color: #373;
  border-bottom: 1px #5a5;
  -webkit-border-bottom-right-radius: 2px;
  -moz-border-radius-bottomright: 2px;
  border-bottom-right-radius: 2px;
  padding-right: 8px;
  -webkit-box-shadow: 1px 1px 0 #9c9 inset;
  -moz-box-shadow: 1px 1px 0 #9c9 inset;
  box-shadow: 1px 1px 0 #9c9 inset;
}
.toolbar {
  clear: both;
  height: 30px;
  background-color: #5a5;
  border: solid 1px #373;
  background: -webkit-linear-gradient(top, #5a5 1%, #383 100%);
  background: -moz-linear-gradient(top, #5a5 1%, #383 100%);
  background: linear-gradient(top, #5a5 1%,#383 100%);
  -webkit-box-shadow: 1px 1px 0 #9c9 inset;
  -moz-box-shadow: 1px 1px 0 #9c9 inset;
  box-shadow: 1px 1px 0 #9c9 inset;
}
.toolbar .pager {
  display: block;
  float: right;
  margin: 6px;
}
.toolbar .pager li {
  display: block;
  float: left;
  margin-left: 2px;
  color: #fff;
}
.toolbar .pager li.button {
  width: 20px;
  padding: 1px;
  border: solid 1px;
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  border-radius: 3px;
}
.toolbar .pager li.enable {
  border-color: rgba(255, 255, 255, 0.5);
}
.toolbar .pager li.current {
  background-color: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
}
.toolbar .pager li.period {
  width: auto;
  padding: 1px 2px;
  border: 0;
}
</pre>
<div class="step7">
<div class="tab selected">フォローしている</div>
<div class="tab">フォローされている</div>
<div class="toolbar">
<ul class="pager">
<li class="button enable">1</li>
<li class="button enable">2</li>
<li class="button current">3</li>
<li class="button enable">4</li>
<li class="button enable">5</li>
<li class="period">&#8230;</li>
<li class="button enable">≫</li>
</ul>
</div>
</div>
<h4>テキストの書式を調整する</h4>
<p>残りは微調整になりますが、テキストの書式を指定していきます。<br />
センタリングやフォントサイズの調整の他、選択中のタブやページを強調するためにテキストシャドウを指定しました。<br />
下に 1px の位置にぼかし無しのシャドウを付けています。あまり離したり、ぼかしすぎたりすると 90 年代テイストの野暮ったさになってしまうので気を付けたいところです。</p>
<p>ところでこのテキストシャドウ、本当は 1px 程度はぼかした方が見た目が柔らかくなっていいのですが、XP 上の Chrome 限定で、「本来アンチエイリアスがかかっていないフォントに、テキストシャドウをぼかして適用するとアンチエイリアスがかかる」という仕様 (バグ？) があって、隣のシャドウ無しのフォントと見た目が変わってしまうので、あえてぼかし無しにしています。<br />
自分が XP 上で Chrome を使っていて気になるというだけなので、気にせずぼかしを適用しても良いかも知れません。</p>
<style>
.step8 .tab {
  margin: 10px 5px 0 0;
  padding: 5px 7px;
  float: left;
  height: 14px;
  color: #383;
  border-style: solid;
  border-color: #383;
  border-width: 1px 1px 0 1px;
  -webkit-border-top-left-radius: 5px;
  -moz-border-radius-topleft: 5px;
  border-top-left-radius: 5px;
}
.step8 .selected {
  height: 16px;
  margin-bottom: -2px;
  background-color: #5a5;
  color: #fff;
  border-color: #373;
  border-bottom: 1px #5a5;
  padding-right: 8px;
  -webkit-box-shadow: 1px 1px 0 #9c9 inset;
  -moz-box-shadow: 1px 1px 0 #9c9 inset;
  box-shadow: 1px 1px 0 #9c9 inset;
  text-shadow: 0 1px 0 #333;
}
.step8 .toolbar {
  clear: both;
  height: 30px;
  background-color: #5a5;
  border: solid 1px #373;
  background: -webkit-linear-gradient(top, #5a5 1%, #383 100%);
  background: -moz-linear-gradient(top, #5a5 1%, #383 100%);
  background: linear-gradient(top, #5a5 1%,#383 100%);
  -webkit-box-shadow: 1px 1px 0 #9c9 inset;
  -moz-box-shadow: 1px 1px 0 #9c9 inset;
  box-shadow: 1px 1px 0 #9c9 inset;
}
.step8 .toolbar .pager {
  display: block;
  float: right;
  margin: 6px;
}
.step8 .toolbar .pager li {
  display: block;
  float: left;
  margin-left: 2px;
  color: #fff;
  text-align: center;
  font-size: 90%;
}
.step8 .toolbar .pager li.button {
  width: 20px;
  padding: 1px;
  border: solid 1px;
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  border-radius: 3px;
}
.step8 .toolbar .pager li.enable {
  border-color: rgba(255, 255, 255, 0.5);
}
.step8 .toolbar .pager li.current {
  background-color: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
  text-shadow: 0 1px 0 #333;
}
.step8 .toolbar .pager li.period {
  width: auto;
  padding: 1px 2px;
  border: 0;
}
</style>
<pre class="height_narrow">
.tab {
  margin: 10px 5px 0 0;
  padding: 5px 7px;
  float: left;
  height: 14px;
  color: #383;
  border-style: solid;
  border-color: #383;
  border-width: 1px 1px 0 1px;
  -webkit-border-top-left-radius: 5px;
  -moz-border-radius-topleft: 5px;
  border-top-left-radius: 5px;
}
.selected {
  height: 16px;
  margin-bottom: -2px;
  background-color: #5a5;
  color: #fff;
  border-color: #373;
  border-bottom: 1px #5a5;
  padding-right: 8px;
  -webkit-box-shadow: 1px 1px 0 #9c9 inset;
  -moz-box-shadow: 1px 1px 0 #9c9 inset;
  box-shadow: 1px 1px 0 #9c9 inset;
<span style="color:blue;">  text-shadow: 0 1px 0 #333;</span>
}
.toolbar {
  clear: both;
  height: 30px;
  background-color: #5a5;
  border: solid 1px #373;
  background: -webkit-linear-gradient(top, #5a5 1%, #383 100%);
  background: -moz-linear-gradient(top, #5a5 1%, #383 100%);
  background: linear-gradient(top, #5a5 1%,#383 100%);
  -webkit-box-shadow: 1px 1px 0 #9c9 inset;
  -moz-box-shadow: 1px 1px 0 #9c9 inset;
  box-shadow: 1px 1px 0 #9c9 inset;
}
.toolbar .pager {
  display: block;
  float: right;
  margin: 6px;
}
.toolbar .pager li {
  display: block;
  float: left;
  margin-left: 2px;
  color: #fff;
  text-align: center;
  font-size: 90%;
}
.toolbar .pager li.button {
  width: 20px;
  padding: 1px;
  border: solid 1px;
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  border-radius: 3px;
}
.toolbar .pager li.enable {
  border-color: rgba(255, 255, 255, 0.5);
}
.toolbar .pager li.current {
  background-color: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
<span style="color:blue;">  text-shadow: 0 1px 0 #333;</span>
}
.toolbar .pager li.period {
  width: auto;
  padding: 1px 2px;
  border: 0;
}
</pre>
<div class="step8">
<div class="tab selected">フォローしている</div>
<div class="tab">フォローされている</div>
<div class="toolbar">
<ul class="pager">
<li class="button enable">1</li>
<li class="button enable">2</li>
<li class="button current">3</li>
<li class="button enable">4</li>
<li class="button enable">5</li>
<li class="period">&#8230;</li>
<li class="button enable">≫</li>
</ul>
</div>
</div>
<h4>ユーザビリティを向上させる</h4>
<p>静的な見た目についてはすでに完成していますが、オンマウス時の挙動を指定する事でユーザビリティを向上させます。</p>
<p>まずクリック可能な要素に対して cursor を pointer にするのは基本中の基本です。a 要素を使えばデフォルトのスタイルがそうなるのですが、HTML の思想からしてページ遷移 (ページ内ジャンプを含む) 以外で a 要素を使うのは正しいとは言えません。<br />
余談ですが、a 要素の name 属性も HTML5 で廃止されました。要素に名前を付けるために a を使うなという事です。</p>
<p>なお、クリック時の動作自体は、JavaScript で動的に付与します。onclick 属性は Ajax で HTML を差し込む時に便利だったのですが、jQuery の live を使えば、後から追加される要素にも動的にイベントを付与出来るので、昔ながらの手法はそろそろ終わりにしましょう。</p>
<p>後は、hover 時のスタイルを追加します。タブが上に伸びたようになるのは、padding-top を増やした分、margin-top を減らす事で表現しています。<br />
この時 transition を使えばさらにアニメーションさせる事もできるかと思ったのですが、padding と margin を同時に変化させると、アニメーションがガタガタしてしまうことが分かったので適用していません。</p>
<pre class="height_narrow">
.tab {
  margin: 10px 5px 0 0;
  padding: 5px 7px;
  float: left;
  height: 14px;
  color: #383;
  border-style: solid;
  border-color: #383;
  border-width: 1px 1px 0 1px;
  -webkit-border-top-left-radius: 5px;
  -moz-border-radius-topleft: 5px;
  border-top-left-radius: 5px;
<span style="color:blue;">  cursor: pointer;</span>
}
.tab:hover {
<span style="color:blue;">  padding-top: 7px;</span>
<span style="color:blue;">  margin-top: 8px;</span>
}
.selected {
  height: 16px;
  margin-bottom: -2px;
  background-color: #5a5;
  color: #fff;
  border-color: #373;
  border-bottom: 1px #5a5;
  padding-right: 8px;
  -webkit-box-shadow: 1px 1px 0 #9c9 inset;
  -moz-box-shadow: 1px 1px 0 #9c9 inset;
  box-shadow: 1px 1px 0 #9c9 inset;
  text-shadow: 0 1px 0 #333;
}
.toolbar {
  clear: both;
  height: 30px;
  background-color: #5a5;
  border: solid 1px #373;
  background: -webkit-linear-gradient(top, #5a5 1%, #383 100%);
  background: -moz-linear-gradient(top, #5a5 1%, #383 100%);
  background: linear-gradient(top, #5a5 1%,#383 100%);
  -webkit-box-shadow: 1px 1px 0 #9c9 inset;
  -moz-box-shadow: 1px 1px 0 #9c9 inset;
  box-shadow: 1px 1px 0 #9c9 inset;
}
.toolbar .pager {
  display: block;
  float: right;
  margin: 6px;
}
.toolbar .pager li {
  display: block;
  float: left;
  margin-left: 2px;
  color: #fff;
  text-align: center;
  font-size: 90%;
}
.toolbar .pager li.button {
  width: 20px;
  padding: 1px;
  border: solid 1px;
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  border-radius: 3px;
}
.toolbar .pager li.enable {
  border-color: rgba(255, 255, 255, 0.5);
<span style="color:blue;">  cursor: pointer;</span>
}
.toolbar .pager li.enable:hover {
<span style="color:blue;">  background-color: rgba(255, 255, 255, 0.3);</span>
}
.toolbar .pager li.current {
  background-color: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
  text-shadow: 0 1px 0 #333;
}
.toolbar .pager li.period {
  width: auto;
  padding: 1px 2px;
  border: 0;
}
</pre>
<div class="finish">
<div class="tab selected">フォローしている</div>
<div class="tab">フォローされている</div>
<div class="toolbar">
<ul class="pager">
<li class="button enable">1</li>
<li class="button enable">2</li>
<li class="button current">3</li>
<li class="button enable">4</li>
<li class="button enable">5</li>
<li class="period">&#8230;</li>
<li class="button enable">≫</li>
</ul>
</div>
</div>
<h4>さいごに</h4>
<p>CSS3 を使う時は、ついつい派手に使いたくなるのですが、さりげなくワンポイントずつ使うと、比較的こなれた仕上がりになるようです。</p>
<p>また、例によって IE のようなレガシーブラウザでは、意図したとおりの見た目にはなりません。<br />
IE6 でのキャプチャは以下のようになります。</p>
<p><a href="http://www.otchy.net/wp-content/uploads/2011/09/ie6.png"><img src="http://www.otchy.net/wp-content/uploads/2011/09/ie6-300x41.png" alt="" title="IE6" width="300" height="41" class="aligncenter size-medium wp-image-1448" /></a></p>
<p>このままだと厳しそうですが、選択中のページの背景色を半透明以外にも指定しておけば、ぎりぎり意図は伝えられるレベルですね。<br />
プログレッシブエンハンスメント (長すぎ！略称募集) も意識したデザインをやっていければいいなと思います。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.otchy.net/20110906/css3-tab-toolbar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5＋CSS3 使ってみた感想</title>
		<link>http://www.otchy.net/20101020/html5-css3-impression/</link>
		<comments>http://www.otchy.net/20101020/html5-css3-impression/#comments</comments>
		<pubDate>Wed, 20 Oct 2010 04:08:38 +0000</pubDate>
		<dc:creator>Otchy</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>

		<guid isPermaLink="false">http://www.otchy.net/?p=1220</guid>
		<description><![CDATA[Cron Builder を作るにあたって、初めてちゃんと HTML5＋CSS3 を使ってみたので、その雑感などをメモ程度に書いてみます。
HTML5

header、footer、nav

  分かりやすくていいです。 [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.otchy.net/cronbuilder/" target="_blank">Cron Builder</a> を作るにあたって、初めてちゃんと HTML5＋CSS3 を使ってみたので、その雑感などをメモ程度に書いてみます。</p>
<h4>HTML5</h4>
<dl>
<dt>header、footer、nav</dt>
<dd>
  分かりやすくていいです。ソースが見やすくなります。<br />
  早くエディタ側の対応が進んで、見やすく色分けしてくれるようになると嬉しいですね。
</dd>
<dt>section</dt>
<dd>
  Cron Builder みたいなウェブアプリの場合、使いどころにちょっと悩みます。今回はタブの中身で使ってみました。article 要素に至っては、使いどころがないです。<br />
  ブログとかニュースサイトなら綺麗にハマるんだと思いますが、ウェブアプリの場合、新規追加の要素を無理して使う必要はないですよね。
</dd>
<dt>header とか section って、ブロック要素じゃないの？</dt>
<dd>
  header、footer、section を最初、名前が違うだけのdiv のつもりで使ってたら、Chrome は意図通り表示されたのに、Firefox はブロック要素として振る舞っていませんでした。(未確認ですが inline-block ぽい？)<br />
  display: block して事なきを得ましたが、この辺って正しくはどうあるべきなんでしょう？(Fx 3.6 が実は HTML5 に対応していないだけ？？)
</dd>
<dt>div</dt>
<dd>
  せっかくだから、div 要素を使わずにやってみようと思って始めましたが、結局挫折。少し凝ったことをやろうとすると、やっぱり「論理的な意味を持たない枠」が必要になるので、そこは結局 div にしました。<br />
  まあ、無しにするのは難しいですが、div は確実に減らせます。div が減ると class とか id の指定も減らせて、CSS のセレクタが綺麗になるのが嬉しいところです。
</dd>
<dt>その他 canvas、video、audio など</dt>
<dd>
  派手派手しい要素は全然使ってません。
</dd>
</dl>
<h4>CSS3</h4>
<dl>
<dt>:hover</dt>
<dd>
  CSS3 じゃないけど、IE が a 要素にしか対応してなかったので、気分としては CSS3。a 要素以外にも色々使うと、スマートに書けます。<br />
  よく li の中に a を入れて…ってやってましたが、今回、タブを表す li 要素に直接 :hover したら HTML がスッキリしました。気持ちいい。<br />
  onclick イベントも jQuery の後乗せで li に直接付与して実現してて、a 要素の使用は本当の意味でページ遷移する時だけです。意味的にも綺麗で精神的によろしい。
</dd>
<dt>border-radius</dt>
<dd>
  言わずと知れた角丸。もはや定番という意識です。<br />
  Fx 3.6 はまだベンダープレフィックスが必要なのがちょっと意外でした。Fx 4.0 では要らなくなるのかな？
</dd>
<dt>text-shadow</dt>
<dd>
  実装されたのが昔だけあって、抜群の安定感。Cron Builder ではロゴにあたる部分で使用してます。<br />
  最近、本文に微妙にずらした text-shadow をかける例を見かけますが、やりすぎると見にくくなるので気を付けたいところですね。<br />
  調子に乗って、5px 5px 5px とか離しすぎでぼかしすぎの影を付けると、雰囲気が一気に 90 年代テイストになりますｗ
</dd>
<dt>box-shadow</dt>
<dd>
  影繋がりで次は box-shadow。こっちは最近の実装なので、Chrome も Firefox もベンダープレフィックスが必要です。でも、ルール自体はシンプルなので使い勝手はブラウザに寄らず同じでした。<br />
  inset (内側の影) を指定すると窪んだ感じを表現できます。<br />
  Cron Buider では、border-radius と box-shadow: inset を組み合わせて使っていて、同じ事を CSS3 無しでやろうと思ったら、画像はいくつも必要だし、マークアップも汚くなってしまいます。今回、一番 CSS3 の恩恵を感じた部分はここでした。
</dd>
<dt>グラデーション</dt>
<dd>
  最後はこれです。仕様未決定でしたっけ？ベンダープレフィックスどころか、実装によってそもそも書式が全然違うし、それらも複雑です。<br />
  オンライン上に色々とグラデーション CSS のジェネレータがありますが、グラデーションの指定はジェネレータが無いと書けないと思います。
</dd>
<dt>その他</dt>
<dd>
  アニメーションとか回転とかは使ってません。CSS3 を考えた人達が「CSS3 すげーんだぜ！」って言いたい気持ちは分かるんですが、やりすぎじゃないかなぁと思ってます。昔懐かしい blink とか marquee の匂いを感じるんですがどうなんでしょう？
</dd>
</dl>
<p>ざっとこんなところです。<br />
全般的にみて、マークアップが綺麗になるケースが多く、それに伴い CSS のセレクタも分かりやすくなるケースが多かったので、将来的には主流になっていくと思いました。<br />
jQuery 使ってると、CSS セレクタが分かりやすい＝jQuery が分かりやすいっていう事なので、特に助かりますね。</p>
<p>スタンダードな使い方をしている限り、ブラウザ間の挙動の違いもほとんど無いので楽に作れます。<br />
え？IE？もちろん、全力で無視してます。<br />
body 直下に以下の条件付きコメントを入れているのが、せめてもの良心でしょうか。</p>
<pre>
&lt;!--[if IE]&gt;
&lt;div style="padding: 5px; border: 3px solid #f00; background: #fee; color: #f00; font-size: 10pt;"&gt;
IE では一切動作確認していません。恐らく動作しません。
&lt;/div&gt;
&lt;![endif]--&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.otchy.net/20101020/html5-css3-impression/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>テーブルのヘッダを固定してスクロールする jQuery プラグイン</title>
		<link>http://www.otchy.net/20100308/jquery-tablefix-js-had-released/</link>
		<comments>http://www.otchy.net/20100308/jquery-tablefix-js-had-released/#comments</comments>
		<pubDate>Sun, 07 Mar 2010 21:44:47 +0000</pubDate>
		<dc:creator>Otchy</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.otchy.net/?p=1004</guid>
		<description><![CDATA[Excel のウィンドウ枠の固定のように、テーブルのヘッダや左側を固定して、残りの部分をスクロールさせるための jQuery プラグインを書きました。
マークアップはシンプルで、普通にテーブルを書いたら、jQuery の [...]]]></description>
			<content:encoded><![CDATA[<p>Excel のウィンドウ枠の固定のように、テーブルのヘッダや左側を固定して、残りの部分をスクロールさせるための jQuery プラグインを書きました。<br />
マークアップはシンプルで、普通にテーブルを書いたら、jQuery の作法でプラグインを呼び出すだけです。</p>
<p>jQuery のおれおれプラグインはいくつか書いた事がありましたが、こうやって公開するのは初めてです。ごてごての機能が欲しいんじゃなくて、単に既存のテーブルを固定スクロール化したいだけの時に、いいのが見つからなくて書いたので、けっこうニーズがあるんじゃないかと思ってます。</p>
<p>下記は簡単なサンプルです。詳細は<a href="/javascript/tablefix/">専用ページ</a>を見てみて下さい。</p>
<p>HTML</p>
<pre class="height_middle">
&lt;table id=&quot;tablefix&quot;&gt;
    &lt;thead&gt;
    &lt;tr&gt;
        &lt;th rowspan=&quot;2&quot;&gt;ヘッダA&lt;/th&gt;
        &lt;th rowspan=&quot;2&quot;&gt;ヘッダB&lt;/th&gt;
        &lt;th colspan=&quot;2&quot;&gt;ヘッダC&lt;/th&gt;
        &lt;th rowspan=&quot;2&quot;&gt;ヘッダD&lt;/th&gt;
        &lt;th rowspan=&quot;2&quot;&gt;ヘッダE&lt;/th&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;th&gt;ヘッダ C-1&lt;/th&gt;
        &lt;th&gt;ヘッダ C-2&lt;/th&gt;
    &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
    &lt;tr&gt;
        &lt;td&gt;データ&lt;/td&gt;
        &lt;td&gt;データ&lt;/td&gt;
        &lt;td&gt;データデータデータデータデータデータデータデータデータデータデータデータ&lt;/td&gt;
        &lt;td&gt;データデータデータデータデータデータデータデータデータデータデータデータ&lt;/td&gt;
        &lt;td&gt;データデータデータデータデータデータデータデータデータデータデータデータ&lt;/td&gt;
        &lt;td&gt;データデータデータデータデータデータデータデータデータデータデータデータ&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;データ&lt;/td&gt;
        &lt;td&gt;データ&lt;/td&gt;
        &lt;td&gt;データデータデータデータデータデータデータデータデータデータデータデータ&lt;/td&gt;
        &lt;td&gt;データデータデータデータデータデータデータデータデータデータデータデータ&lt;/td&gt;
        &lt;td&gt;データデータデータデータデータデータデータデータデータデータデータデータ&lt;/td&gt;
        &lt;td&gt;データデータデータデータデータデータデータデータデータデータデータデータ&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;データ&lt;/td&gt;
        &lt;td&gt;データ&lt;/td&gt;
        &lt;td&gt;データデータデータデータデータデータデータデータデータデータデータデータ&lt;/td&gt;
        &lt;td&gt;データデータデータデータデータデータデータデータデータデータデータデータ&lt;/td&gt;
        &lt;td&gt;データデータデータデータデータデータデータデータデータデータデータデータ&lt;/td&gt;
        &lt;td&gt;データデータデータデータデータデータデータデータデータデータデータデータ&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;データ&lt;/td&gt;
        &lt;td&gt;データ&lt;/td&gt;
        &lt;td&gt;データデータデータデータデータデータデータデータデータデータデータデータ&lt;/td&gt;
        &lt;td&gt;データデータデータデータデータデータデータデータデータデータデータデータ&lt;/td&gt;
        &lt;td&gt;データデータデータデータデータデータデータデータデータデータデータデータ&lt;/td&gt;
        &lt;td&gt;データデータデータデータデータデータデータデータデータデータデータデータ&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;データ&lt;/td&gt;
        &lt;td&gt;データ&lt;/td&gt;
        &lt;td&gt;データデータデータデータデータデータデータデータデータデータデータデータ&lt;/td&gt;
        &lt;td&gt;データデータデータデータデータデータデータデータデータデータデータデータ&lt;/td&gt;
        &lt;td&gt;データデータデータデータデータデータデータデータデータデータデータデータ&lt;/td&gt;
        &lt;td&gt;データデータデータデータデータデータデータデータデータデータデータデータ&lt;/td&gt;
    &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;
</pre>
<p>JavaScript</p>
<pre>
$(function() {
    $('#tablefix').tablefix({width: 500, height: 200, fixRows: 2, fixCols: 2});
});
</pre>
<p>実行結果</p>
<style>
#tablefix {
    width: 800px;
    border-collapse: collapse;
    border-spacing: 0;
}
#tablefix thead th {
    background-color: #333;
    color: #fff;
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
}
</style>
<table id="tablefix">
<thead>
<tr>
<th rowspan="2">ヘッダA</th>
<th rowspan="2">ヘッダB</th>
<th colspan="2">ヘッダC</th>
<th rowspan="2">ヘッダD</th>
<th rowspan="2">ヘッダE</th>
</tr>
<tr>
<th>ヘッダ C-1</th>
<th>ヘッダ C-2</th>
</tr>
</thead>
<tbody>
<tr>
<td>データ</td>
<td>データ</td>
<td>データデータデータデータデータデータデータデータデータデータデータデータ</td>
<td>データデータデータデータデータデータデータデータデータデータデータデータ</td>
<td>データデータデータデータデータデータデータデータデータデータデータデータ</td>
<td>データデータデータデータデータデータデータデータデータデータデータデータ</td>
</tr>
<tr>
<td>データ</td>
<td>データ</td>
<td>データデータデータデータデータデータデータデータデータデータデータデータ</td>
<td>データデータデータデータデータデータデータデータデータデータデータデータ</td>
<td>データデータデータデータデータデータデータデータデータデータデータデータ</td>
<td>データデータデータデータデータデータデータデータデータデータデータデータ</td>
</tr>
<tr>
<td>データ</td>
<td>データ</td>
<td>データデータデータデータデータデータデータデータデータデータデータデータ</td>
<td>データデータデータデータデータデータデータデータデータデータデータデータ</td>
<td>データデータデータデータデータデータデータデータデータデータデータデータ</td>
<td>データデータデータデータデータデータデータデータデータデータデータデータ</td>
</tr>
<tr>
<td>データ</td>
<td>データ</td>
<td>データデータデータデータデータデータデータデータデータデータデータデータ</td>
<td>データデータデータデータデータデータデータデータデータデータデータデータ</td>
<td>データデータデータデータデータデータデータデータデータデータデータデータ</td>
<td>データデータデータデータデータデータデータデータデータデータデータデータ</td>
</tr>
<tr>
<td>データ</td>
<td>データ</td>
<td>データデータデータデータデータデータデータデータデータデータデータデータ</td>
<td>データデータデータデータデータデータデータデータデータデータデータデータ</td>
<td>データデータデータデータデータデータデータデータデータデータデータデータ</td>
<td>データデータデータデータデータデータデータデータデータデータデータデータ</td>
</tr>
</tbody>
</table>
<p><script src="/js/jquery.tablefix.js"></script><br />
<script>
$(function() {
    $('#tablefix').tablefix({width: 500, height: 200, fixRows: 2, fixCols: 2});
});
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.otchy.net/20100308/jquery-tablefix-js-had-released/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>css による疑似フレーム IE6 標準準拠モード完全対応版 (CSS ハック / JavaScript未使用)</title>
		<link>http://www.otchy.net/20090519/frame-like-css-layout-for-ie6/</link>
		<comments>http://www.otchy.net/20090519/frame-like-css-layout-for-ie6/#comments</comments>
		<pubDate>Tue, 19 May 2009 13:25:54 +0000</pubDate>
		<dc:creator>Otchy</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[ie6]]></category>

		<guid isPermaLink="false">http://www.otchy.net/?p=642</guid>
		<description><![CDATA[css のみを使って、ヘッダ / メニュー / フッタをスクロールしないように固定して疑似フレームを表現する手法は position: fixed による方法が広く知られています。
この方法は、手軽に疑似フレームを表現で [...]]]></description>
			<content:encoded><![CDATA[<p>css のみを使って、ヘッダ / メニュー / フッタをスクロールしないように固定して疑似フレームを表現する手法は position: fixed による方法が広く知られています。<br />
この方法は、手軽に疑似フレームを表現できる一方で、IE6 が対応していないという非常に残念な現実があり、対象ブラウザから IE6 を完全に外してしまえるような状況ならともかく、(特に仕事の上などでは) IE6 を対象から外せない事も多いので頭痛の種でした。</p>
<p>IE 独自拡張の expression を使って、fixed に近い状況を作り出す技が色々と開発されているのですが、どうも自分にしっくり来るものがありませんでした。<br />
そこで、下記の条件を満たすやり方を開発したので公開します。</p>
<ul>
<li>IE6 標準準拠モードで動作させる<br />
IE 7 に関して、fixed を正しく動作させるために標準準拠に関しては重要な要件</li>
<li>css ハックは使わない<br />
将来のブラウザのバージョンで異変が起きる可能性を排除</li>
<li>メニューもフッタも固定する<br />
ヘッダだけの固定であればシンプルな実装が他にもある</li>
<li>無駄な HTML マークアップを追加しない<br />
HTML 自体は fixed 対応ブラウザのみの場合と同様</li>
<li>極力シンプルに記述できる<br />
冗長なコードを書いて無理矢理つじつまを合わせるような事はしない</li>
<li>スクロール時に画面がちらつかない<br />
expression の使い方によってはダサイ見た目になってしまうのでそれを回避</li>
<li>IE6 以外のブラウザに影響を与えない<br />
当然</li>
</ul>
<p>論より証拠。まずは<a href="http://www.otchy.net/sample/ie6fixed.html" target="_blank">サンプル</a>を見て下さい。<br />
このページでは、ヘッダ / メニュー / フッタの 3 つがスクロールに対して固定されています。<br />
fixed 対応ブラウザでは fixed で実現され、IE6 に関しては expression をちょっとだけ使っています。</p>
<p>まず、一般的な fixed 部分について簡単に解説します。</p>
<pre>&lt;div id="header"&gt;ヘッダ&lt;/div&gt;
&lt;div id="menu"&gt;メニュー&lt;/div&gt;
&lt;div id="contents"&gt;
START&lt;br /&gt;
コンテンツ...&lt;br /&gt;
END&lt;br /&gt;
&lt;/div&gt;
&lt;div id="footer"&gt;フッタ&lt;/div&gt;</pre>
<p>HTML については、非常にシンプルです。<br />
各部位ごとに異なる id を指定した div があるだけです。</p>
<p>css のうち装飾に関わる部分を除くとこんな感じです。</p>
<pre>* {
	margin: 0;
	padding: 0;
}
#header {
	position: fixed;
	left: 0;
	top: 0;
	width: 100%;
	height: 24px;
	z-index: 3;
}
#menu {
	position: fixed;
	left: 0;
	top: 0;
	width: 150px;
	height: 100%;
	padding-top: 24px;
	z-index: 2;
}
#contents {
	padding: 24px 0 24px 150px;
	z-index: 1;
}
#footer {
	position: fixed;
	left: 0;
	bottom: 0;
	width: 100%;
	height: 24px;
	z-index: 3;
}</pre>
<p>#header / #menu / #footer については、fixed で固定されています。<br />
#menu / #contents では padding を指定する事で、重なってしまう部分が隠れないようにしてあります。<br />
fixed 対応ブラウザであれば、これだけで疑似フレームの完成です。標準準拠モードになるよう、DOCTYPE を指定しているので、IE7 であっても同様に動作します。</p>
<p>続いて、IE6 向けの設定です。</p>
<pre>&lt;!--[if lt IE 7]&gt;
&lt;style&gt;
#header, #footer, #menu {
	position: absolute;
}
#contents {
	overflow: auto;
	height: expression((document.documentElement.clientHeight - 48) + 'px');
}
#menu {
	height: expression((document.documentElement.clientHeight - 48) + 'px');
}
&lt;/style&gt;
&lt;![endif]--&gt;</pre>
<p>意外なほどシンプルではないでしょうか？これだけです。</p>
<p>&lt;!&#8211;[if lt IE 7]&gt; から始まる記述は IE 独自拡張の条件付きコメントで、IE 以外のブラウザでは完全に無視されます。<br />
ここでは、IE 7 未満の IE を指定して専用の記述を読み込ませています。<br />
どうせ IE に対してのみ動作を変えるのであれば、変に CSS ハックを使うよりよほどリスクが少なく確実な方法だと思います。</p>
<p>position: absolute; は、fixed に対応していない IE6 のために、設定を上書きしています。<br />
css の設定は後勝ちなので、IE6 向けの設定は fixed 向けよりも後に書く必要があります。</p>
<p>#contens / #menu にある、expression がポイントです。<br />
expression は、filter 関数などと同様の IE 独自拡張で、任意の JavaScript コードを使用して動的に css の値を指定する事が出来きるものです。</p>
<p>ここでは、#contents / #menu の高さを、ウィンドウ内部の高さからヘッダとフッタの分を引いた値に指定しています。<br />
これにより「メニューとコンテンツ部分がウィンドウからはみ出ない」という状況が生まれ、実質的な疑似フレームになります。<br />
また、expression 関数は、ウィンドウサイズが変更された際などにも自動的に再計算されます。</p>
<p>ヘッダとフッタの top や left を expression 関数で設定する手法も見かけたのですが、これだとスクロール時にちらつきが出るのでイマイチです。<br />
この手法は、ウィンドウ自体がスクロールしないよう抑制し、コンテンツ部分のみを overflow: auto; でスクロールさせるという逆転の発想で実装されています。</p>
<p>ソースの全容は<a href="http://www.otchy.net/sample/ie6fixed.html" target="_blank">サンプル</a>をダウンロードして確認して下さい。<br />
また、実際に使用する時はもちろん、css を直接 HTML に書かず、外部ファイルに切り出した方がよいです。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.otchy.net/20090519/frame-like-css-layout-for-ie6/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>サーバサイド高機能エディタ ecoder インストール方法</title>
		<link>http://www.otchy.net/20090330/server-side-editor-ecoder-installation/</link>
		<comments>http://www.otchy.net/20090330/server-side-editor-ecoder-installation/#comments</comments>
		<pubDate>Mon, 30 Mar 2009 05:20:38 +0000</pubDate>
		<dc:creator>Otchy</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[ecoder]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.otchy.net/?p=441</guid>
		<description><![CDATA[ecoder って何？
ブラウザ上でソースコード編集が可能な開発環境を提供「ecoder」:phpspot開発日誌 で紹介されている、激しく便利そうなエディタです。
ブラウザ上から、こんな感じでサーバ上のファイルを直接編 [...]]]></description>
			<content:encoded><![CDATA[<h4>ecoder って何？</h4>
<p><a href="http://phpspot.org/blog/archives/2009/03/ecoder.html" target="_blank">ブラウザ上でソースコード編集が可能な開発環境を提供「ecoder」:phpspot開発日誌</a> で紹介されている、激しく便利そうなエディタです。<br />
ブラウザ上から、こんな感じでサーバ上のファイルを直接編集することができます。</p>
<p><a href="http://www.otchy.net/wp-content/uploads/2009/03/edit_html.gif"><img src="http://www.otchy.net/wp-content/uploads/2009/03/edit_html-150x150.gif" alt="HTML の編集" title="HTML の編集" width="150" height="150" class="alignnone size-thumbnail wp-image-443" /></a><a href="http://www.otchy.net/wp-content/uploads/2009/03/edit_css.gif"><img src="http://www.otchy.net/wp-content/uploads/2009/03/edit_css-150x150.gif" alt="CSS の編集" title="CSS の編集" width="150" height="150" class="alignnone size-thumbnail wp-image-444" /></a><a href="http://www.otchy.net/wp-content/uploads/2009/03/edit_js.gif"><img src="http://www.otchy.net/wp-content/uploads/2009/03/edit_js-150x150.gif" alt="JavaScript の編集" title="JavaScript の編集" width="150" height="150" class="alignnone size-thumbnail wp-image-445" /></a><a href="http://www.otchy.net/wp-content/uploads/2009/03/edit_php.gif"><img src="http://www.otchy.net/wp-content/uploads/2009/03/edit_php-150x150.gif" alt="PHP の編集" title="PHP の編集" width="150" height="150" class="alignnone size-thumbnail wp-image-446" /></a></p>
<p>順に、HTML / CSS / JavaScript / PHP を編集している様子です。これらのファイルが、色分けされた状態でブラウザで編集できるなんて、よだれが止まりません。</p>
<p>そこで早速インストールしてみようとしたところ、まだベータ版ゆえか、公式ではいっさいドキュメントが用意されていなかったので、ソースを読みながらインストールした記録を公開することにしました。</p>
<h4>対象者</h4>
<ul>
<li>PHP の動作するサーバを使用できる</li>
<li>Linux 設定について基本的な事を理解している or 自分で調べられる</li>
<li>Apache の設定について基本的な事を理解している or 自分で調べられる</li>
</ul>
<h4>ファイルのダウンロードと展開</h4>
<p><a href="http://ecoder.gmeditor.com/">ecoder のウェブサイト</a>から、tar.gz ファイルをダウンロードして、ecoder を配置したい場所に展開します。<br />
現在の最新版 (ver 0.3.2) の直 DL は http://downloads.sourceforge.net/ecoder/ecoder_0.3.2.tar.gz?use_mirror=jaist&amp;filesize=406946 ですが、まだベータ版の状態なので、インストール時点での最新版を調べて DL した方が良いです。</p>
<p>Windows で作業をする場合は、ブラウザから DL して展開したファイルに対して、後述の設定変更を行った後に、FTP なりでアップすると良いでしょう。<br />
ここでは、Linux 上で作業を完結させるためのコマンドを掲載しておきます。<br />
DL するパスとか展開するパスは、それぞれの環境に合わせて読み替えてください。</p>
<pre>$ su -
# cd /usr/local/src/
# mkdir ecoder_0.3.2
# cd ecoder_0.3.2
# wget http://downloads.sourceforge.net/ecoder/ecoder_0.3.2.tar.gz?use_mirror=jaist&amp;filesize=406946
# tar xfvz ecoder_0.3.2.tar.gz
# mv ecoder_0.3.2.tar.gz ../
# cd ../
# cp -a ecoder_0.3.2/ /var/www/www.otchy.net/himitsu
# cd /var/www/www.otchy.net/
# chown -R apache:apache himitsu/
# cd himitsu/
# find -type d -exec chmod 755 {} \;
# find -type f -exec chmod 644 {} \;</pre>
<p>※最後の権限変更は、デフォルトの設定がいろいろと気持ち悪かったのでなおしました</p>
<h4>設定ファイルの編集</h4>
<p>ルートディレクトリ直下にある code.php というファイルに、正しい設定を書かないと ecoder は動作しません。といっても、必要な設定はすべてここにまとめられているので、さほど難しくはないかと思います。<br />
以下では、修正が必要な項目について、本サイトの設定を例に順番に説明します。<br />
まずは、大抵の場合で修正が必要な項目です。</p>
<p>動作させるサイトのドメイン。</p>
<pre>$code['domain'] = "http://www.otchy.net/";</pre>
<p>クッキーを適用するドメイン。</p>
<pre>$code['domain_cookie'] = "www.otchy.net";</pre>
<p>編集するファイルのルート。スラッシュから始まるフルパスで記述する。</p>
<pre>$code['root'] = '/var/www/www.otchy.net/';</pre>
<p>エラーログの出力先。後述の .htaccess の設定と同じパスにする。<br />
事前に Apache ユーザに対して書き込み許可を与えておく必要がある。</p>
<pre>$dbug['error_path'] = '/var/log/ecoder/error.log';</pre>
<p>続いて、必要に応じて修正するといいかも知れない項目です。</p>
<p>自動セーブ機能をデフォルトで ON にするかどうか。保存即公開の場合は、OFF 推奨。<br />
デフォルト OFF になっていても、画面上から切り替えることが可能。</p>
<pre>$code['autosave'] = 0;</pre>
<p>自動セーブ機能を ON にした場合のセーブ間隔 (秒)</p>
<pre>$code['autosave_time'] = 10;</pre>
<p>編集時に裏でバックアップをするかどうか。</p>
<pre>$code['backup'] = 1;</pre>
<p>ツリービューに表示させるファイルの拡張子。</p>
<pre>$_SESSION['tree_file_types'] = array( "php", "js", "html", "css", "txt", "htaccess", "ini" );</pre>
<p>アップロードできないようにするファイルの拡張子。</p>
<pre>$_SESSION['upload_banned'] = array( "exe" );</pre>
<p>ツリービューの中で無視するファイル名。</p>
<pre>$_SESSION['tree_file_ignore'] = array ( ".ftpquota" )</pre>
<p>ツリービューの中で無視するディレクトリ名。</p>
<pre>$_SESSION['tree_dir_ignore'] = array( ".", "..", ".files", ".snap", "logic", "cpanel", "ftp", "00", "01" );</pre>
<h4>セキュリティと .htaccess 設定</h4>
<p>上記の設定を施しただけでも、とりあえず ecoder は動作し、ファイルの編集、保存を行うことができます。<br />
ただ、セキュリティは全く考慮されておらず、URL さえ知っていれば、誰でも編集可能な状態になってしまいます。</p>
<p>実は、ecooder 自体でもセキュリティの仕組みを持っていて、code.php において、$code['secure'] = 1; と設定すれば、認証機能を有効にすることができます。<br />
ただ、この認証は、別プログラムでアカウントを認証し、設定したキー名で PHP のセッションを発行する事により機能するようです。(推測)<br />
既存のシステムにシングルサインオンで組み込むには非常に適した仕組みですが、認証プログラム自体は同梱されておらず、別途作り込む必要があります。</p>
<p>そんな面倒くさい作り込みはしたくないので却下して、ここでは簡単に BASIC 認証を設定しておくことにします。<br />
平文でパスワードが流れるのが嫌な方は、SSL を同時に適用することをお勧めします。<br />
自分専用の編集サイトであれば、おれおれ証明書でも十分ですし。<br />
(その辺の設定については本記事の範疇外ですので別サイトなど参照してください。)</p>
<p>以上を踏まえた、.htaccess の編集箇所は以下の通りです。</p>
<p>ログファイルの出力先の権限を設定</p>
<pre>&lt;Files /var/log/ecoder/error.log&gt;
  Order allow,deny
  Deny from all
  Satisfy All
&lt;/Files&gt;</pre>
<p>ログファイルの出力先を設定</p>
<pre>php_value error_log /var/log/ecoder/error.log</pre>
<p>BASIC 認証を追加</p>
<pre>AuthUserFile /var/www/www.otchy.net/himitsu/.htpasswd
AuthGroupFile /dev/null
AuthName "ecoder login"
AuthType Basic
require valid-user

&lt;Files .htpasswd&gt;
  order allow,deny
  deny from all
&lt;/Files&gt;</pre>
<p>さらに、.htpasswd ファイルを作成する必要がありますが、ここでは詳しく説明しません。<br />
Apache 同梱の htpasswd コマンドを使うのが一番楽かと思います。</p>
<pre>$ htpasswd -c .htpasswd username</pre>
<p>以上で、設定は完了です。<br />
ファイル一式を配置したフォルダをブラウザから開けば、高機能なエディタが利用できます。<br />
もし何らかの設定が間違っている場合、ecoder 側で結構丁寧なエラーメッセージを表示してくれるので、それを元に修正していけば大丈夫です。</p>
<p>この ecoder と <a href="http://www.ajaxplorer.info/" target="_blank">AjaXplorer</a> を組み合わせて使えば、簡単な開発はもう Web 上で完結できるんじゃないかという気がしてきますね。<br />
すばらしい時代になったものです。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.otchy.net/20090330/server-side-editor-ecoder-installation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML のみで携帯から Twitter する</title>
		<link>http://www.otchy.net/20090224/mobile-twitter-with-only-html/</link>
		<comments>http://www.otchy.net/20090224/mobile-twitter-with-only-html/#comments</comments>
		<pubDate>Tue, 24 Feb 2009 03:38:02 +0000</pubDate>
		<dc:creator>Otchy</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.otchy.net/?p=323</guid>
		<description><![CDATA[ちょっと携帯から Twitter に投稿してみたいと思って、色々と方法を調べてみました。
携帯用の Web インターフェースや、メールから投稿できるもの、専用アプリなどいろいろあったのですが、どれもいまいち自分のニーズに [...]]]></description>
			<content:encoded><![CDATA[<p>ちょっと携帯から Twitter に投稿してみたいと思って、色々と方法を調べてみました。<br />
携帯用の Web インターフェースや、メールから投稿できるもの、専用アプリなどいろいろあったのですが、どれもいまいち自分のニーズにしっくりきません。</p>
<ul>
<li>よく分からんサービスに ID とかパスワードを預けたり送ったりするのは不安だ</li>
<li>単につぶやきたいだけだから、多機能である必要はない</li>
<li>そもそもパケホじゃないので、なるべく無駄なパケットは使いたくない</li>
</ul>
<p>なので、自分のニーズにしっくりくるものを自作することにしました。<br />
もちろん、PHP やら Perl やらを使ってごりごりやることも出来るんですが、簡単に (x)HTML だけで事が済みそうだったので、HTML だけで作成することに決定。</p>
<h4>HTMLソース</h4>
<p>下記の xhtml ソースを任意の名前で文字コードを UTF-8 として保存し、任意のサーバにアップします。<br />
携帯からアクセスして、「投稿」ボタンを押すと、最初は BASIC 認証が聞かれるので、Twitter で使用している ID とパスワードを入力します。<br />
以上で Twitter への投稿は完了です。</p>
<p>ひたすら軽く軽くシンプルにをモットーとして作られているので、投稿結果の処理が入っていません。(というか、HTML だけでそこまで出来ません。)<br />
投稿後は端末上で「未対応のフォーマット」的なエラーになるかと思います。<br />
アップしたページを画面メモなりお気に入りなりで携帯に保存しておけば、必要最小限のパケットで、Twitter に投稿することが可能です。</p>
<pre>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja"&gt;
&lt;head&gt;
    &lt;meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" /&gt;
    &lt;title&gt;モバT&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div&gt;モバT&lt;/div&gt;
&lt;form action="http://twitter.com/statuses/update.xml" method="POST"&gt;
&lt;input type="text" name="status" /&gt;&lt;input type="submit" value="投稿" /&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h4>制限事項</h4>
<p>UTF-8 ＋xhtml が読めない端末だと使用できません。最近の 3G 携帯なら特に問題ないでしょう。<br />
BASIC 認証に対応していない端末では使用できません。これも最近のものなら特に問題ないようです。<br />
au では使用できません。ページのエンコードが UTF-8 であっても、フォームの送信は Shift_JIS で行うという謎仕様のせいです。</p>
<h4>参考ページ</h4>
<ul>
<li><a href="http://watcher.moe-nifty.com/memo/2007/04/twitter_api.html" target="_blank">Twitter API 仕様書 (勝手に日本語訳シリーズ)</a></li>
<li><a href="http://www.marguerite.jp/Nihongo/WWW/Mobile/BasicAuthentication.html" target="_blank">携帯電話でのベーシック認証</a></li>
<li><a href="http://muneto.murakami.biz/mobile/xhtml-css-5.php" target="_blank">【携帯サイト制作】第五回 auでutf-8のページからformで日本語を渡すと文字化けorz</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.otchy.net/20090224/mobile-twitter-with-only-html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>右下または左下においた画像に文字列を回り込ませるHTML/CSS</title>
		<link>http://www.otchy.net/20090219/bottom-image-floating/</link>
		<comments>http://www.otchy.net/20090219/bottom-image-floating/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 12:13:45 +0000</pubDate>
		<dc:creator>Otchy</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[float]]></category>
		<category><![CDATA[html]]></category>

		<guid isPermaLink="false">http://www.otchy.net/?p=298</guid>
		<description><![CDATA[
普通、HTML で画像の回り込みというと、右上か左上に画像があって、そこに文字列が回り込むという感じです。これは簡単です。画像に対して float: left; すれば OK です。
しかし、右下か左下に画像を固定して [...]]]></description>
			<content:encoded><![CDATA[<p>
普通、HTML で画像の回り込みというと、右上か左上に画像があって、そこに文字列が回り込むという感じです。これは簡単です。画像に対して float: left; すれば OK です。<br />
しかし、右下か左下に画像を固定して、文字列がそこにたどり着いたら回り込むという動作は一筋縄ではいきません。<br />
<a href="http://h2ham.seesaa.net/article/102886385.html" target="_blank">画像をブロックの左下に配置してテキストを回り込ませる方法を考える</a> というページで色々と考察されていて、ふむふむと思ったのですが、この方法では、テキストの量が変わるたびに調整が必要になってしまうので、テキストの量が動的に変わる場合には対応しにくいです。<br />
何より、文章をぶった切って画像を入れるというのはどうもスマートではありません。
</p>
<p>色々と試行錯誤してみたところ、以下の方法で実現できそうだったので、公開してみます。</p>
<pre class="height_narrow">&lt;html&gt;
&lt;head&gt;
&lt;style&gt;
#block {
    width: 200px;
    height: 200px;
    overflow: hidden;
    font-size: 10pt;
    border: solid 1px #666;
    padding: 0.5em;
}
#bar {
    float: right;
    width: 1px;
    height: 100px;
    background-color: red;
}
#img {
    float: right;
    clear: both;
    width: 100px;
    height: 100px;
    background-color: blue;
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id="block"&gt;
&lt;div id="bar"&gt;&lt;/div&gt;
&lt;div id="img"&gt;&lt;/div&gt;
ああああああああああああああああああああああああああああ
ああああああああああああああああああああああああああああ
ああああああああああああああああああああああああああああ
ああああああああああああああああああああああああああああ
ああああああああああああああああああああああああああああ
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>
このソースを保存して開くと、以下のような見た目になります。<br />
わかりやすいように色分けした div で表現していますが、赤線は実際には透明、青い四角は実際には画像だと思って下さい。
</p>
<style>
#block {
    width: 200px;
    height: 200px;
    overflow: hidden;
    font-size: 10pt;
    border: solid 1px #666;
    padding: 0.5em;
}
#bar {
    float: right;
    width: 1px;
    height: 100px;
    background-color: red;
}
#img {
    float: right;
    clear: both;
    width: 100px;
    height: 100px;
    background-color: blue;
}
</style>
<div id="block">
<div id="bar"></div>
<div id="img"></div>
<p>ああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああ
</p></div>
<p>
#bar の部分とか美しいマークアップとは言えないですし、画像に文字が被ったりとかしてますが、微調整してやれば十分使い物になるかと思います。<br />
最初は絶対実現できないんじゃないかと思ったので、出来た時は嬉しかったですね～。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.otchy.net/20090219/bottom-image-floating/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

