1、生成css文件:D:\wamp\www\MyWeb\Public\css\common.css
文件内容:
body{ background: #ffb; color: #333;}
.result{border:1px solid #d4d4d4; background:#FFC;color:#393939; padding:8px 20px;float:auto; width:350px;margin:2px}
.main{ padding: 0; margin: 0;font-size:16px; font-family: "微软雅黑"}
2、修改模板文件:D:\wamp\www\MyWeb\Application\Home\View\Index\index.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<load href="__PUBLIC__/Css/Common.Css" />
<title>ThinkPHP示例:模板</title>
</head>
<html>
<body>
<div class="main">
<block name="title">提示</block>
<block name="content1"><div class="result">这里是模板定义内容1</div></block>
<block name="content2"><div class="result">这里是模板定义内容2</div></block>
</div>
</body>
</html>
3、浏览:http://localhost/myweb/
4、看一下网页源代码,注意看模板文件位置已被替换:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="/myweb/Public/Css/Common.Css" />
<title>ThinkPHP示例:模板</title>
</head>
<html>
<body>
<div class="main">
提示
<div class="result">这里是模板定义内容1</div>
<div class="result">这里是模板定义内容2</div>
</div>
</body>
</html>