我正在尝试创建适合页面顶部并填充宽度的div元素。我已经填满了宽度,但是我无法使它适合页面的顶部,div上方有一个小间隙。div适合页面顶部
我已经设置身体有0边距和0填充,所以什么是在顶部创建〜20px的差距。
我的HTML如下
<!DOCTYPE html>
<html lang="en">
<head>
<title>Photography</title>
<style>
p {
padding-top: 20px;
padding-right: 20px;
padding-bottom: 20px;
padding-left: 20px;
}
</style>
</head>
<body bgcolor="#bbbbbb" style="margin:0;padding:0">
<div style="background-color:#999999;margin:0;padding:0">
<h1 style="color:#ffffff" >Photographs</h1>
</div>
<div>
<p align="center" ><img src="IMG_2574.png" alt="Campground" style="width:;height:;"></p>
<p align="center"><img src="IMG_2593.png" alt="Lake Sunset" style="width:;height:;"></p>
<p align="center"><img src="IMG_2702.png" alt="Hudson River" style="width:;height:;"></p>
<p align="center"><img src="IMG_3129.png" alt="Central Park" style="width:;height:;"></p>
<p align="center"><img src="IMG_3229.png" alt="The Met" style="width:;height:;"></p>
<p align="center"><img src="IMG_3384.png" alt="Break Dancer" style="width:;height:;"></p>
<p align="center"><img src="IMG_3486.png" alt="Brooklyn Bridge" style="width:;height:;"></p>
<p align="center"><img src="IMG_3656 2.png" alt="Rockefeller Center" style="width:;height:;"></p>
<p align="center"><img src="IMG_3809 2.png" alt="Times Square" style="width:;height:;"></p>
<p align="center"><img src="IMG_3824 2.png" alt="Top of the Rock" style="width:;height:;"></p>
<p align="center"><img src="IMG_7620.png" alt="Lake Louise" style="width:;height:;"></p>
<p align="center"><img src="IMG_7907.png" alt="Mt Hood" style="width:;height:;"></p>
<p align="center"><img src="IMG_7950.png" alt="Multnomah Falls" style="width:;height:;"></p>
<p align="center"><img src="IMG_8193.png" alt="Cape Kiwanda" style="width:;height:;"></p>
<p align="center"><img src="IMG_8254.png" alt="Yaquina Head Lighthouse" style="width:;height:;"></p>
<p align="center"><img src="IMG_8377.png" alt="Cape Perpetua" style="width:;height:;"></p>
<p align="center"><img src="IMG_8441.png" alt="Simpson Reef" style="width:;height:;"></p>
<p align="center"><img src="IMG_9711.png" alt="Nevada" style="width:;height:;"></p>
<p align="center"><img src="IMG_9730.png" alt="Salt Flats" style="width:;height:;"></p>
</div>
</body>
</html>
谢谢。当我将div位置固定时,顶部空间再次出现。为什么是这样? – ScottF
@ScottF请选择此项:https://jsfiddle.net/1rLkvsv1/5/ –
此外,请尽量避免网络上文件名称中的空格。有时可以,有时不可以。一般来说,'IMG_3824_2.png'比''IMG_3824 2.png'好 –