エディタ アドオンを Google スプレッドシート、ドキュメント、スライド、フォームのように見せるには、以下の CSS パッケージにリンクして、フォント、ボタン、フォーム要素に Google スタイルを適用します。CSS パッケージの使用例については、ドキュメント アドオンのクイックスタートをご覧ください。CSS パッケージを使用するには、各 HTML ファイルの先頭に次のコードを追加します。
<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons1.css">
フォーム要素のスタイルをすべてのブラウザで完全に制御できるわけではありません。特に <select>
要素は、Firefox と Internet Explorer では適切に機能しますが、一部に視覚的なアーティファクトを表示します。特定のブラウザでスタイルがどのように表示されるかを確認するには、そのブラウザでこのページを読み込みます。
タイポグラフィ
すべてのテキストに Arial フォントを使用し、用途に応じて以下のスタイルを使用します。
使用方法と外観 |
CSS パッケージによるマークアップ |
|
<h1>Titles and headers</h1>
<b>Bold text</b>
Normal text
<a href="">Links</a>
<span class="current">Current navigation selection</span>
<span class="error">Form input errors</span>
<span class="gray">Gray text</span>
<span class="secondary">Secondary text</span> |
標準タイプのボタン(<button>
、<input type="button">
、<input type="submit">
)と <a class="button">
を使用できます。横方向に隣接するボタンは自動的に配置されます。さまざまな用途向けに、複数の色が用意されています。
用途 |
デザイン |
CSS パッケージによるマークアップ |
メインの操作 |
|
<button class="action">Translate</button> |
サブアクション |
<button>Close</button> |
アクションを作成 |
<button class="create">Create</button> |
共有アクション |
<button class="share">Share</button> |
チェックボックス
例 |
CSS パッケージによるマークアップ |
|
<div>
<input type="checkbox" id="checkbox1" checked>
<label for="checkbox1">Checked</label>
</div>
<div>
<input type="checkbox" id="checkbox2">
<label for="checkbox2">Unchecked</label>
</div>
<div>
<input type="checkbox" id="checkbox3" checked disabled>
<label for="checkbox3">Checked, disabled</label>
</div>
<div>
<input type="checkbox" id="checkbox4" disabled>
<label for="checkbox4">Unchecked, disabled</label>
</div> |
例 |
CSS パッケージによるマークアップ |
|
<div>
<input type="radio" name="radio-a" id="radio1" checked>
<label for="radio1">Checked</label>
</div>
<div>
<input type="radio" name="radio-a" id="radio2">
<label for="radio2">Unchecked</label>
</div>
<div>
<input type="radio" name="radio-b" id="radio3"
checked disabled>
<label for="radio3">Checked, disabled</label>
</div>
<div>
<input type="radio" name="radio-b" id="radio4" disabled>
<label for="radio4">Unchecked, disabled</label>
</div> |
例 |
CSS パッケージによるマークアップ |
|
<div class="block form-group">
<label for="select">Select</label>
<select id="select">
<option selected>Google Docs</option>
<option>Google Forms</option>
<option>Google Sheets</option>
</select>
</div>
<div class="block form-group">
<label for="disabled-select">Disabled select</label>
<select id="disabled-select" disabled>
<option selected>Google Docs</option>
<option>Google Forms</option>
<option>Google Sheets</option>
</select>
</div> |
テキスト エリア
例 |
CSS パッケージによるマークアップ |
|
<div class="form-group">
<label for="sampleTextArea">Label</label>
<textarea id="sampleTextArea" rows="3"></textarea>
</div> |
テキスト フィールド
例 |
CSS パッケージによるマークアップ |
|
<div class="inline form-group">
<label for="city">City</label>
<input type="text" id="city" style="width: 150px;">
</div>
<div class="inline form-group">
<label for="state">State</label>
<input type="text" id="state" style="width: 40px;">
</div>
<div class="inline form-group">
<label for="zip-code">Zip code</label>
<input type="text" id="zip-code" style="width: 65px;">
</div> |
多くのアドオンでは、高さは可変であるものの、スクロールしないブランディング領域を設ける必要があるため、サイドバーのスタイル設定が難しい場合があります。以下は、Google ドキュメント アドオンのクイックスタートにあるサイドバーを簡略化してコピーしたものです。テキスト領域の右下隅をドラッグしてコンテンツをサイドバーより高くした場合、コンテンツ領域は自動的にスクロールしますが、下部のブランディングはスクロールしません。
この例では、sidebar
クラスを使用して正しいパディングを適用し、bottom
クラスを使用してブランディング領域を強制的に下部に配置しています。ローカルクラスの branding-below
は、サイドバーのメインエリアを下から離す領域を定義します。
例 |
CSS パッケージによるマークアップ |
|
<style>
.branding-below {
bottom: 56px;
top: 0;
}
</style>
<div class="sidebar branding-below">
<div class="block form-group">
<label for="translated-text">
<b>Translation</b></label>
<textarea id="translated-text" rows="15">
</textarea>
</div>
<div class="block">
<input type="checkbox" id="save-prefs">
<label for="save-prefs">
Use these languages by default</label>
</div>
<div class="block">
<button class="blue">Translate</button>
<button>Insert</button>
</div>
</div>
<div class="sidebar bottom">
<span class="gray">
Translate sample by Google</span>
</div> |