我有以下代码,正如预期的那样,在Firefox和IE中都显示了一个灰色矩形.只要我在前面添加DOCTYPE(HTML 4.01 Transitional),它就会只显示一个空白页面.在线验证员说文件没问题.怎么了?我应该关心DOCTYPE吗?
<html>
<head>
<title>Title</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<style type="text/css">
#gallery
{
width:750;
height:548;
background-color: #f0f0f0;
}
</style>
</head>
<body>
<div id="gallery">
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
您需要指定宽度和高度的单位.我假设你要像素那样:
#gallery
{
width: 750px;
height: 548px;
background-color: #f0f0f0;
}
Run Code Online (Sandbox Code Playgroud)