当前位置:首页 » 编程语言 » 网站c语言导航条生成器官网
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

网站c语言导航条生成器官网

发布时间: 2023-01-28 22:35:40

⑴ 怎样用PHP来给网页做导航栏

本文只需要读者具备PHP、HTML的初步知识就可以基本读懂了。 译文:如大家所知PHP对于用数据库驱动的网站(making database-driven sites)来讲可谓功能强大,可是我们是否可以用它来做点其他事情呢?PHP给了我们所有我们期望的工具:for与while的循环结构、数学运算等等,还可以通过两种方式来引用文件:直接引用或向服务器提出申请。其实何止这些,让我们来看一个如何用它来做导航条的例子:完整的原代码:<!—— This "<?" is how you indicate the start of a block of PHP code, ——> <?PHP # and this "#" makes this a PHP comment. $full_path = getenv("REQUEST_URI"); $root = dirname($full_path);$page_file = basename($full_path);$page_num = substr($page_file, strrpos($page_file, "_") + 1, strpos($page_file, ".html") - (strrpos($page_file, "_") + 1)); $partial_path = substr($page_file, 0, strrpos($page_file, "_")); $prev_page_file = $partial_path . "_" . (string)($page_num-1) . ".html";$next_page_file = $partial_path . "_" . (string)($page_num+1) . ".html"; $prev_exists = file_exists($prev_page_file);$next_exists = file_exists($next_page_file); if ($prev_exists) { print "<a href="$root/$prev_page_file">previous</a>";if ($next_exists) { print " | ";} if ($next_exists) { print "<a href="$root/$next_page_file">next</a>";} ?>//原程序完。 代码分析:OK! 前面做了足够的铺垫工作,现在让我们来看看如何来用PHP来完成这项工作: <!—— This "<?" is how you indicate the start of a block of PHP code, ——> <?PHP # and this "#" makes this a PHP comment. $full_path = getenv("REQUEST_URI"); $root = dirname($full_path);$page_file = basename($full_path); /* PHP函数getenv()用来取得环境变量的值,REQUEST_URI的值是紧跟在主机名后的部分URL,假如URL是, 那它的值就为/dinner/tuna_1.html. 现在我们将得到的那部分URL放在变量$full_path中,再用dirname()函数来从URL中抓取文件目录,用basename()函数取得文件名,用上面的例子来讲dirname()返回值:/dinner/;basename()返回:tuna_1.html.接下来的部分相对有些技巧,假如我们的文件名以story_x的格式命名,其中x代表页码,我们需要从中将我们使用的页码抽出来。当然文件名不一定只有一位数字的模式或只有一个下划线,它可以是tuna_2.html,同样它还可以叫做tuna_234.html甚至是candy_apple_3.html,而我们真正想要的就是位于最后一个“_”和“。html”之间的东东。可采用如下方法:*/ $page_num = substr($page_file, strrpos($page_file, "_") + 1, strpos($page_file, ".html") - (strrpos($page_file, "_") + 1));/* substr($string, $start,[$length] )函数给了我们字符串$string中从$start开始、长为$length或到末尾的字串(方括号中的参数是可选项,如果省略$length,substr就会返回给我们从$start开始直到字符串末尾的字符串),正如每一个优秀的C程序员告诉你的那样,代表字符串开始的位置开始的数字是“0”而不是“1”。 函数strrpos($string, $what)告诉我们字符串$what在变量$string中最后一次出现的位置,我们可以通过它找出文件名中最后一个下划线的位置在哪,同理,接着的strpos($string, $what)告诉我们“。html”首次出现的位置。我们通过运用这三个函数取得在最后一个“_”和“。html”之间的数字(代码中的strpos()+1代表越过“_”自己)。 剩下的部分很简单,首先为上页和下页构造文件名:*/ $partial_path = substr($page_file, 0, strrpos($page_file, "_")); $prev_page_file = $partial_path . "_" . (string)($page_num-1) . ".html";$next_page_file = $partial_path . "_" . (string)($page_num+1) . ".html"; /*(string)($page_num+1)将数学运算$page_num+1的结果转化为字符串类型,这样就可以用来与其他字串最终连接成为我们需要的文件名。 */ /*现在检查文件是否存在(这段代码假设所有的文件都位于同样的目录下),并最终给出构成页面导航栏的HTML代码。>

