search
HomeWeb Front-endHTML Tutorial项目:(前端部分)制作一个导航目录表格,统计黄石港区各社区各类人数_html/css_WEB-ITnose

一、设计表格样式

目标:定义表格的宽度、字体、背景颜色等。

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <title>黄石港区各类人数统计</title> 6     <style type="text/css"> 7         table.hovertable { 8             font-family: verdana,arial,sans-serif; 9             font-size:11px;10             color:#333333;11             border-width: 1px;12             border-color: #999999;13             border-collapse: collapse;14         }15         table.hovertable th {16             background-color:#c3dde0;17             border-width: 1px;18             padding: 8px;19             border-style: solid;20             border-color: #a9c6c9;21         }22         table.hovertable tr {23             background-color:#d4e3e5;24         }25         table.hovertable td {26             border-width: 1px;27             padding: 8px;28             border-style: solid;29             border-color: #a9c6c9;30         }31     </style>32 </head>

知识拓展:
1、font-family:

  CSS中font-family用来定义页面字体,一般定义3-4个(比如:font-family: verdana,arial,helvetica,sans-serif; )。第一个优先级最高。这样如果访问你网页的电脑没有安装你定义的第一个字体,它会用第二个,以此类推。如果都找不到,就用浏览器的默认字体显示你的网页。通常推荐字体:黑体、宋体、微软雅黑、Arial, Helvetica, sans-serif。

2、html5表格的使用:

表格 描述
定义表格
定义表格标题
定义表格的表头
定义表格的行
定义表格的单元
定义表格的页眉
定义表格的主体
定义表格的页脚
定义表格的列属性

3、CSS border-style属性:

  设置 4 个边框的样式

  

  最不可预测的边框样式是 double。它定义为两条线的宽度再加上这两条线之间的空间等于 border-width 值。不过,CSS 规范并没有说其中一条线是否比另一条粗或者两条线是否应该是一样的粗,也没有指出线之间的空间是否应当比线粗。所有这些都有用户代理决定,创作人员对这个决定没有任何影响。

4、border-collapse: collapse:

    为表格设置合并边框模型

  

二、设计表格效果

目标:将表格的表头加粗,鼠标移到某一行时会改变该行的颜色,鼠标移开则恢复原色。

 1 <body bgcolor="#9999FF"> 2     <div class="head"> 3         <hr /> 4         <h1 id="黄石港区各类人数统计">黄石港区各类人数统计</h1> 5         <hr /> 6     </div> 7     <div class="center"> 8         <table class="hovertable"> 9             <tr>10                 <th>社区</th><th>民主党派</th><th>无党派</th><th>党外知识分子</th><th>宗教人士</th><th>少数民族流动人口</th>11                 <th>少数民族常住人口</th><th>非公有制经济人士</th><th>新的社会阶层人士</th><th>出国和归国留学人员</th><th>港澳同胞(家属)</th>12                 <th>台湾同胞(家属)</th><th>华侨/归侨/侨眷</th>13             </tr>14             <tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';">15                 <td><a href="#">江北社区</a></td><td></td><td></td><td></td><td></td>16                 <td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>17             </tr>18             <tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';">19                 <td><a href="#">天方社区</a></td><td></td><td></td><td></td><td></td><td></td>20                 <td></td><td></td><td></td><td></td><td></td><td></td><td></td>21             </tr>22             <tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';">23                 <td><a href="#">天虹社区</a></td><td></td><td></td><td></td><td></td><td></td><td></td>24                 <td></td><td></td><td></td><td></td><td></td><td></td>25             </tr>26             <tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';">27                 <td><a href="#">大码头社区</a></td><td></td><td></td><td></td><td></td><td></td><td></td>28                 <td></td><td></td><td></td><td></td><td></td><td></td>29             </tr>30             <tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';">31                 <td><a href="#">老虎头社区</a></td><td></td><td></td><td></td><td></td><td></td><td></td>32                 <td></td><td></td><td></td><td></td><td></td><td></td>33             </tr>34             <tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';">35                 <td><a href="#">锁前社区</a></td><td></td><td></td><td></td><td></td><td></td><td></td>36                 <td></td><td></td><td></td><td></td><td></td><td></td>37             </tr>38             <tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';">39                 <td><a href="#">花湖社区</a></td><td></td><td></td><td></td><td></td><td></td><td></td>40                 <td></td><td></td><td></td><td></td><td></td><td></td>41             </tr>42         </table>43     </div>44 </body>45 </html>    

知识拓展:

1、javascript中onmouseover和onmouseout事件:

       onmouseover 用户鼠标移入元素时触发的事件。并执行onmouseover调用的函数。

       onmouseout 用户鼠标移开元素时触发的事件。并执行onmouseout调用的函数。

  HTML中可以用这两个事件改变背景颜色或者背景图片,例如:

  (1)用onmouseout  onmouseover 图像间相互变换:

1 <imagesrc="img1"onmouseover="this.src='img2'"onmouseout="this.src='img1'">

  (2)onmouseover  onmouseout 改变文字背景色:

1 <div width="100" height="100" onmouseover="style.backgroundColor='#fff'"2 onmouseout="style.backgroundColor='#bbb'" bgcolor="#bbb">文字</div>

  (3)onmouseover  onmouseout 改文字变背景图:

1 <div width="100" height="100" onMouseOver="this.background='1.gif'"2 onMouseOut="this.background='2.gif'" background="2.gif">文字</div>3 <image src="img1" onmouseover="this.src='img2'" onmouseout="this.src='img1'">

 

 

 

三、完成效果

1、打开效果

 

2、鼠标放上去的效果:

 

 

 

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Why are HTML attributes important for web development?Why are HTML attributes important for web development?May 12, 2025 am 12:01 AM

HTMLattributesarecrucialinwebdevelopmentforcontrollingbehavior,appearance,andfunctionality.Theyenhanceinteractivity,accessibility,andSEO.Forexample,thesrcattributeintagsimpactsSEO,whileonclickintagsaddsinteractivity.Touseattributeseffectively:1)Usese

