/// BANGBOO BLOG ///

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

April 8, 2006

The beginning of CSSレイアウト
left
right



<html>
<head>
<style type="text/css">
#box { text-align: center;}
#campas { text-align: left; margin-left: auto; margin-right: auto; border: 3px solid #cccccc; width: 500px;}
#lbox { position:relative; margin: 10px; width: 210px; left: 10px; border: 3px solid #cccccc; float: left; }
#rbox { position:relative; margin: 10px; width: 210px; right: 10px; border: 3px solid #cccccc; float: right; }
</style>
</head>
<body>
<div id="box">
<div id="campas">
<div id="lbox">
left
</div>
<div id="rbox">
right
</div>
<br style="clear: both;" />
</div>
</div>
</body>
</html>

////////////////////CSSレイアウト(FireFox-IE対応)////////////////////////
text-alingは本来インライン要素を中央揃えにする。
divはブロック要素なので、中央揃えにするときはmargin-right:auto;とmargin-left:auto;を使用する。

body {text-align:center;}をレイアウトのために使用するのは適切でない。
余計なところまでセンタリングされてしまうことにもなる。
しかしながら他の要素であればレイアウトのためでも現実的には許される。#box { text-align: center;}

2重にセンタリングをIEバグのために行う。
- センタリングしたい要素にmargin-left: auto; margin-right: auto;として標準準拠でセンタリング
- その親でもIEバグ対策としてtext-align: center;を指定
- しかしその子の中では余計なところもセンタリングされるので再びtext-align: left;として戻す
IEバグについて詳しくは、
http://www.mozilla.gr.jp/standards/webtips0004.html

回り込み解除はスタイルシートで次に来る要素にclear:bothとしておいてもいいのですが、 1箇所だけのために外部ファイルに書くのも面倒。<br style="clear: both;">=<br clear="all">

単位の省略はしない

float要素は子要素とみなされず親要素を突き抜けてしまう 親要素にoverflow:auto;を指定するか、親要素のうしろに:afterで見えない要素を追加し,clear:bothする

////////////////////CSSレイアウト////////////////////////
コンテンツを<DIV>で羅列し、CSSでレイアウトを整える。

position: relativeの要素の子にposition: absoluteの要素を入れることで的確な位置を指定することもできる。
CSSのネストを行うとスタイルを有効にさせるところを細かく設定できる。
#p1{ xxx }
#p1 h1 { xxx }
<div id=p1><h1>xxxxx</h1>xxxxxxx</div>

画像の配置を以下のようにして行うことも可能。
#p1 h1 { background: url(h1.gif); width: 200px; height: 90px; }
#p1 h1 span { display: none; }
<div id=p1><h1><span>代替テキスト</span></h1></div>

同じidを複数の場所で指定しない、複数で利用する場合はclassを使用する。

このブログはCSSでレイアウトを整形しているのだが、Firefoxで崩れるとは知らなかった。標準的なCSSを使用しているつもりだったのだがIE特有のものだったためだ。2004年くらいはこれで大丈夫だったのだが。。いくつかCSSレイアウトのコツをまとめたのだが、いくらかはout of age?勘所ははずしていないと思うが、しかし細かいところで全然違うなぁ。継承の考え方が違うのか?→単位(px)を省略しないようにするとOK


twitter
Hatena
Google Buzz
newsing
Yahoo!
Buzzurl
Technorati
del.icio.us
Choix
Iza!
Livedoor Clip
Facebook
Evernote
 

Posted by funa : 11:22 PM | Web | Comment (0) | Trackback (0)


PhotoGallery


TWITTER
Search

Mobile
QR for cellphone  QR for smart phone
For mobile click here
For smart phone click here
Popular Page
#1Web
#2Hiace 200
#3Gadget
#4The beginning of CSSレイアウト
#5Column
#6Web font test
#7Ora Ora Ora Ora Ora
#8Wifi cam
#9みたらし団子
#10Arcade Controller
#11G Suite
#12PC SPEC 2012.8
#13Javascript
#14REMIX DTM DAW - Acid
#15RSS Radio
#16Optimost
#17通話SIM
#18Attachment
#19Summer time blues
#20Enigma
#21Git
#22Warning!! Page Expired.
#23Speaker
#24Darwinian Theory Of Evolution
#25AV首相
#26htaccess mod_rewite
#27/// BANGBOO BLOG /// From 2016-01-01 To 2016-01-31
#28竹書房
#29F☆ck CSS
#30Automobile Inspection
#31No ID
#32Win7 / Win10 Insco
#33Speaker
#34Arcade Controller
#35Agile
#36G Suite
#37Personal Information Privacy Act
#38Europe
#39Warning!! Page Expired.
#40GoogleMap Moblile
#41CSS Selectors
#42MySQL DB Database
#43Ant
#44☆od damnit
#45Teeth Teeth
#46Itinerary with a eurail pass
#47PHP Developer
#48Affiliate
#49/// BANGBOO BLOG /// From 2019-01-01 To 2019-01-31
#50/// BANGBOO BLOG /// From 2019-09-01 To 2019-09-30
#51/// BANGBOO BLOG /// On 2020-03-01
#52/// BANGBOO BLOG /// On 2020-04-01
#53Windows env tips
#54恐慌からの脱出方法
#55MARUTAI
#56A Rainbow Between Clouds‏
#57ER
#58PDF in cellphone with microSD
#59DJ
#60ICOCA
#61Departures
#62Update your home page
#63CSS Grid
#64恐慌からの脱出方法
#65ハチロクカフェ
#66/// BANGBOO BLOG /// On 2016-03-31
#67/// BANGBOO BLOG /// From 2017-02-01 To 2017-02-28
#68/// BANGBOO BLOG /// From 2019-07-01 To 2019-07-31
#69/// BANGBOO BLOG /// From 2019-10-01 To 2019-10-31
#70/// BANGBOO BLOG /// On 2020-01-21
#71Bike
#72Where Hiphop lives!!
#73The team that always wins
#74Tora Tora Tora
#75Blog Ping
#76無料ストレージ
#77jQuery - write less, do more.
#78Adobe Premire6.0 (Guru R.I.P.)
#79PC SPEC 2007.7
#80Google Sitemap
#81Information privacy & antispam law
#82Wifi security camera with solar panel & small battery
#83Hope get back to normal
#84Vice versa
#85ハイエースのメンテ
#86Camoufla
#87α7Ⅱ
#88Jack up Hiace
#89Fucking tire
#90Big D
#914 Pole Plug
#925-year-old shit
#93Emancipation Proclamation
#94Windows env tips
#95Meritocracy
#96Focus zone
#97Raspberry Pi
#98Mind Control
#99Interview
#100Branding Excellent
Category
Recent Entry
Trackback
Comment
Archive
<     March 2024     >
Sun Mon Tue Wed Thi Fri Sat
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
Link