background-imageの使い方
Web標準HTML/CSS > background-imageの使い方
background-image
プロパティの説明
background-imageは、背景に画像を指定するプロパティです。画像が読み込まれなかった場合に備え、background-colorプロパティで背景色も指定すべきです。全ての要素に指定することができます。
指定できる値
- none
- 標準設定。背景画像を指定しません。
- 画像をおいたURL
- 自分が背景画像を置いたアドレスを指定します。
サンプル
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"https://www.w3.org/TR/html4/strict.dtd">
<html 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">
<!--
.b1{
color:#000000;
background-color:#cccccc;
background-image:url(../img/wp/wall.gif);
}
-->
</style>
</head>
<body>
<h1>サンプルページ</h1>
<p class="b1">背景画像を指定しています。</p>
</body>
</html>