第二步:创建html模板及文件目录等

 

1.创建html模板。
  代码如下:

div css xhtml xml Example Source Code Example Source Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
<title>CompanyName - PageName</title>
<meta http-equiv="Content-Language" content="en-us" /> 
<meta http-equiv="imagetoolbar" content="no" />
<meta name="MSSmartTagsPreventParsing" content="true" /> 
<meta name="description" content="Description" />
<meta name="keywords" content="Keywords" /> 
<meta name="author" content="Enlighten Designs" />
<style type="text/css" media="all">@import "css/master.css";</style>
</head>
<body>
</body>
</html>


  将其保存为index.html,并创建文件夹css,images,网站结构如下:



2.创建网站的大框:
  建立一个宽760px的盒子,它将包含网站的所有元素。
  在html文件的<body>和</body>之间写入

div css xhtml xml Example Source Code Example Source Code
<div id="page-container">
Hello world.
</div>


  创建css文件,命名为master.css,保存在/css/文件夹下。写入:

div css xhtml xml Example Source Code Example Source Code
#page-container {
width: 760px;
background: red;
}


  控制html的id为page-container的盒子的宽为760px,背景为红色。

  现在为了让盒子居中,写入margin: auto;,使css文件为:

div css xhtml xml Example Source Code Example Source Code]
#page-container {
width: 760px;
margin: auto;
background: red;
}


  现在你可以看到盒子和浏览器的顶端有8px宽的空隙。这是由于浏览器的默认的填充和边界造成的。消除这个空隙,就需要在css文件中写入:

div css xhtml xml Example Source Code Example Source Code[
html, body {
margin: 0;
padding: 0;
}


 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值