<!doctype html><html><head><meta charset="UTF-8"><title>HTML5 Example</title><style type="text/css">body {?margin:50px;?background:pink;}*{?margin:0;?padding:0;}section{?width:980px;?background:#f5f5f5;?box-shadow:0 0 1px rgba(0,0,0,.4) inset;?box-sizing:border-box;?padding:40px;}section::after{? content:"";? display:table;? clear:both;}article{?width:49%;?float:left;?position:relative;}article:first-child{?margin-right:2%;}h1{?font-size:32px;?margin-bottom:15px;}p{?font-size:15px;?color:#777;}h1, p{?width:65%;?margin-left:35%;?font-family:Georgia, "Times New Roman", Times, serif;}img{?position:absolute;?top:0;}</style></head><body><section>? <article>??? <h1>Rip Van winkle</h1>??? <p>Many years ago, at the foothills of the Kaatskill (Kat-skill) mountains, was a little village. In the village lived a simple, good-natured fellow named Rip Van Winkle. He was a kind neighbour, ready to help anyone. </p>??? <img src="head1.png" alt="picture of Rip Van winkle">? </article>? <article>??? <h1>Robinson Crusoe</h1>??? <p>As Rip and his companion reached them, they stopped playing and stared at Rip with a fixed gaze. Rip was really frightened. His companion emptied the contents of the barrel into glasses and made Rip drink it.</p>??? <img src="head2.png" alt="picture of Rip Van winkle">? </article></section></body></html>代碼是著樣的,我在boby中設(shè)了背景,然后改了下margin的值,但是為什么是那個(gè)方框動(dòng)了,不是那個(gè)背景動(dòng)?
1 回答
已采納

Nyears
TA貢獻(xiàn)35條經(jīng)驗(yàn) 獲得超10個(gè)贊
在不設(shè)置html背景色的前提下,html的背景色等同于body的背景色
html{
? ? background-color:red;
? ? }
當(dāng)你單獨(dú)為HTML加背景就能體現(xiàn)你要的效果
- 1 回答
- 0 關(guān)注
- 997 瀏覽
添加回答
舉報(bào)
0/150
提交
取消