What is the purpose of the alt attribute? Why is it important?What is the purpose of the alt attribute? Why is it important?May 11, 2025 am 12:01 AM

The alt attribute is an important part of the tag in HTML and is used to provide alternative text for images. 1. When the image cannot be loaded, the text in the alt attribute will be displayed to improve the user experience. 2. Screen readers use the alt attribute to help visually impaired users understand the content of the picture. 3. Search engines index text in the alt attribute to improve the SEO ranking of web pages.

HTML, CSS, and JavaScript: Examples and Practical ApplicationsHTML, CSS, and JavaScript: Examples and Practical ApplicationsMay 09, 2025 am 12:01 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML is used to build web page structure; 2. CSS is used to beautify the appearance of web pages; 3. JavaScript is used to achieve dynamic interaction. Through tags, styles and scripts, these three together build the core functions of modern web pages.

How do you set the lang attribute on the  tag? Why is this important?How do you set the lang attribute on the tag? Why is this important?May 08, 2025 am 12:03 AM

Setting the lang attributes of a tag is a key step in optimizing web accessibility and SEO. 1) Set the lang attribute in the tag, such as. 2) In multilingual content, set lang attributes for different language parts, such as. 3) Use language codes that comply with ISO639-1 standards, such as "en", "fr", "zh", etc. Correctly setting the lang attribute can improve the accessibility of web pages and search engine rankings.

What is the purpose of HTML attributes?What is the purpose of HTML attributes?May 07, 2025 am 12:01 AM

HTMLattributesareessentialforenhancingwebelements'functionalityandappearance.Theyaddinformationtodefinebehavior,appearance,andinteraction,makingwebsitesinteractive,responsive,andvisuallyappealing.Attributeslikesrc,href,class,type,anddisabledtransform

How do you create a list in HTML?How do you create a list in HTML?May 06, 2025 am 12:01 AM

TocreatealistinHTML,useforunorderedlistsandfororderedlists:1)Forunorderedlists,wrapitemsinanduseforeachitem,renderingasabulletedlist.2)Fororderedlists,useandfornumberedlists,customizablewiththetypeattributefordifferentnumberingstyles.

HTML in Action: Examples of Website StructureHTML in Action: Examples of Website StructureMay 05, 2025 am 12:03 AM

HTML is used to build websites with clear structure. 1) Use tags such as, and define the website structure. 2) Examples show the structure of blogs and e-commerce websites. 3) Avoid common mistakes such as incorrect label nesting. 4) Optimize performance by reducing HTTP requests and using semantic tags.

How do you insert an image into an HTML page?How do you insert an image into an HTML page?May 04, 2025 am 12:02 AM

ToinsertanimageintoanHTMLpage,usethetagwithsrcandaltattributes.1)UsealttextforaccessibilityandSEO.2)Implementsrcsetforresponsiveimages.3)Applylazyloadingwithloading="lazy"tooptimizeperformance.4)OptimizeimagesusingtoolslikeImageOptimtoreduc

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version