常用HTML代码

1.加图片:<img src="图片地址">

2.加网页连接:<a href="链接地址">链接对应的文字</a>

3.添加在新窗口打开连接效果:<a href="链接地址" target="_blank">链接对应的文字</a>,如果想消除链接文字下的下划线,可以在href后加:style="text-decoration:none" 

另外: target="_blank"将在新窗口打开链接;target="_parent"将在父窗口或框架中打开网页; target="_self"将在本页面打开链接;target="_top"将忽略框架,在顶端打开窗口。

4.走马灯:<marquee>走马灯</marquee>

5.加粗字体:<b>文字</b>

6.斜体:<i>文字</i>

7.加下划线: <u>文字</u>

8.加删除线: <s>文字</s>

9.加大字体: <big>文字</big>

10.控制字体大小:

<h1>文字</h1>最大

<h2>文字</h2>次大

<h3>文字</h3> 次次大

<h4>文字</h4>次次次大

<h5>文字</h5> 最小

11.定义字体颜色:<font color="#16进制编码">文字</font>

12.换行:<br/>

13.加段落:<p>段落</p>

14.定义背景图片:<body background="图片地址">,默认背景图片会随着滚动条滚动,如果不想让它滚(),可以加入:body bgproperties=fixed

15.定义文件类型:<html></html>,放在网页文件的开头及结尾

16. 贴图:<img src=“图片地址”>

17. 加入连接:<a href="所要连接的相关地址>写上你想写的字</a>

18. 在新窗口打开连接:<a href=“相关地址”target=“_blank”>写上你想写的字</a>

19. 消除连接的下划线在新窗口打开连接:<a href=“相关地址”style=“text—decoration:none”target="_blank*>写上你想写的字</a>

20. 移动字体(走马灯):<marquee>写上你想写的字</marquee>

21. 字体加粗:<b>写上你想写的字</b>

22. 字体斜体: <i>写上你想写的字</i>

23. 字体下划线: <u>写上你想写的字</u>

24. 字体删除线:<s>写上你想写的字</s>

25. 字体加大:<big>写上你想写的字</big>

26. 字体标题大小:<hl>写上你想写的字</hl> (h1—h5. h1最大. h5最小)

27. 更改字体颜色: <font color=“#value“>写上你想写的字</font> 其中value值在000000与ffffff(16位进制)之间

28. 修改文字的背景色 <font style=“background: red”>红色</font>

29. 文字渐变背景色 <font style="background: linear-gradient( to right, #ff1616, #ff7716,#ffdc16, #36c945, #10a5ce, #0f0096, #a51eff, #ff1616):">文字渐变七彩背景色</font>

30. 消除连接的下划线: <a href=“相关地址” style=“text—decoration:none”>写上你想写的字</a>

31. 贴音乐: <embed src=“音乐地址” width=300 height=45 type=audio/mpeg autostart—“false”>

32. 贴flash: <embed src="flash地址" width="宽度" height="高度">

33. 贴影视文件: <img dynsrc=“文件地址”width=“宽度” height=“高度” start=mouseover>

34. 换帖子背景: <body background=“背景图片地址”>

35. 固定帖子背景不随滚动条滚动: <body background=“背景图片地址” body bgproperties—fixed>

36. 定制帖子背景顏色: <body bgcolor=“#value”>其中value值在000000与ffffff(16位进制)之间

37. 帖子背景音乐:<bgsound=“背景音乐地址”loop=infinite>

38. 打开网站出现欢迎词:<body alert(“欢迎访问本站!”)>

39. 返回上一页: <a href=“#” onclick=“javascript:history.back(—1):”>返回上一页』</a>

40.关闭窗口: <a href=javascript :self.close()>「关闭窗口」</a>

41. 禁止复制网页代码: <body bgcolor=“#ffffff” oncontextmenu=“return false”onselectstart="return false">

42. IE地址栏前换成自己的图标 <link rel=“Shortcut Icon” href=“favicon.ico”>

43. 在收藏夹中显示出图标 <link rel="Bookmark" href="favicon.ico">

44. 关闭输入法<input style="ime-mode:disabled">

45. 网页将不能被另存为: <noscript><iframe src=*.html></iframe></noscript>

46. 删除时确认: <a href="javascript :if(confirm("确定删除? "))location="boos.asp? &areyou=删除&page=1"">删除</a>

47. 去掉(底部)左右滚动条: <body style="overflow:-Scroll;overflow-x:hidden">

48. 去掉(右侧)上下滚动条: <body style="overflow:-Scroll:overflow-y:hidden">

49. 两个都去掉: <body scroll="no"></body>

