• 検索結果がありません。

分散情報システム構成法

N/A
N/A
Protected

Academic year: 2021

シェア "分散情報システム構成法"

Copied!
20
0
0

読み込み中.... (全文を見る)

全文

(1)

Web Information System Design

No.3 Web文書にスタイルを付ける

Tatsuya Hagino (hagino@sfc.keio.ac.jp)

(2)

Webページの構成要素

2

直交技術を組み合わせる

内容

スタイル

プログラミング

Webページ

Web文書

HTML

内容

スタイル

CSS

JavaScript

プログラミング

(3)

内容と表示

3

内容

情報

データ

Webページのもっとも重要な部分

表示(表現)

スタイル

飾り

デザイン

内容をいかに見せるか

(4)

内容と表示の分離

分離する利点

HTMLの役割がはっきりする

内容を変えずにスタイルだけを変えることができる

複数の文書で同じスタイルを共有できる

サイト全体を統一することができる

ユーザがスタイルを変えることができる

アクセシビリティの向上

4

HTML

stylesheet

HTML

HTML

stylesheet

user choice

share

http://www.csszengarden.com/

CSS Zen Garden

(5)

CSSとは?

5

構造化文書に表示を与える

HTML文書に主に用いられるが

XMLアプリケーション一般に使うこ

ともできる.

内容と表示の分離

内容を書きやすい

サイトの管理が容易になる

アクセシビリティが上がる

CSSの3つのレベル

CSS1 (Cascading Style Sheets, level 1)

http://www.w3.org/TR/REC-CSS1-961217.html

CSS2 (Cascading Style Sheets, level 2)

http://www.w3.org/TR/REC-CSS2

(6)

HTMLでCSSの与え方

6

HTMLのheadに記述する

CSSファイルをリンクする

<!DOCTYPE HTML> <html> <head>

<title>Bach's home page</title> <style type="text/css">

h1 { color: blue } </style>

</head> <body>

<h1>Bach's home page</h1> <p>Johann Sebastian Bach

was a prolific composer.</p> </body>

</html>

<!DOCTYPE HTML> <html>

<head>

<title>Bach's home page</title>

<link rel="stylesheet" href="bach.css" type="text/css" />

</head> <body>

<h1>Bach's home page</h1> <p>Johann Sebastian Bach

was a prolific composer.</p> </body> </html> h1 { color: blue; text-align: center; }

CSSファイル

<h1 style="color: blue">Bach's home page</h1>

<p>Johann Sebastian Bach

was a prolific composer.</p>

(7)

CSSの書き方

7

セレクタにより適応箇所を指定

要素名, ID, パターン

属性と値を並べて書く

宣言的

継承とカスケード

子要素は親要素の属性を継承する

複数のスタイルシートをカスケードする

宣言的

vs

手続き的

body {

font-family: "Gill Sans", sans-serif;

font-size: 12pt;

margin: 3em;

}

(8)

宣言的

vs 手続き的

8

宣言的

単純に記述する

規則を並べる

編集が可能

細かく書かないといけないので面倒

手続き的

手続きを書く

プログラム

編集が難しい

プリミティブは少なくて済む

プログラム

出力

修正が難しい

(9)

セレクタ

9

スタイルを適用する要素を指定

パターンマッチ

Pattern Meaning

* Matches any element.

E Matches any E element (i.e., an element of type E).

E F Matches any F element that is a descendant of an E element. E > F Matches any F element that is a child of an element E.

E:first-child Matches element E when E is the first child of its parent. E:link

E:visited Matches element E if E is the source anchor of a hyperlink of which the target is not yet visited (:link) or already visited (:visited). E:active

E:hover E:focus

(10)

セレクタ(続き)

10

Pattern Meaning

E:lang(c) Matches element of type E if it is in (human) language c (the document language specifies how language is determined).

E + F Matches any F element immediately preceded by an element E.

E[foo] Matches any E element with the "foo" attribute set (whatever the value). E[foo="warning"] Matches any E element whose "foo" attribute value is exactly equal to

"warning".

E[foo~="warning"] Matches any E element whose "foo" attribute value is a list of space-separated values, one of which is exactly equal to "warning".

E[lang|="en"] Matches any E element whose "lang" attribute has a hyphen-separated list of values beginning (from the left) with "en".

E.warning

HTML only

. The same as E[class~="warning"]. E#myid Matches any E element ID equal to "myid".

(11)

セレクタの例

11

グルーピング

h1, h2, h3 { font-family:

sans-serif }

子孫

h1 { color: red }

em { color: red }

h1 em { color: blue }

子供

body > p { line-height: 1.3 }

div ol > li p

math + p { text-indent: 0 }

h1 + h2 { margin-top: -5mm }

属性

h1[title] { color: blue; }

span[class=example] { color: blue; }

a[rel~="copyright"]

*[lang|="en"] { color : red }

class属性

*.pastoral { color: green }

.pastoral { color: green }

