CSSで背景色と余白を変更する
課題
【CSS05】
- 画像のような表示になるよう指定しなさい
- 色・文字サイズは自由設定(バランスは考慮すること)
- 解答は、エンベッド
- DTDは各自選択
<body> <h2>background-colorの設定</h2> <p>見出しには濃いめの色を背景に指定し、文字を白抜きにします。段落には見出しよりも薄い色を指定します。さらに見出しと段落の上下のマージンを0にして、ボックスの上下をくっつけ、パディングを1em指定します。</p> </body>
解答
背景色と余白 - 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>背景色と余白</title> <style type="text/css"> body { margin: 0px; } h2 { background-color: #0066ff; color: #ffffff; margin-bottom: 0px; padding: 1em; } p { background-color: #99bbff; line-height: 1.8; margin-top: 0px; padding: 1em; } </style> </head> <body> <h2>background-colorの設定</h2> <p>見出しには濃いめの色を背景に指定し、文字を白抜きにします。段落には見出しよりも薄い色を指定します。さらに見出しと段落の上下のマージンを0にして、ボックスの上下をくっつけ、パディングを1em指定します。</p> </body> </html>