⑵ 高手们!!!怎么制作网站 的下拉式导航条

用CSS巧制微软下拉式导航条
(作者:touch8 2002年02月20日 09:17)

去过微软中国站点(http://www.microsoft.com/china)的朋友都会对它的下拉菜单式导航条感兴趣,微软的制作方法比较复杂,不是一般菜鸟能学会的,于是就有很多人想出各种办法模拟制作,可是不是要用到很多层就是要用到脚本,感觉还是挺麻烦。我的做法可就简单多了,而且效果不错,看看本文抬头的导航条,再和微软站点的比较一下,怎么样?是不是几乎一模一样?你只要会点html和CSS的一些基本知识就能做到,具体的方法如下:

第一步:

为链接建立样式,代码如下:

a:visited{color:white}
a:link{color:white}
a:active{color:white}
a:hover{color:red }

说明:除了hover是红色外,其他都是白色,和微软一致。

第二步:

建立一个表格,以便放菜单内容,如建立一个3行1列的表格如下:

说明:表格参数均为0,即border="0" cellpadding="0" cellspacing="0" 这里为了解释方便所以留了边框。

第三步:

将菜单内容添入表格并加上链接,如下:

主页
微软中国
美国总部

第四步:

下面我们要建立样式了,首先建立一个名为close的样式,代码如下:

.close{visibility:hidden;background:#6699ff;height:23px;
color:white;font:9pt;text-align:center}

说明:使用hidden属性,说白了就是什么也看不到了!

再来建立一个样式名为open,代码如下:

.open{visibility:visible;background:#6699ff;height:23px;
color:white;font:9pt;text-align:center}

说明:背景采用天蓝色,字体为9pt,和微软保持一致,使用visible属性,即可见。

第五步:

既然样式已经建好了,我们就来调用,代码如下:

<table width="100" border="0" cellpadding="0" cellspacing="0"class=close>
<tr>
<td class=open><a href="#">主页</a></td>
</tr>
<tr>
<td><a href="#">微软中国</a></td>
</tr>
<tr>
<td><a href="#">美国总部</a></td>
</tr>
</table>

说明:整个表格采用close样式,而“主页”单元格采用open样式,充分利用CSS优先权的规则,所产生的效果是只能看到“主页”这个单元格。

第六步:

这是关键的一步,用行为调用样式,代码如下:

<table width="100" class=close onMouseOut="this.style.visibility='hidden'"
onMouseOver="this.style.visibility='visible '"
cellpadding="0" cellspacing="0" border="0" >
<tr>
<td class=open> <a href="#">主页</a></td>
</tr>
<tr>
<td><a href="#">微软中国</a></td>
</tr>
<tr>
<td><a href="#">美国总部</a></td>
</tr>
</table>

说明:当mouseover即鼠标移上时,表格变为可见,而当onmouseout即鼠标移开时,表格恢复不可见样式。

最后一步:

一个下拉菜单已经做好了,现在建立一个1x8的表格,再把下拉菜单插到各个单元格里面,最后把这个大的表格放到一个层里(这样容易定位),大功告成!

为了方便你学习,下面是本菜单式导航条的全部代码,你可以把代码拷贝到记事本里,保存为一个txt文件,然后将这个文件的扩展名由.txt改为.htm,就可以直接用IE打开了。

<html>
<head>
<title>用CSS做下拉式菜单</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
body{margin-top:50}
.td{font:9pt;color:green}
a:visited{color:white}
a:link{color:white}
a:active{color:white}
a:hover{color:red }
..close{visibility:hidden;background:#6699ff;
height:23px;color:white;font:9pt;text-align:center}
..open{visibility:visible;background:#6699ff;
height:23px;color:white;font:9pt;text-align:center}
</style>
</head>

<body bgcolor="#FFFFFF" text="#000000" >
<div id="Layer1" style="position:absolute;
left:4px; top:4px; width:1000px; height:108px;
z-index:1">
<table width="100%" border="0" align="center"
cellpadding="0" cellspacing="0">
<tr>
<td valign="top" width="12%">
<table width="100%" class=close onMouseOut="this.style.visibility='hidden' ;
a.style.height='23'" onMouseOver="this.style.
visibility='visible';
a.style.height='21'" cellpadding="0"
cellspacing="0" border="0" >
<tr>
<td id=a class=open > <a href="#">主页</a>
|</td>
</tr>
<tr >
<td bgcolor=white></td>
</tr>
<tr>
<td><a href="#">微软中国</a></td>
</tr>
<tr>
<td><a href="#">美国总部</a></td>
</tr>
<tr>
<td></td>
</tr>
</table>
</td>
<td valign="top" width="12%">
<table width="100%" class=close onMouseOut="this.style.visibility='hidden' ;
b.style.height='23'" onMouseOver="this.style.
visibility='visible';
b.style.height='21'" cellpadding="0"
cellspacing="0" border="0" >
<tr>
<td id=b class="open"><a href="#">活动与培训</a>|</td>
</tr>
<tr >
<td bgcolor=white></td>
</tr>
<tr>
<td><a href="#">在线讲座</a></td>
</tr>
<tr>
<td ><a href="#">任证与培训 </a></td>
</tr>
<tr>
<td ><a href="#">微软出版社</a></td>
</tr>
<tr>
<td ></td>
</tr>
</table>
</td>
<td valign="top" width="12%">
<table width="100%" class=close onMouseOut="this.style.visibility='hidden' ;
c.style.height='23'" onMouseOver="this.style.
visibility='visible';
c.style.height='21'" cellpadding="0"
cellspacing="0" border="0" >
<tr>
<td id=c class=open><a href="#">定阅电子期刊
</a>|</td>
</tr>
<tr >
<td bgcolor=white></td>
</tr>
<tr>
<td><a href="#">订阅</a></td>
</tr>
<tr>
<td><a href="#">修改</a></td>
</tr>
<tr>
<td></td>
</tr>
</table>
</td>
<td valign="top" width="12%">
<table width="100%" class=close onMouseOut="this.style.visibility='hidden' ;
d.style.height='23'" onMouseOver="this.style.
visibility='visible';
d.style.height='21'" cellpadding="0"
cellspacing="0" border="0" >
<tr>
<td id=d class=open><a href="#">微软中国</a>
|</td>
</tr>
<tr>
<td bgcolor=white></td>
</tr>
<tr>
<td><a href="#">新闻</a></td>
</tr>
<tr>
<td><a href="#">动态传真</a></td>
</tr>
<tr>
<td></td>
</tr>
</table>
</td>
<td valign="top" width="12%">
<table width="100%"class=open cellpadding="0"
cellspacing="0" border="0" >
<tr>
<td ><a href="#">微软总部
</a> |</td>
</tr>
</table>
</td>
<td valign="top" width="12%">
<table width="100%" class=close onMouseOut="this.style.visibility='hidden' ;
e.style.height='23'" onMouseOver="this.style.
visibility='visible';
e.style.height='21'" cellpadding="0"
cellspacing="0" border="0" >
<tr>
<td id=e class=open><a href="#">购买与许可
</a>|</td>
</tr>
<tr>
<td bgcolor=white></td>
</tr>
<tr>
<td><a href="#">版权与许可</a></td>
</tr>
<tr>
<td><a href="#">购买指南</a></td>
</tr>
<tr>
<td><a href="#">我用正版</a></td>
</tr>
<tr>
<td><a href="#">商标指南</a></td>
</tr>
<tr>
<td></td>
</tr>
</table>
</td>
<td valign="top" width="12%">
<table width="100%" class=close onMouseOut="this.style.visibility='hidden' ;
f.style.height='23'" onMouseOver="this.style.
visibility='visible';
f.style.height='21'" cellpadding="0"
cellspacing="0" border="0" >
<tr>
<td id=f class=open><a href="#">站点地图</a>|</td>
</tr>
<tr>
<td bgcolor=white></td>
</tr>
<tr>
<td><a href="#">站点内幕</a></td>
</tr>
<tr>
<td></td>
</tr>
</table>
</td>
<td valign="top" width="12%">
<table width="100%" class=open cellpadding="0"
cellspacing="0" border="0" >
<tr>
<td ><a href="#">招贤纳士 </a></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<div align="left"> </div>
</body>
</html>

⑶ 怎样制作网站首页导航条

非常简单的,背景色,打几个字,把链接一加就算是一个导航条了,复杂的多了去了