ウェブ学のすすめ

Study of Web Design & Programing

CSS Box Model 2

課題

【CSS12】

  • 画像のような表示になるよう指定しなさい
  • 色・文字サイズは自由設定(バランスは考慮すること)
  • 解答は、エンベッド
  • DTDは各自選択
  • この場合、リセットはしない
  • 左右均等空き(上下空きは指定しない)
<body>
<p>BOX and margin<br>
この領域はボックスといいます。テキストなどのコンテンツ内容を表示する領域です。マージンはこのボックスの余白のことをいいます。</p>
</body>


引用元:ボックスモデル - Webデザインの勉強|忘筌

解答

CSS Box Model 2 - jsdo.it - share JavaScript, HTML5 and CSS

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<title>CSS Box Model 2</title>
<style type="text/css">
p {
    color: #ffffff;
    font-family: 
	Meiryo,
	"メイリオ",
	"Hiragino Kaku Gothic Pro",
	"ヒラギノ角ゴ Pro W3",
	sans-serif;
    font-size: 1.2em;
    font-weight: bold;
    line-height: 1.6;
    margin-right: 48px;
    margin-left: 48px;
    padding: 3px;
    background-color: #00a5ff;
    border-width: 6px;
    border-color: #ffbb00; 
    border-style: solid;
}
</style>
</head>
<body>
<p>BOX and margin<br>
この領域はボックスといいます。テキストなどのコンテンツ内容を表示する領域です。マージンはこのボックスの余白のことをいいます。</p>
</body>
</html>

ポイント

margin(マージン)
  • margin-right」:右側の余白を指定
  • margin-left」:左側の余白を指定
border(ボーダー)

枠線を指定します。

  • border-width:上下左右の枠線の太さをまとめて指定
  • border-color:上下左右の枠線の色をまとめて指定
  • border-style:上下左右の枠線のスタイルをまとめて指定