スマートフォンとposition:fixedのバグ iPhoneではiOS5からAndroidでは2.2からposition:fixedに対応されてスマートフォンでも固定配置が利用できつつあります。と思いきや色々と落とし穴が多いのでまとめておきます。 Androidではuser-scalable=noが必須 <meta name="viewport" content="user-scalable=no" /> Androidではviewportにuser-scalable=noの指定がないとposition:fixedが動きません。iPhoneではuser-scalable=noの指定がなくてもposition:fixedが動きますがけっこう挙動が微妙なのでuser-scalable=noは指定しておいたほうが良いでしょう。 サンプル(user-scalable=noあり) サンプル(us
Androidのposition:absoluteとフォームの問題 Androidではposition:absoluteをした要素内にフォーム部品があると色々と不具合があるようです。 例えば、次のようにフォーム部品の背景になにか文字列があるような状態にしてしまうとAndroid2.2でフォームが選択できなくなります。Android2.1ではちゃんと選択できた。 <style> body{ margin:0; } #search{ width:100%; height:100px; background:blue; position:absolute; } #back{ width:100%; height:100px; } </style> <div id="search"> <br> <select> <option>選択1</option> <option>選択2</option> <
Androidでfont-weight:boldを適用する方法 Androidでは日本語にfont-weight:boldが適用されません。 <p style="font-weight:normal">ノーマル normal</p> <p style="font-weight:bold">ボールド bold</p> このHTMLをAndroidで確認すると次のようになります。 日本語だけ太字になっていないですね、デフォルトのフォントにbold体がないらしいんですが、デバイス毎にフォントも変わるのでfont-familyでは回避できず。 対策としてはfont-weightの代わりにtext-shadowを利用して太字にします。 <p style="text-shadow:1px 0 0 black">ボールド bold</p> ただ、この方法だとiPhoneでは太字になるけどAndroidで
HTML5が使えるスマートフォンOS HTML5が使えると言うと少し言いすぎですが、headerなどの新要素に対してdisplay:blockが指定されているOSです。 iPhoneなどではiOS4.0以上から、Androidでは2.2からdisplay:blockが適用されています。 それ以下のバージョンでHTML5を利用したい場合は、 article, aside, figure, footer, header,hgroup, nav, section { display:block; } といったdisplayの指定が必要です。 Safariや最新のiPhoneで検証してたら忘れがちになりそうなのでメモ。 追記:@hilokiから「dialogはもう抜きでよろしいかもです!」と指摘いただいのたで削除しました。そういえばこいつはHTML5から削除されたんですよね。 スポンサードリンク
【スマホ対応サイト制作のより詳しい記事はこちら】 1.メニュー編 2.HTMLとCSSで画像を操る編(前編) 2.HTMLとCSSで画像を操る編(後編) スマホサイトの作り方関連のブログとかを見てて、viewport周りの基本的な設定は書かれているのですが、 個人的に重要だと思うポイントが、なかなかどなたも書いてらっしゃらないような気がするので、まとめてみました。 それは、 とにかく内側のHTML要素をハミ出さないように作る どうしてか? ふつうは、スマホサイトというのは縦スクロールしかさせたくないですよね。 例えば、iPhoneで言うPortrait(縦)表示のとき、横幅320pxを超えたページ構成になると、 おかしな横スクロールが発生してしまいます。 viewportで拡大とかの禁止をおこなっていても、そうなります。 (まぁ、拡大とは意味が違うので当然なのですが。。。) 具体的にどうい
iPhoneとAndroidに搭載されているブラウザは同じWebkitですが、バージョンの違いから表示が若干異なる部分があるようです。そこでiPhoneで表示された場合はbodyにclass=”iphone”、Androidで表示された場合はbodyにclass=”android”を付与するjavascriptをご紹介します。 サンプル サンプル ※iPhone/Androidで見てみてください。 ダウンロード ip-ad.zip 動作確認機種 docomo xperia、softbank desire iPhone3G、iPod touch 使い方 ダウンロードしたip-ad.jsをjquery.jsと一緒に読み込むだけで動作します。 HTMLコーダーからフロントエンドエンジニアにステップするために必要な知識と技術を解説。 現場で求められる人材となるためには、何を知っていて、何ができなけ
WebサイトをiPhone/Androidに最適化するには、PCサイトとは別にスマートフォン専用サイトを用意するのがベストですが、コストや時間などの理由で難しい場合があります。そこで今回は、PC向けのWebサイト(HTML)はそのまま利用し、CSSとJavaScriptだけでレイアウトやデザインを変更する「クロスデバイスサイト」の作り方を説明します。題材は、筆者が制作した「iPhone/Android Webサイト制作出張セミナー」のWebサイトです。 このサイトは1ページ完結の告知サイトで、左右2段組みで構成されています。左カラムにはナビゲーションメニューを、右カラムにはメインコンテンツを配置し、ナビゲーションメニューをクリックするとページ内リンクで表示する部分を変えられます。iPhone/Androidからアクセスしたとき、このページを以下のように表示するようにします。 PCサイトのマ
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く