HTML整站规划与规范

文章目录

命名规则

命名

根据每块元素的主题、功能、页面上的位置命名,便于后期更改与维护。

另外:如果所有样式放在同一文件下,可以给每个页面起简称防止命名冲突,如:iPicTab、pPicTab。

命名书写

可以参照以下某一个规则进行全站书写
php规则命名 :每个单词中间以"_"隔开,如: #main_left_box{}
驼峰命名:从第二个单词开始,每个单词首字母大写,如:#mainLeftBox{}

包含样式规范

写包含样式的时候能找到这个元素并且不影响其他元素即可,不需要列出所有元素

冗杂举例:#whyQq ol li h3 a {}

正常举例:#whyQq a {}

样式重置

用到那个标签,对那个标签进行重置。

样式引入

csharp 复制代码
<link rel="stylesheet" href="css/index.css">

页面结构

页面宽度

实际内容宽度,并不包括没有内容的两边。

页面高度与背景

当页面背景图片像素小于实际高度时。可以同时添加背景色,使得网页不突兀。

html 复制代码
body{margin: 0;background: url(/img/bg.gif) repeat-x #d9e2ce; height: 2000px;}

页面设计

html 复制代码
<div class="wrap"> 
        <div class="header"></div>
        <ul class="nav"></ul>
        <div class="main"></div>
  </div>

将页面内容用一个div包裹起来:

1.html按照每个标签加载内容,所以同一个div整个页面会同时加载显示所有内容,加载较长页面时,用户体验不友好。

2.并不利于后期扩展。

建议布局

html 复制代码
<div id="header">     
        <div class="header wrap"></div>    
    </div>
    <ul id="nav" class="wrap"></ul>
    <div id="picTab" class="wrap"></div>
    <div id="whyQQ" class="wrap"></div>

网址图标

html 复制代码
<link rel="icon" href="/img/aiv01-79xtx-001.ico">

示例

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="css/index.css">
    <link rel="icon" href="/img/aiv01-79xtx-001.ico">
    <title>Document</title>
    <!--解决 :IE6不支持png图片透明 引用DD_belatedPNG  父级加相对定位-->

    <!--[if IE 6]>
    <script src="js/DD_belatedPNG_0.0.8a.js"></script>
    <script>
        DD_belatedPNG.fix('#nav a:hover,#nav .active');
    </script>
    <![endif]-->
</head>
<body>
    <div id="header">     
        <div class="header wrap"></div>    
    </div>
    <ul id="nav" class="wrap">
        <li>
            <a class="active" href="index.html" >首&nbsp;&nbsp;页</a>
        </li>
        <li>
            <a href="index.html" >产品介绍</a>
        </li>
        <li>
            <a href="index.html" >企业空间</a>
        </li>
        <li>
            <a href="index.html" >成功案例</a>
        </li>
        <li>
            <a href="index.html" >产品支持</a>
        </li>
        <li>
            <a href="index.html" >产品帮助</a>
        </li>
        <li>
            <a href="index.html" >产品帮助</a>
        </li>
    </ul>
    <div id="picTab" class="wrap"></div>
    <div id="whyQQ" class="wrap"></div>
</body>
</html>
css 复制代码
@charset "utf-8";

/*reset*/
body{margin: 0;background: url(/img/bg.gif) repeat-x #d9e2ce; min-width: 960px; }
a{text-decoration: none;}
li{list-style: none;}
.wrap{width: 960px; margin: 0 auto;}
#header{background: url(/img/head_bg.jpg) no-repeat center 0 ;height: 120px;}
.header{height: 94px;}
 #nav{height: 43px; background: url(/img/nav_bg.png) no-repeat;}
 #nav li{float: left;width: 118px;padding-right: 8px;position: relative; } 
 #nav a{display: block;padding-top: 1px;line-height: 42px; font-size: 16px;color: #fdfbf9;text-align: center;background: url(/img/nav_hover.png) no-repeat center 50px;}
 #nav a:hover,#nav .active{background-position: center 0;}


/*public*/


/*end  public*/


/*index*/


/*end  index*/
相关推荐
晓晨的博客4 分钟前
ROS1录制的bag包转换为ROS2格式
前端·chrome
Wect12 分钟前
LeetCode 72. 编辑距离:动态规划经典题解
前端·算法·typescript
donecoding25 分钟前
别再让 pnpm 跟着 nvm 跑了!独立安装终极指南
前端·node.js·前端工程化
GISer_Jing27 分钟前
AI全栈转型_TS后端学习路线
前端·人工智能·后端·学习
竹林81827 分钟前
被The Graph的GraphQL查询坑了三天,我用一个真实DeFi项目把链上数据索引彻底搞懂了
前端·graphql
漫游的渔夫27 分钟前
前端开发者做 Agent:别只会执行,用 4 类失败策略让 AI 知道怎么停
前端·人工智能·typescript
用户0595401744630 分钟前
把多级缓存一致性验证从手工测试换成 Pytest 参数化,Bug 排查时间缩短 90%
前端·css
暗不需求32 分钟前
深入理解 LangChain:AI 应用开发框架的工程化实践
前端·langchain
用户059540174461 小时前
把 Redis 持久化测试从 800 行 Shell 换成 30 行 pytest,排错效率翻了 10 倍
前端·css
GISer_Jing1 小时前
AI全栈工程师知识体系全景:从前后端核心架构到落地项目全拆解
前端·人工智能·后端·ai编程