*[class~="pastoral"] { color: green }

j1.pastoral { color: green }

p.pastoral.marine { color: green }

ID

(12)

疑似クラスと疑似要素

疑似

クラス

div > p:first-child { text-indent: 0 }

a:link { color: red } /* unvisited links */

a:visited { color: blue } /* visited links */

a:hover { color: yellow } /* user hovers */

a:active { color: lime } /* active links */

:lang(fr) > q { quotes: '<<' '>>' }

疑似

要素

p:first-line { text-transform: uppercase }

p:first-letter { font-size: 200%; font-style: italic; font-weight: bold;

float: left }

h1:before { content: counter(chapno, upper-roman) ". " }

body:end { content: "The End" }

(13)

カスケード

13 

複数のスタイルシート

 著者のスタイルシート  利用者のスタイルシート  ブラウザ(ユーザエージェント)のスタイルシート 

優先度

1. 利用者が !important と指定したもの 2. 著者が !important と指定したもの 3. 著者の指定 4. 利用者の指定 5. デフォールト 

セレクタの順

1. IDによる指定 (インラインを含む) 2. 属性による指定 3. 要素による指定 

同順の場合

 より限定されたものを順位が高いと考える  @import で取り込まれたものは最初に取り込まれたと 考え優先度は低い

/* From the user's style sheet */ p { text-indent: 1em ! important } p { font-style: italic ! important } p { font-size: 18pt }

/* From the author's style sheet */ p { text-indent: 1.5em !important } p { font: 12pt sans-serif !important } p { font-size: 24pt }

HTML

CSS CSS CSS 著者 スタイルシート 利用者 スタイルシート ユーザエージェント スタイルシート

(14)

セレクタと継承とカスケード

14

カスケード

より限定

#id

.class

継承

祖先

継承

著者

スタイル

シート

ユーザ

スタイル

シート

ユーザエー

ジェント

スタイル

シート

セレクタ

カスケード

(15)

実際の値の計算

1.

指定された値

カスケードの値を用いる

親要素から継承された値を用いる

デフォールト値を用いる

2.

計算された値

絶対的な値(px, cmなど)はそのまま

相対的な値(em, %など)は絶対的な値を計算する

3.

実際の値

可能な値にまるめる

15

(16)

ボックスモデル

16

ブロックボックス

段落用

垂直につながる

インラインボックス

段落内の文書要

素用

横につながる

親のブロックボック

スをはみ出すと改

(17)

位置の指定

17 

Containing block

 子要素を描画する箱  子要素は親要素のcontaining block内におか れる  はみ出しても構わない 

初期containing block

 ルート要素のcontaining block  width とheight属性で大きさを指定  widthがautoのときはviewportの幅を使う  heightがautoの場合は自動的に伸びる 

Float box

 float:left と float:right でしたいされた箱を左 あるいは右に移動させる  移動後にblock boxは重なりを関係なく配置  inline boxはfloatと重ならないように配置  clear 属性でblock boxとfloatを重ならないよ

うに指定することも可能 

位置の指定

 position: static  通常の配置  position: relative  相対的に位置をずらす  position: absolute  containing boxにおける位置を指定  position: fixed  viewportにおける位置を指定

(18)

レイアウト例

18

Menu

Main content

<body>

<section>

Menu

</section>

<article>

Main content

</article>

</body>

section {

float: left;

width: 200px;

}

article {

left-margin: 210px;

}

(19)

音声スタイルシート

19

volume

speak

pause-before, pause-after

cue-before, cue-after

play-during

azimuth, elevation (3 dimensional sound)

speech-rate, voice-family, pitch, pitch-range, stress,

richness

(20)

まとめ

20

原理

宣言的 vs 手続き的

スタイルシート

内容と表示の分離

CSS

セレクタ

カスケード

継承

参照

関連したドキュメント

By the algorithm in [1] for drawing framed link descriptions of branched covers of Seifert surfaces, a half circle should be drawn in each 1–handle, and then these eight half

In this paper we show how to obtain a result closely analogous to the McAlister theorem for a certain class of inverse semigroups with zero, based on the idea of a Brandt

For further analysis of the effects of seasonality, three chaotic attractors as well as a Poincar´e section the Poincar´e section is a classical technique for analyzing dynamic

We will give a different proof of a slightly weaker result, and then prove Theorem 7.3 below, which sharpens both results considerably; in both cases f denotes the canonical

OFFI CI AL SCORE CERTI FI CATE GTEC (4技能) (CBT可). Test Repor t For m I ELTS™(Academi c

To lower bound the number of points that the excited random walk visits, we couple it with the SRW in the straightforward way, and count the number of “tan points” visited by the

In the section we investigate the connection between DF-valued holomorphic mappings of uniformly bounded type on DF-spaces and the linear topological invariants (LB ∞ ) and (DN ).

Let T (E) be the set of switches in E which are taken or touched by the jump line of E. In the example of Fig. This allows us to speak of chains and antichains of switches.. An