Trans

NPOやソーシャルビジネスの創業・経営・マネジメント

CSS+JavaScriptで画像に柔軟なレイアウトを作る。(日本語訳)

If I Told You You Had a Beautiful Figure...


OK使
調1238px 283px
CMS使CMS使
DOM scripting
WebJavaScript
使img

さっぱりとした図表


script1microformat使
<div class="figure">
  <img src="fa.jpg" alt="" />
  <p class="credit"><abbr class="type" title="Photograph">Photo</abbr>by<cite>Aaron Gustafson</cite></p>
  <p class="caption"><em class="title">Figure 1</em> The &#8220;Faces of the Fallen&#8221; exhibit at Arlington National Cemetery.</p>
</div>













Web使90使使
<div class="figure">
  <img src="faces-of-the-fallen.jpg" alt="The &#8220;Faces of the Fallen&#8221; exhibit at Arlington National emetery." />
</div>

microformatrel="license"hcardgeo-positioning datalongdesc使

魅力的な図表


JavaScript使使
.figure {
  margin: 0 0 1.5em;
}
.figure p {
  margin: 0;
}
.figure .credit {
  font-size: .8em;
  text-align: right;
}
.figure .credit cite {
  font-style: inherit;
}
.figure .caption {
  font-style: italic;
  font-size: 1.1em;
}
.figure .title {
  font-style: normal;
  font-weight: bold;
}
.figure .title:after {
  content: ":";
}

Figure 1body

floatCSS使micoformatexisting practices
50float
31


(一)

(二)class

(三)


31JavaScript1scriptFigureHandler使

柔軟な図表

FigureHandlerはあなたのサイトにおける図表のレイアウトを非常に簡単にするものだ。それはあなたの仕事で使えば、役立つデフォルトスタイルのセットだ。しかし、それはまた簡単に細かいカスタマイズも行うことができる。

表1: FigureHandlerのデフォルトクラス
カラムのパーセント 適用されるクラス
カラムのパーセント 適用されるクラス
0-25 quarter-col
25-34 third-col
34-50 half-col
50-67 two-thirds-col
67-75 three-quarters-col
75-100 full-col

FigureHandler.jsPrototypeFigureHandlerFigureHandler
if( typeof( Prototype ) != 'undefined' &&
    typeof( FigureHandler ) != 'undefined' ){
  Event.observe( window, 'load', function(){
    new FigureHandler; } );
}

 FigureHandler


(一)divfigure

(二)figure

(三)class


FigureHandler調
FigureHandler
FigureHandleridid
if( typeof( Prototype ) != 'undefined' &&
    typeof( FigureHandler ) != 'undefined' ){
  Event.observe( window, 'load', function(){
    new FigureHandler( 'main' ); } );
}

 FigureHandlerJSONclass 
if( typeof( Prototype ) != 'undefined' &&
    typeof( FigureHandler ) != 'undefined' ){
  Event.observe( window, 'load', function(){
    new FigureHandler( 'main', { '0-27':   'small',
                                 '27-100': 'large' } );
    new FigureHandler( 'extras', { '0-50':   'potato',
                                   '50-100': 'tomato' } );
  });

Go figure


FigureHandlermicroformatFigureHandler

訳者より一言


JavaScriptCSSJS使
(X)HTML+CSS(+microfomats)使JavaScriptJavaScript使WebJavaScript
CSS使FigureHandler