50. 去掉图片链接点击后. 图片周围的虚线 <a href=“#” onFocus=“this.blur()”><img src=“logo.jpg”border=0></a>

51. 设定打开页面的大小: <body onload="top.resizeTo(300.200):“>打开页面的位置<bodyonload="top.moveBy(300. 200):>

52. 使图片圆角: <style> img { border-radius: 50% limportant; border: 30px solid #eee: </style>

53. 网页标题左侧显示图标: <link rel=“icon” href=“图标地址”type=“image/x—icon”>

54. 收藏夹显示图标: <link rel="shortcut icon" href="图标地址" type="image/x-icon">

55, 网页适配手机: <meta name="viewport" content="width=device-width, initial-scale-1.0. maximum-scale=1.0. minimurn-scale=1.0, user-scalable=no">

56. 插入其它网页: <iframe id=“iframe” align=center src=“网页网址” frameBorder=0width="100%" height="100%" scrolling=no ></IFRAME>


底部链接代码(需插入footer)

<?php if($this->is('index')): ?>
<style>
.index-link{margin-top:5px;min-height: initial;border: 1px solid #9eabb3;    color: #9eabb3;padding: 5px;border-radius: 3px;}
.index-link a{color: #9eabb3;}
.index-link a:hover{border: 1px solid #9eabb3;border-radius: 3px;margin:0 5px;}
</style>
<div class="post index-link">友情链接:
<a href="https://www.链接.com/" title="标签" target="_blank">站点</a>
<a href="https://www.链接.com/" title="标签" target="_blank">站点</a>
<a href="https://www.链接.com/" title="标签" target="_blank">站点</a>
<a href="https://www.链接.com/" title="标签" target="_blank">站点</a>
</div>

<?php endif; ?>

通知消息代码

<script language="javascript">alert('通知:明天的明天会更好,努力啊啊!!!-老张儿')</script>

网站运行时间(需插入footer)

<span id="runtime_span"></span> <script
type="text/javascript">function
show_runtime(){window.setTimeout("show_runtime()",1000);X=new 
Date("10/16/2017 5:22:00"); Y=new
Date();T=(Y.getTime()-X.getTime());M=246060*1000;
a=T/M;A=Math.floor(a);b=(a-A)24;B=Math.floor(b);c=(b-B)60;C=Math.floor((b-B)60);D=Math.floor((c-C)60);
runtime_span.innerHTML=" 本站勉强运行:
"+A+" 天 "+B+" 小时 "+C+" 分 "+D+" 秒 "} show_runtime ();</script>

不允许右键复制代码(需插入footer)

<body onselectstart="return false;" oncontextmenu="alert('就是不让你按鼠标右键!');return false;" onkeydown="if(event.keyCode==27) return false;">
<script type="text/javascript">
document.onmousedown = click;  //绑定禁用鼠标右键事件
document.onkeydown = ctrl_key; //绑定禁用键盘事件
function click() {
if (event.button == 2)      //单击的鼠标键为右键
{
alert('就是不让你按鼠标右键!');
return false;
}
}
function ctrl_key() {
if (event.keyCode == 17) {                          //禁用CTRL+S 保存网页代码
window.alert("就是不让你按鼠标右键!");
return false;
}
 
if (event.keyCode == 123) {                         //禁用F12查看源代码
alert('就是不让你按鼠标右键!');
return false;
}
}
</script>

博客时间显示

<div class="card-content">
<canvas id="canvas" style="width:100%;" width="820" height="250"></canvas>
<script>
(function(){var t=820;var a=250;var r=7;var n=10;var e=.65;var f;var o=[];const v=["#33B5E5","#0099CC","#AA66CC","#9933CC","#99CC00","#669900","#FFBB33","#FF8800","#FF4444","#CC0000"];var h=[];var u=[[[0,0,1,1,1,0,0],[0,1,1,0,1,1,0],[1,1,0,0,0,1,1],[1,1,0,0,0,1,1],[1,1,0,0,0,1,1],[1,1,0,0,0,1,1],[1,1,0,0,0,1,1],[1,1,0,0,0,1,1],[0,1,1,0,1,1,0],[0,0,1,1,1,0,0]],[[0,0,0,1,1,0,0],[0,1,1,1,1,0,0],[0,0,0,1,1,0,0],[0,0,0,1,1,0,0],[0,0,0,1,1,0,0],[0,0,0,1,1,0,0],[0,0,0,1,1,0,0],[0,0,0,1,1,0,0],[0,0,0,1,1,0,0],[1,1,1,1,1,1,1]],[[0,1,1,1,1,1,0],[1,1,0,0,0,1,1],[0,0,0,0,0,1,1],[0,0,0,0,1,1,0],[0,0,0,1,1,0,0],[0,0,1,1,0,0,0],[0,1,1,0,0,0,0],[1,1,0,0,0,0,0],[1,1,0,0,0,1,1],[1,1,1,1,1,1,1]],[[1,1,1,1,1,1,1],[0,0,0,0,0,1,1],[0,0,0,0,1,1,0],[0,0,0,1,1,0,0],[0,0,1,1,1,0,0],[0,0,0,0,1,1,0],[0,0,0,0,0,1,1],[0,0,0,0,0,1,1],[1,1,0,0,0,1,1],[0,1,1,1,1,1,0]],[[0,0,0,0,1,1,0],[0,0,0,1,1,1,0],[0,0,1,1,1,1,0],[0,1,1,0,1,1,0],[1,1,0,0,1,1,0],[1,1,1,1,1,1,1],[0,0,0,0,1,1,0],[0,0,0,0,1,1,0],[0,0,0,0,1,1,0],[0,0,0,1,1,1,1]],[[1,1,1,1,1,1,1],[1,1,0,0,0,0,0],[1,1,0,0,0,0,0],[1,1,1,1,1,1,0],[0,0,0,0,0,1,1],[0,0,0,0,0,1,1],[0,0,0,0,0,1,1],[0,0,0,0,0,1,1],[1,1,0,0,0,1,1],[0,1,1,1,1,1,0]],[[0,0,0,0,1,1,0],[0,0,1,1,0,0,0],[0,1,1,0,0,0,0],[1,1,0,0,0,0,0],[1,1,0,1,1,1,0],[1,1,0,0,0,1,1],[1,1,0,0,0,1,1],[1,1,0,0,0,1,1],[1,1,0,0,0,1,1],[0,1,1,1,1,1,0]],[[1,1,1,1,1,1,1],[1,1,0,0,0,1,1],[0,0,0,0,1,1,0],[0,0,0,0,1,1,0],[0,0,0,1,1,0,0],[0,0,0,1,1,0,0],[0,0,1,1,0,0,0],[0,0,1,1,0,0,0],[0,0,1,1,0,0,0],[0,0,1,1,0,0,0]],[[0,1,1,1,1,1,0],[1,1,0,0,0,1,1],[1,1,0,0,0,1,1],[1,1,0,0,0,1,1],[0,1,1,1,1,1,0],[1,1,0,0,0,1,1],[1,1,0,0,0,1,1],[1,1,0,0,0,1,1],[1,1,0,0,0,1,1],[0,1,1,1,1,1,0]],[[0,1,1,1,1,1,0],[1,1,0,0,0,1,1],[1,1,0,0,0,1,1],[1,1,0,0,0,1,1],[0,1,1,1,0,1,1],[0,0,0,0,0,1,1],[0,0,0,0,0,1,1],[0,0,0,0,1,1,0],[0,0,0,1,1,0,0],[0,1,1,0,0,0,0]],[[0,0,0,0],[0,0,0,0],[0,1,1,0],[0,1,1,0],[0,0,0,0],[0,0,0,0],[0,1,1,0],[0,1,1,0],[0,0,0,0],[0,0,0,0]]];function l(t){var a=[];f.fillStyle="#005EAC";var r=new Date;var e=70,o=30;var v=r.getHours();var u=Math.floor(v/10);var l=v%10;a.push({num:u});a.push({num:l});a.push({num:10});var c=r.getMinutes();var u=Math.floor(c/10);var l=c%10;a.push({num:u});a.push({num:l});a.push({num:10});var M=r.getSeconds();var u=Math.floor(M/10);var l=M%10;a.push({num:u});a.push({num:l});for(var p=0;p<a.length;p++){a[p].offsetX=e;e=m(e,o,a[p].num,t);if(p<a.length-1){if(a[p].num!=10&&a[p+1].num!=10){e+=n}}}if(h.length==0){h=a}else{for(var C=0;C<h.length;C++){if(h[C].num!=a[C].num){s(a[C]);h[C].num=a[C].num}}}i(t);g();return r}function s(t){var a=t.num;var n=u[a];for(var e=0;e<n.length;e++){for(var f=0;f<n[e].length;f++){if(n[e][f]==1){var h={offsetX:t.offsetX+r+r*2*f,offsetY:30+r+r*2*e,color:v[Math.floor(Math.random()*v.length)],g:1.5+Math.random(),vx:Math.pow(-1,Math.ceil(Math.random()*10))*4+Math.random(),vy:-5};o.push(h)}}}}function i(t){for(var a=0;a<o.length;a++){t.beginPath();t.fillStyle=o[a].color;t.arc(o[a].offsetX,o[a].offsetY,r,0,2*Math.PI);t.fill()}}function g(){var n=0;for(var f=0;f<o.length;f++){var v=o[f];v.offsetX+=v.vx;v.offsetY+=v.vy;v.vy+=v.g;if(v.offsetY>a-r){v.offsetY=a-r;v.vy=-v.vy*e}if(v.offsetX>r&&v.offsetX<t-r){o[n]=o[f];n++}}for(;n<o.length;n++){o.pop()}}function m(t,a,n,e){var f=u[n];for(var o=0;o<f.length;o++){for(var v=0;v<f[o].length;v++){if(f[o][v]==1){e.beginPath();e.arc(t+r+r*2*v,a+r+r*2*o,r,0,2*Math.PI);e.fill()}}}e.beginPath();t+=f[0].length*r*2;return t}var c=document.getElementById("canvas");c.width=t;c.height=a;f=c.getContext("2d");var M=new Date;setInterval(function(){f.clearRect(0,0,f.canvas.width,f.canvas.height);l(f)},50)})();
</script>
</div>

春节倒计时代码

<div>
    <h1><font color="ff0000"></font><div class="text" style=" text-align:center;"><font color="ff0000"><img class="wp-smiley" src="https://cdn.qqsuu.cn/Gallery/denglong.gif" title="灯笼" alt="灯笼">春节倒计时<img class="wp-smiley" src="https://cdn.qqsuu.cn/Gallery/denglong.gif" title="灯笼" alt="灯笼"></font></div></h1>
    <h3 id="title-1"><div class="text" style=" text-align:center;">2019年春节时间:2019年2月05日 星期二 农历正月初一<img class="wp-smiley" src="https://cdn.qqsuu.cn/Gallery/meigui.png" title="玫瑰" alt="玫瑰"></div></h3>
    <h3 id="title-2"><div class="text" style=" text-align:center;"><img class="wp-smiley" src="https://cdn.qqsuu.cn/Gallery/taiyang.png" title="太阳" alt="太阳">距离2019年春节过年还有<img class="wp-smiley" src="https://cdn.qqsuu.cn/Gallery/89.png"></div></h3>
    <div><div class="text" style=" text-align:center;">
        <span id="t_d">00</span>
        <span id="t_h">00</span>
        <span id="t_m">00</span>
        <span id="t_s">00</span>
    </div>
<script type="text/javascript">
    function getRTime(){
        var EndTime= new Date('2024/02/05 00:00:00'); //截止时间
        var NowTime = new Date();
        var t =EndTime.getTime() - NowTime.getTime();
        var d=Math.floor(t/1000/60/60/24);
        var h=Math.floor(t/1000/60/60%24);
        var m=Math.floor(t/1000/60%60);
        var s=Math.floor(t/1000%60);

        document.getElementById("t_d").innerHTML = d + " 天";
        document.getElementById("t_h").innerHTML = h + " 时";
        document.getElementById("t_m").innerHTML = m + " 分";
        document.getElementById("t_s").innerHTML = s + " 秒";
    }
    setInterval(getRTime,1000);
    </script>
## 跳转网页.html代码
<html lang="en">
<head>
<meta charset="UTF-8">
<title>5秒后跳转到另一个页面</title>
</head>
<script>
var t = 5;
var s = '.';
timeID=setInterval("countDown()",1000);
function countDown(){
time.innerHTML= t +"秒后跳转"+s;
t--;
s+='.';
if (t==0) {
location.href="https://htoo.vip/";;        //跳转目标网址
clearInterval(timeID);
}
}
</script>
<body>
<div><font ID="time" face="impact" color="#272822" size="7">即将跳转</font>
</div>
</body>
</html>

给网站添加运行时间和节日倒计时代码(其中X=new Date("11/01/2017 00:00:00");改为你自己建站开始的日期即可。)

<span id="runtime_span"></span>
<script type="text/javascript">function show_runtime(){window.setTimeout("show_runtime()",1000);X=new Date("11/01/2017 00:00:00");
Y=new Date();T=(Y.getTime()-X.getTime());M=24*60*60*1000;
a=T/M;A=Math.floor(a);b=(a-A)*24;B=Math.floor(b);c=(b-B)*60;C=Math.floor((b-B)*60);D=Math.floor((c-C)*60);
runtime_span.innerHTML="本站勉强运行: "+A+"天"+B+"小时"+C+"分"+D+"秒"}show_runtime();</script>
上一篇 下一篇