CSS 是什么?
CSS是Cascading Style Sheets的簡稱,中文稱為層疊樣式表。
屬性和屬性值用冒號隔開,以分號結(jié)尾。
CSS 四種引入方式:
1.行內(nèi)式
行內(nèi)式是在標(biāo)簽的style屬性中設(shè)定CSS樣式。
<div style="..."></div>
2.嵌入式
嵌入式是將CSS樣式集中寫在網(wǎng)頁的<head>標(biāo)簽的<style></style>標(biāo)簽對中。
<head>
...
<style type="text/css">
...此處寫CSS樣式
</style>
</head>
3.導(dǎo)入式
將一個獨立的.css文件引入HTML文件中,導(dǎo)入式使用@import 引入外部CSS文件,<style>標(biāo)記也是寫在<head>標(biāo)記中。
導(dǎo)入式會在整個網(wǎng)頁裝載完后再裝載CSS文件。
<head>
...
<style type="text/css">
@import "My.css"; 此處注意.css文件的路徑
</style>
</head>
4.鏈接式
將一個獨立的.css文件引入到HTML文件中,使用<link>標(biāo)記寫在<head>標(biāo)記中。
鏈接式會以網(wǎng)頁文件主體裝載前裝載CSS文件。
<head>
...
<link href="My.css" rel="stylesheet" type="text/css">
</head>
樣式應(yīng)用順序:
.nick {
color: yellow !important;
}
基本選擇器:
1.通用元素選擇器
* 表示應(yīng)用到所有的標(biāo)簽。
* {color: yellow}
2.標(biāo)簽選擇器
匹配所有使用 div 標(biāo)簽的元素(可以匹配所有標(biāo)簽)
div {color: yellow}
3.類選擇器
匹配所有class屬性中包含info的元素。
語法:.類名{樣式}(類名不能以數(shù)字開頭,類名要區(qū)分大小寫。)
.Mycolor {color: yellow}
<h3 class="Mycolor">nick</h3>
4.ID選擇器
使用id屬性來調(diào)用樣式,在一個網(wǎng)頁中id的值都是唯一的(是W3C規(guī)范而不是規(guī)則,所以不會報錯)。
語法:#ID名{樣式}(ID名不能以數(shù)字開頭)
#Mycolor {color: yellow}
<h3 id="Mycolor">Nick.</h3>
組合選擇器:
1.多元素選擇器
同時匹配h3,h4標(biāo)簽,之間用逗號分隔。
h3,h4 {color: yellow;}
<h3>Nick</h3>
<h4>Jenny</h4>
2.后代元素選擇器
匹配所有div標(biāo)簽里嵌套的P標(biāo)簽,之間用空格分隔。
div p {color: yellow;}
<div>
<p>Nick</p>
<div>
<p>Nick</p>
</div>
</div>
3.子元素選擇器
匹配所有div標(biāo)簽里嵌套的子P標(biāo)簽,之間用>分隔。
div > p {color: yellow;}
<div>
<p>Nick</p>
<p>Nick</p>
</div>
4.毗鄰元素選擇器
匹配所有緊隨div標(biāo)簽之后的同級標(biāo)簽P,之間用+分隔(只能匹配一個)。
div + p {color: yellow;}
<div>Nick</div>
<p>Nick</p>
屬性選擇器:
1.[title] & P[title]
設(shè)置所有具有title屬性的標(biāo)簽元素;
設(shè)置所有具有title屬性的P標(biāo)簽元素。
[title]
{
color: yellow;
}
p[title]
{
color: yellow;
}
<div title>Nick</div>
<p title>Nick</p>
2.[title=Nick]
設(shè)置所有title屬性等于“Nick”的標(biāo)簽元素。
[title="Nick"]
{
color: yellow;
}
<p title="Nick">Nick</p>
3.[title~=Nick]
設(shè)置所有title屬性具有多個空格分隔的值、其中一個值等于“Nick”的標(biāo)簽元素。
[title~="Nick"]
{
color: yellow;
}
<p title="Nick Jenny">Nick</p>
<p title="Jenny Nick">Nick</p>
4.[title|=Nick]
設(shè)置所有title屬性具有多個連字號分隔(hyphen-separated)的值、其中一個值以"Nick"開頭的標(biāo)簽元素。
例:lang屬性:"en"、"en-us"、"en-gb"等等
[title|="Nick"]
{
color: yellow;
}
<p title="Nick-Jenny">Nick</p>
5.[title^=Nick]
設(shè)置屬性值以指定值開頭的每個標(biāo)簽元素。
[title^="Nick"]
{
color: yellow;
}
<p title="NickJenny">Nick</p>
6.[title$=Nick]
設(shè)置屬性值以指定值結(jié)尾的每個標(biāo)簽元素。
[title$="Nick"]
{
color: yellow;
}
<p title="JennyNick">Nick</p>
7.[title*=Nick]
設(shè)置屬性值中包含指定值的每個元素
[title*="Nick"]
{
color: yellow;
}
<p title="SNickJenny">Nick</p>
偽類選擇器:
1. link、hover、active、visited
a:link{color: black}
a:hover{color: yellow}
a:active{color: blue}
a:visited{color: red}
<a href="#">Nick</a>
2. before、after
p {
color: yellow;
}
p:before{
content: "before...";
}
p:after{
content: "after...";
}
<p> Nick </p>
1. 顏色屬性:
color
transparent
opacity
2. 字體屬性:
font-style: 用于規(guī)定斜體文本
font-weight: 設(shè)置文本的粗細(xì)
font-size: 設(shè)置字體的大小
font-family:字體名稱
font:簡寫屬性
3. 文本屬性:
white-space: 設(shè)置元素中空白的處理方式
direction: 規(guī)定文本的方向
text-align: 文本的水平對齊方式
line-height: 文本行高
vertical-align: 文本所在行高的垂直對齊方式
text-indent: 文本縮進(jìn)
letter-spacing: 添加字母之間的空白
word-spacing: 添加每個單詞之間的空白
text-transform: 屬性控制文本的大小寫
text-overflow: 文本溢出樣式
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<!--<link href="cc2.css" rel="stylesheet" type="text/css">-->
<style>
div {
width: 100px;
height: 100px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
</head>
<body>
<div>索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧</div>
</body>
</html>
text-decoration: 文本的裝飾
text-shadow:文本陰影
word-wrap:自動換行
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
p {
width: 150px;
height: 160px;
background-color: #FFA500;
/*邊框陰影*/
box-shadow: 10px 10px 5px #888;
/*自動換行*/
word-wrap: break-word;
}
h1 {
text-shadow: 5px 5px 5px #888;
}
</style>
</head>
<body>
<p>
When you are old and grey and full of sleep,And nodding by the fire, take down this book,And slowly read, and dream of the soft look
</p>
<h1>索寧</h1>
</body>
</html>
a {
text-decoration: none;
/*去除a標(biāo)簽下劃線*/
}
4. 背景屬性
background-color: 背景顏色
background-image 設(shè)置圖像為背景
background-position 設(shè)置背景圖像的位置坐標(biāo)
background-repeat 設(shè)置背景圖像不重復(fù)平鋪
background-attachment 背景圖像是否固定或者隨著頁面的其余部分滾動
background 簡寫
5. 列表屬性
list-style-type: 列表項標(biāo)志的類型
list-style-image:將圖象設(shè)置為列表項標(biāo)志
list-style-position:列表項標(biāo)志的位置
list-style:縮寫
1. 邊框
border-style:邊框樣式
border-color:邊框顏色
border-width:邊框?qū)挾?/strong>
border-radius:圓角
border: 簡寫
box-shadow:邊框陰影
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
div {
border:2px solid;
border-radius:25px;
width: 140px;
}
</style>
</head>
<body>
<div>
點贊哦!dear.
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.radius1 {
display: inline-block;
width: 100px;
height: 100px;
background-color: yellow;
border-radius: 20px;
}
.radius2 {
display: inline-block;
width: 100px;
height: 100px;
background-color: red;
border-radius: 20px 35px;
}
.radius3 {
display: inline-block;
width: 100px;
height: 100px;
background-color: blue;
border-radius: 20px 35px 50px;
}
.radius4 {
display: inline-block;
width: 100px;
height: 100px;
background-color: green;
border-radius: 20px 35px 50px 60px;
}
</style>
</head>
<body>
<div>
<span class="radius1"></span>
<span class="radius2"></span>
<span class="radius3"></span>
<span class="radius4"></span>
</div>
</body>
</html>
邊框?qū)崿F(xiàn)各種三角符號:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.triangle-one {
display: inline-block;
border-top: 50px red solid;
border-right: 50px green solid;
border-bottom: 50px yellow solid;
border-left: 50px blue solid;
}
.triangle-two {
display: inline-block;
border-top: 0 red solid;
border-right: 50px green solid;
border-bottom: 50px yellow solid;
border-left: 50px blue solid;
}
.triangle-stree {
display: inline-block;
border-top: 50px red solid;
border-right: 0 green solid;
border-bottom: 50px yellow solid;
border-left: 50px blue solid;
}
.triangle-four {
display: inline-block;
border-top: 50px red solid;
border-right: 0 green solid;
border-bottom: 0 yellow solid;
border-left: 50px blue solid;
}
.triangle-five {
display: inline-block;
border: 50px transparent solid;
border-top: 50px red solid;
}
.triangle-six {
display: inline-block;
border: 50px transparent solid;
border-bottom: 50px yellow solid;
}
.triangle-seven {
display: inline-block;
border: 50px transparent solid;
border-top: 60px red solid;
border-right: 0;
}
.triangle-eight {
display: inline-block;
border: 50px transparent solid;
border-left: 30px yellow solid;
border-bottom: 0;
}
</style>
</head>
<body>
<div class="triangle-one"></div>
<div class="triangle-two"></div>
<div class="triangle-stree"></div>
<div class="triangle-four"></div>
<div class="triangle-five"></div>
<div class="triangle-six"></div>
<div class="triangle-seven"></div>
<div class="triangle-eight"></div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.back {
width: 1000px;
height: 1000px;
margin: 0 auto;
background-color: #ddd;
position: relative;
}
.back-in {
position: absolute;
width: 1020px;
height: 45px;
left: -20px;
top: 50px;
background-color: #2F4F4F;
}
.back-img {
border: 20px solid transparent;
border-top: 10px solid dimgrey;
border-right: 0;
display: inline-block;
position: absolute;
top: 95px;
left: -20px;
}
.back-font {
line-height: 9px;
margin-left: 30px;
color: white;
}
</style>
</head>
<body>
<div class="back">
<div class="back-in"><h3 class="back-font">妹子求關(guān)注 ^.^</h3></div>
<div class="back-img"></div>
</div>
</body>
</html>
2.★ 盒子模型
一個標(biāo)準(zhǔn)的盒子模型:
padding:用于控制內(nèi)容與邊框之間的距離;
margin: 用于控制元素與元素之間的距離;
一個參數(shù),應(yīng)用于四邊。
兩個參數(shù),第一個用于上、下,第二個用于左、右。
三個參數(shù),第一個用于上,第二個用于左、右,第三個用于下。
邊框在默認(rèn)情況下會定位于瀏覽器窗口的左上角,但是并沒有緊貼著瀏覽器的窗口的邊框,這是因為body本身也是一個盒子,外層還有html,
在默認(rèn)情況下,body距離html會有若干像素的margin,所以body中的盒子不會緊貼瀏覽器窗口的邊框了。
解決方法:
body {
margin: 0;
}
3.★ display
4. visibility
5.★ float 浮動
讓一行顯示兩個塊級標(biāo)簽,會脫離文檔流
clear 清除浮動:
6. clip 剪裁圖像
rect 剪裁定位元素:
7. overflow 設(shè)置當(dāng)對象的內(nèi)容超過其指定高度及寬度時如何顯示內(nèi)容
8.★ position 規(guī)定元素的定位類型
9. z-index 元素層疊順序
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.z-index1 {
width: 100px;
height: 100px;
background-color: yellow;
position: absolute;
z-index: -1;
}
.z-index2 {
width: 100px;
height: 100px;
background-color: red;
position: absolute;
top: 20px;
left: 20px;
z-index: 5;
}
</style>
</head>
<body>
<div class="z-index1"></div>
<div class="z-index2"></div>
</body>
</html>
10. outline 邊框輪廓
11. zoom 縮放比例
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.zoom1 {
zoom: 100%;
}
.zoom2 {
zoom: 150%;
}
.zoom3 {
zoom: 200%;
}
</style>
</head>
<body>
<div class="zoom1">Nick 100%</div>
<div class="zoom2">Nick 200%</div>
<div class="zoom3">Nick 300%</div>
</body>
</html>
12. cursor 鼠標(biāo)的類型形狀
鼠標(biāo)放在以下單詞上,There will be a miracle:
url: 自定義光標(biāo)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<!--<link href="cc2.css" rel="stylesheet" type="text/css">-->
<style>
body {
cursor: url("mouse.png"), auto;
/*圖片地址:http://images.cnblogs.com/cnblogs_com/suoning/845162/o_mouse.png*/
}
</style>
</head>
<body>
<div><img src="http://images.cnblogs.com/cnblogs_com/suoning/845162/o_ns.png" height="100%" width="100%"></div>
</body>
</html>
Auto: 默認(rèn)
Default: 默認(rèn)
e-resize
ne-resize
nw-resize
n-resize
se-resize
sw-resize
s-resize
w-resize
Crosshair
Pointer
Move
text
wait
help
not-allowed
13. transform、transition 動畫效果
transform 轉(zhuǎn)換,變形
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>nick</title>
<meta charset="utf-8" />
<style type="text/css">
div {
border: 1px solid black;
height: 30px;
width: 30px;
background-color: yellow;
/*transform-origin: 50px 50px;*/
transform-origin: left;
transform: rotate(50deg);
/*transform: skew(50deg,50deg);*/
/*transform: translate(50px,50px);*/
/*transform: scale(2);*/
}
</style>
</head>
<body>
<div></div>
</body>
</html>
Transition 平滑過渡
#property 指定屬性對應(yīng)類型
1、color: 通過紅、綠、藍(lán)和透明度組件變換(每個數(shù)值單獨處理),如:background-color,border-color,color,outline-color等CSS屬性;
2、length:真實的數(shù)字,如:word-spacing,width,vertical- align,top,right,bottom,left,padding,outline-width,margin,min-width,min- height,max-width,max-height,line-height,height,border-width,border- spacing,background-position等屬性;
3、percentage:真實的數(shù)字,如:word-spacing,width,vertical- align,top,right,bottom,left,min-width,min- height,max-width,max-height,line-height,height,background-position等屬性;
4、integer 離散步驟(整個數(shù)字),在真實的數(shù)字空間,以及使用floor()轉(zhuǎn)換為整數(shù)時發(fā)生,如:outline-offset,z-index等屬性;
5、number真實的(浮點型)數(shù)值,如:zoom,opacity,font-weight等屬性;
6、transform list。
7、rectangle:通過x、 y、 width和height(轉(zhuǎn)為數(shù)值)變換,如:crop;
8、visibility:離散步驟,在0到1數(shù)字范圍之內(nèi),0表示“隱藏”,1表示完全“顯示”,如:visibility;
9、shadow:作用于color、x、y、和blur(模糊)屬性,如:text-shadow;
10、gradient:通過每次停止時的位置和顏色進(jìn)行變化。它們必須有相同的類型(放射狀的或是線性的)和相同的停止數(shù)值以便執(zhí)行動畫,如:background-image;
11、paint server (SVG):只支持下面的情況:從gradient到gradient以及color到color,然后工作與上面類似;
12、space-separated list of above:如果列表有相同的項目數(shù)值,則列表每一項按照上面的規(guī)則進(jìn)行變化,否則無變化;
13、a shorthand property:如果縮寫的所有部分都可以實現(xiàn)動畫,則會像所有單個屬性變化一樣變化。
#支持執(zhí)行transition效果的屬性
Property Name Type
background-color as color
background-position as repeatable list of simple list of length, percentage, or calc
border-bottom-color as color
border-bottom-width as length
border-left-color as color
border-left-width as length
border-right-color as color
border-right-width as length
border-spacing as simple list of length
border-top-color as color
border-top-width as length
bottom as length, percentage, or calc
clip as rectangle
color as color
font-size as length
font-weight as font weight
height as length, percentage, or calc
left as length, percentage, or calc
letter-spacing as length
line-height as either number or length
margin-bottom as length
margin-left as length
margin-right as length
margin-top as length
max-height as length, percentage, or calc
max-width as length, percentage, or calc
min-height as length, percentage, or calc
min-width as length, percentage, or calc
opacity as number
outline-color as color
outline-width as length
padding-bottom as length
padding-left as length
padding-right as length
padding-top as length
right as length, percentage, or calc
text-indent as length, percentage, or calc
text-shadow as shadow list
top as length, percentage, or calc
vertical-align as length
visibility as visibility
width as length, percentage, or calc
word-spacing as length
z-index as integer
鼠標(biāo)放在以下圖片上,There will be a miracle:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>nick</title>
<meta charset="utf-8" />
<style type="text/css">
.img-see-2016-7-2 {
background-image: url("http://images.cnblogs.com/cnblogs_com/suoning/845162/o_sea.jpg");
background-size: 660px;
background-repeat: no-repeat;
height: 300px;
width: 600px;
transition-duration: 30s;
transition-timing-function: ease;
transition-property: background-size;
}
.img-see-2016-7-2:hover {
background-size: 2000px;
}
</style>
</head>
<body>
<div class="img-see-2016-7-2"></div>
</body>
</html>
作者:suoning
原文鏈接:https://www.cnblogs.com/suoning/p/5625582.html
)貼圖:<img src="圖片地址">
2)加入連接:<a href="所要連接的相關(guān)地址">寫上你想寫的字</a>
1)貼圖:<img src="圖片地址">
2)加入連接:<a href="所要連接的相關(guān)地址">寫上你想寫的字</a>
3)在新窗口打開連接:<a href="相關(guān)地址" target="_blank">寫上要寫的字</a>
消除連接的下劃線在新窗口打開連接:
<a href="相關(guān)地址" style="text-decoration:none" target="_blank">寫上你想寫的字</a>
4)移動字體(走馬燈):<marquee>寫上你想寫的字</marquee>
5)字體加粗:<b>寫上你想寫的字</b>
6)字體斜體:<i>寫上你想寫的字</i>
7)字體下劃線: <u>寫上你想寫的字</u>
8)字體刪除線: <s>寫上你想寫的字</s>
9)字體加大: <big>寫上你想寫的字</big>
10)字體控制大小:<h1>寫上你想寫的字</h1> (其中字體大小可從h1-h5,h1最大,h5最小)
11)更改字體顏色:<font color="#value">寫上你想寫的字</font>(其中value值在000000與ffffff(16位進(jìn)制)之間
12)消除連接的下劃線:<a href="相關(guān)地址" style="text-decoration:none">寫上你想寫的字</a>
13)貼音樂:<embed src=音樂地址 width=300 height=45 type=audio/mpeg autostart="false">
14)貼flash: <embed src="flash地址" width="寬度" height="高度">
15)貼影視文件:<img dynsrc="文件地址" width="寬度" height="高度" start=mouseover>
16)換行:<br>
17)段落:<p>段落</p>
18)原始文字樣式:<pre>正文</pre>
19)換帖子背景:<body background="背景圖片地址">
20)固定帖子背景不隨滾動條滾動:<body background="背景圖片地址" body
bgproperties=fixed>
21)定制帖子背景顏色:<body bgcolor="#value">(value值見10)
22)帖子背景音樂:<bgsound="背景音樂地址" loop=infinite>
23)貼網(wǎng)頁:<iframe src="相關(guān)地址" width="寬度" height="高度"></iframe>
/----------------------------------------HTML特效代碼--------------------------------/
1。忽視右鍵
<body oncontextmenu="return false">
或
<body style="overflow-y:hidden">
2。加入背景音樂
IE:<bgsound src="*.mid" loop=infinite>
NS:<embed src="*.mid" autostart=true hidden=true loop=true>
</embed>
*.mid你的背景音樂的midi格式文件
3。簡單的window.open方法
<a href="#"
onclick="javascript :window.open(文件路徑/文件名,newwindow,
toolbar=no,scrollbars=yes,resizable=no,top=0,left=0,
width=400,height=300);">文字或圖片</a>
參數(shù)解釋:
<SCRIPT LANGUAGE="javascript"> js腳本開始;
window.open 彈出新窗口的命令;
文件路徑/文件名 彈出窗口的文件名;
newwindow 彈出窗口的名字(不是文件名),非必須,可用空代替;
width=400 窗口寬度;
height=300 窗口高度;
top=0 窗口距離屏幕上方的象素值;
left=0 窗口距離屏幕左側(cè)的象素值;
toolbar=no 是否顯示工具欄,yes為顯示;
menubar,scrollbars 表示菜單欄和滾動欄。
resizable=no 是否允許改變窗口大小,yes為允許;
location=no 是否顯示地址欄,yes為允許;
status=no 是否顯示狀態(tài)欄內(nèi)的信息(通常是文件已經(jīng)打開),yes為允許;
</SCRIPT> js腳本結(jié)束
4。簡單的頁面加密
<script LANGUAGE="javascript">
<!--
function loopy(){
var sWord ="";
while(sWord!="login"){sWord=prompt("請輸入你的登陸密碼");}
alert("登陸成功!");
}
loopy()
//-->
</script>
5。拉動頁面時背景圖不動
<style>
body{background-image:url(logo.gif);
background-repeat:no-repeat;background-position:center}
</style>
6。讓瀏覽器在保存頁面時保存失敗
<NOSCRIPT><iframe src="*.html"></iframe></NOSCRIPT>
7。隨機(jī)替換圖片
<script>
document.write(<img src="img/+parseInt(Math.random()*(5))
+.gif"height="40" width="50">
</script>
圖片文件名為0.gif 1.gif 2.gif 3.gif 4.gif
8。窗口定時關(guān)閉
先將如下代碼網(wǎng)頁文件的區(qū):
<script language="javascript">
function closeit() { setTimeout("self.close()",10000) //毫秒 }
</script>
然后再在<body>標(biāo)內(nèi)加入如:<body onload="closeit()">
9。網(wǎng)頁自動關(guān)閉
<html>
<head>
<object id=closes type="application/x-oleobject"
classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<param name="Command" value="Close">
</object>
</head>
<body onload="window.setTimeout(closes.Click(),10000)">
這個窗口會在10秒過后自動關(guān)閉,而且不會出現(xiàn)提示.
</body>
</html>
10。網(wǎng)頁自動刷新
在head部記入
<META HTTP-EQUIV="Refresh" content="20">
其中20為20秒后自動刷新,你可以更改為任意值。
11。網(wǎng)頁自動轉(zhuǎn)頁
<META HTTP-EQUIV="Refresh" CONTENT="時間(秒);URL=地址">
12。保持layer在最前面,而不被Iframe、Object所覆蓋
在Layer中再插Iframe 或 Object 設(shè)z-Index值
<div z-Index:2><object xxx></object> # 前面
<div z-Index:1><object xxx></object> # 后面
<div id="Layer2" style="position:absolute; top:40;width:400px;
height:95px;z-index:2"> height=100% width=100%>
<iframe width=0 height=0></iframe>
</div>
<div id="Layer1" style="position:absolute; top:50;width:200px;
height:115px;z-index:1">
<iframe height=100% width=100%></iframe>
</div>
13。返回上一頁
<a href=javascript :history.back(1)>『返回上一頁』</a>
14。關(guān)閉窗口
<a href=javascript :self.close()>『關(guān)閉窗口』</a>
15。關(guān)于iframe的透明背景
<IFRAME ID="iFrame1" SRC="iframe.htm"
allowTransparency="true"
style="background-color: green"></IFRAME>
16. oncontextmenu="window.event.returnValue=false" 將徹底屏蔽鼠標(biāo)右鍵
<table border oncontextmenu=return(false)><td>no</table> 可用于Table
17. <body onselectstart="return false"> 取消選取、防止復(fù)制
18.onpaste="return false" 不準(zhǔn)粘貼
19.oncopy="return false;" oncut="return false;" 防止復(fù)制
20. <link rel="Shortcut Icon" href="favicon.ico"> IE地址欄前換成自己的圖標(biāo)
21. <link rel="Bookmark" href="favicon.ico"> 可以在收藏夾中顯示出你的圖標(biāo)
22. <input style="ime-mode:disabled"> 關(guān)閉輸入法
23. 永遠(yuǎn)都會帶著框架
<script language="JavaScript"><!--
if (window == top)top.location.href = "frames.htm"; //frames.htm為框架網(wǎng)頁
// --></script>
24. 防止被人frame
<SCRIPT LANGUAGE=JAVASCRIPT><!--
if (top.location != self.location)top.location=self.location;
// --></SCRIPT>
25. 網(wǎng)頁將不能被另存為
<noscript><iframe src=*.html></iframe></noscript>
26. 查看網(wǎng)頁源代碼
<input type=button value=查看網(wǎng)頁源代碼 onclick="window.location = "view-source:"+ "http://www.pconline.com.cn"">
27.刪除時確認(rèn)
<a href="javascript :if(confirm("確實要刪除嗎?"))location="boos.asp? &areyou=刪除&page=1"">刪除</a>
28.屏蔽功能鍵Shift,Alt,Ctrl
<script>
function look(){
if(event.shiftKey)
alert("禁止按Shift鍵!"); //可以換成ALT CTRL
}
document.onkeydown=look;
</script>
29. 網(wǎng)頁不會被緩存
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
或者<META HTTP-EQUIV="expires" CONTENT="0">
30.怎樣讓表單沒有凹凸感?
<input type=text style="border:1 solid #000000">
或 <input type=text style="border-left:none; border-right:none; border -top:none; border-bottom: 1 solid #000000"></textarea>
31.不要滾動條?
讓豎條沒有:
<body style="overflow:scroll;overflow-y:hidden">
</body>
讓橫條沒有:
<body style="overflow:scroll;overflow-x:hidden">
</body>
兩個都去掉?更簡單了
<body scroll="no">
</body>
32.怎樣去掉圖片鏈接點擊后,圖片周圍的虛線?
<a href="#" onFocus="this.blur()"><img src="logo.jpg" border=0></a>
33.電子郵件處理提交表單
<form name="form1" method="post" action="mailt****@***.com" enctype="text/plain">
<input type=submit>
</form>
34.在打開的子窗口刷新父窗口的代碼里如何寫?
window.opener.location.reload()
35.如何設(shè)定打開頁面的大小
<body onload="top.resizeTo(300,200);">
打開頁面的位置<body onload="top.moveBy(300,200);">
36.在頁面中如何加入不是滿鋪的背景圖片,拉動頁面時背景圖不動
<STYLE>
body
{background-image:url(logo.gif); background-repeat:no-repeat;
background-position:center;background-attachment: fixed}
</STYLE>
37. 檢查一段字符串是否全由數(shù)字組成
<script language="Javascript"><!--
function checkNum(str){return str.match(//D/)==null}
alert(checkNum("1232142141"))
alert(checkNum("123214214a1"))
// --></script>
38. 獲得一個窗口的大小
document.body.clientWidth; document.body.clientHeight
39. 怎么判斷是否是字符
if (/[^/x00-/xff]/g.test(s)) alert("含有漢字");
else alert("全是字符");
40.TEXTAREA自適應(yīng)文字行數(shù)的多少
<textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posHeight=this.scrollHeight">
</textarea>
41. 日期減去天數(shù)等于第二個日期
<script language=Javascript>
function cc(dd,dadd)
{
//可以加上錯誤處理
var a = new Date(dd)
a = a.valueOf()
a = a - dadd * 24 * 60 * 60 * 1000
a = new Date(a)
alert(a.getFullYear() + "年" + (a.getMonth() + 1) + "月" + a.getDate() + "日")
} cc("12/23/2002",2)
</script>
42. 選擇了哪一個Radio
<HTML><script language="vbscript">
function checkme()
for each ob in radio1
if ob.checked then window.alert ob.value
next
end function
</script><BODY>
<INPUT name="radio1" type="radio" value="style" checked>Style
<INPUT name="radio1" type="radio" value="barcode">Barcode
<INPUT type="button" value="check" onclick="checkme()">
</BODY></HTML>
43.腳本永不出錯
<SCRIPT LANGUAGE="JavaScript">
<!-- Hide function killErrors(){return true;} window.onerror = killErrors; // -->
</SCRIPT>
44.ENTER鍵可以讓光標(biāo)移到下一個輸入框
<input onkeydown="if(event.keyCode==13)event.keyCode=9">
45. 檢測某個網(wǎng)站的鏈接速度:
把如下代碼加入<body>區(qū)域中:
<script language=Javascript>
tim=1
setInterval("tim++",100)
b=1
var autourl=new Array()
autourl[1]="www.njcatv.net"
autourl[2]="javacool.3322.net"
autourl[3]="www.sina.com.cn"
autourl[4]="www.nuaa.edu.cn"
autourl[5]="www.cctv.com"
function butt(){
document.write("<form name=autof>")
for(var i=1;i<autourl.length;i++)
document.write("<input type=text name=txt"+i+" size=10 value=測試中
……> =》<input type=text
name=url"+i+" size=40> =》<input type=button value=GO
onclick=window.open(this.form.url"+i+".value)><br>")
document.write("<input type=submit value=刷新></form>")
}
butt()
function auto(url){
document.forms[0]["url"+b].value=url
if(tim>200)
{document.forms[0]["txt"+b].value="鏈接超時"}
else
{document.forms[0]["txt"+b].value="時間"+tim/10+"秒"} b++ }
function run(){for(var i=1;i<autourl.length;i++)document.write("<img src=http://"+autourl+"/"+Math.random()+" width=1 height=1 nerror=auto("http://"+autourl+"")>")}
run()</script>
46. 各種樣式的光標(biāo)
auto :標(biāo)準(zhǔn)光標(biāo)
default :標(biāo)準(zhǔn)箭頭
hand :手形光標(biāo)
wait :等待光標(biāo)
text :I形光標(biāo)
vertical-text :水平I形光標(biāo)
no-drop :不可拖動光標(biāo)
not-allowed :無效光標(biāo)
help :?幫助光標(biāo)
all-scroll :三角方向標(biāo)
move :移動標(biāo)
crosshair :十字標(biāo)
e-resize
n-resize
nw-resize
w-resize
s-resize
se-resize
sw-resize
47、禁止鼠標(biāo)右鍵,把Demo的圖片全都設(shè)為表格的背景,表格的大小與圖片的大小一樣。這樣做看起來是一樣的,主要是防止鼠標(biāo)經(jīng)過圖片時會出現(xiàn)另存的按鈕。禁止鼠標(biāo)右鍵的代碼很簡單:
<script LANGUAGE="JavaScript">
function click() { if (event.button==2)
{alert(呵呵,不好意思,你甭想使用右鍵下載圖片:)); } } document.onmousedown=click
</script>
48、在網(wǎng)頁的Head部分加入如下代碼,這段代碼的主要功能是屏蔽PrintScreen鍵,不斷清空剪貼版,防止圖片被用文件——另存為菜單另存。
<script language="javascript">
<!--
function testclip(){
try {
if(clipboardData.getData("Text")||clipboardData.getData("HTML")||clipboardData.getData("URL"))
{
null;
}
}
catch(e){
clipboardData.setData("Text","")
}
setTimeout("testclip()",500)
}
testclip();
//-->
</script>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1. 將徹底屏蔽鼠標(biāo)右鍵
<table border oncontextmenu=return(false)><td>no</table> 可用于Table
2. <body> 取消選取、防止復(fù)制
3. 不準(zhǔn)粘貼
4. 防止復(fù)制
5. <link rel="Shortcut Icon" href="favicon.ico"> IE地址欄前換成自己的圖標(biāo)
6. <link rel="Bookmark" href="favicon.ico"> 可以在收藏夾中顯示出你的圖標(biāo)
7. <input style="ime-mode:-Disabled"> 關(guān)閉輸入法
8. 永遠(yuǎn)都會帶著框架
<script language="javascript"><!--
if (window == top)top.location.href = "frames.htm"; //frames.htm為框架網(wǎng)頁
// --></script>
9. 防止被人frame
<SCRIPT LANGUAGE=javascript><!--
if (top.location != self.location)top.location=self.location;
// --></SCRIPT>
10. 網(wǎng)頁將不能被另存為
<noscript><iframe src=*.html></iframe></noscript>
11. <input type=button value=查看網(wǎng)頁源代碼
onclick="window.location = `view-source:`+ http://www.51js.com/`";>
12.刪除時確認(rèn)
<a href=`javascript:if(confirm("確實要刪除嗎?"location="boos.asp?&areyou=刪除&page=1"`>刪
除</a>
13. 取得控件的絕對位置
//javascript
<script language="javascript">
function getIE(E){
var t=e.offsetTop;
var l=e.offsetLeft;
while(e=e.offsetParent){
t+=e.offsetTop;
l+=e.offsetLeft;
}
alert("top="+t+"/nleft="+l);
}
</script>
//VBScript
<script language="VBScript"><!--
function getIE()
dim t,l,a,b
set a=document.all.img1
t=document.all.img1.offsetTop
l=document.all.img1.offsetLeft
while a.tagName<>"BODY"
set a = a.offsetParent
t=t+a.offsetTop
l=l+a.offsetLeft
wend
msgbox "top="&t&chr(13)&"left="&l,64,"得到控件的位置"
end function
--></script>
14. 光標(biāo)是停在文本框文字的最后
<script language="javascript">
function cc()
{
var e = event.srcElement;
var r =e.createTextRange();
r.moveStart(`character`,e.value.length);
r.collapse(true);
r.select();
}
</script>
<input type=text name=text1 value="123">
15. 判斷上一頁的來源
javascript:
document.referrer
16. 最小化、最大化、關(guān)閉窗口
<object id=hh1 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<param name="Command" value="Minimize"></object>
<object id=hh2 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<param name="Command" value="Maximize"></object>
<OBJECT id=hh3 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<PARAM NAME="Command" value="Close"></OBJECT>
<input type=button value=最小化 onclick=hh1.Click()>
<input type=button value=最大化 onclick=hh2.Click()>
<input type=button value=關(guān)閉 onclick=hh3.Click()>
本例適用于IE
17.屏蔽功能鍵Shift,Alt,Ctrl
<script>
function look(){
if(event.shiftKey)
alert("禁止按Shift鍵!"; //可以換成ALT CTRL
}
document.onkeydown=look;
</script>
18. 網(wǎng)頁不會被緩存
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
或者<META HTTP-EQUIV="expires" CONTENT="0">
19.怎樣讓表單沒有凹凸感?
<input type=text style="border:1 solid #000000">
或
<input type=text style="border-left:none; border-right:none; border-top:none; border-bottom:
1 solid #000000"></textarea>
20.<div><span>&<layer>的區(qū)別?
<div>(division)用來定義大段的頁面元素,會產(chǎn)生轉(zhuǎn)行
<span>用來定義同一行內(nèi)的元素,跟<div>的唯一區(qū)別是不產(chǎn)生轉(zhuǎn)行
<layer>是ns的標(biāo)記,ie不支持,相當(dāng)于<div>
21.讓彈出窗口總是在最上面:
<body>
22.不要滾動條?
讓豎條沒有:
<body style=`overflow:-Scroll;overflow-y:hidden`>
</body>
讓橫條沒有:
<body style=`overflow:-Scroll;overflow-x:hidden`>
</body>
兩個都去掉?更簡單了
<body scroll="no">
</body>
23.怎樣去掉圖片鏈接點擊后,圖片周圍的虛線?
<a href="#"><img src="logo.jpg" border=0></a>
24.電子郵件處理提交表單
<form name="form1" method="post" action="mailto:****@***.com" enctype="text/plain">
<input type=submit>
</form>
25.在打開的子窗口刷新父窗口的代碼里如何寫?
window.opener.location.reload()
26.如何設(shè)定打開頁面的大小
<body>
打開頁面的位置<body>
27.在頁面中如何加入不是滿鋪的背景圖片,拉動頁面時背景圖不動
<style>
body
{background-image:url(logo.gif); background-repeat:no-repeat;
background-position:center;background-attachment: fixed}
</style>
28. 檢查一段字符串是否全由數(shù)字組成
<script language="javascript"><!--
function checkNum(str){return str.match(//D/)==null}
alert(checkNum("1232142141"
alert(checkNum("123214214a1"
// --></script>
29. 獲得一個窗口的大小
document.body.clientWidth; document.body.clientHeight
30. 怎么判斷是否是字符
if (/[^/x00-/xff]/g.test(s)) alert("含有漢字";
else alert("全是字符";
31.TEXTAREA自適應(yīng)文字行數(shù)的多少
<textarea rows=1 name=s1 cols=27>
</textarea>
32. 日期減去天數(shù)等于第二個日期
<script language=javascript>
function cc(dd,dadd)
{
//可以加上錯誤處理
var a = new Date(dd)
a = a.valueOf()
a = a - dadd * 24 * 60 * 60 * 1000
a = new Date(A)
alert(a.getFullYear() + "年" + (a.getMonth() + 1) + "月" + a.getDate() + "日"
}
cc("12/23/2002",2)
</script>
33. 選擇了哪一個Radio
<HTML><script language="vbscript">
function checkme()
for each ob in radio1
if ob.checked then window.alert ob.value
next
end function
</script><BODY>
<INPUT name="radio1" type="radio" value="style" checked>style
<INPUT name="radio1" type="radio" value="barcode">Barcode
<INPUT type="button" value="check">
</BODY></HTML>
34.腳本永不出錯
<SCRIPT LANGUAGE="javascript">
<!-- Hide
function killErrors() {
return true;
}
window.onerror = killErrors;
// -->
</SCRIPT>
35.ENTER鍵可以讓光標(biāo)移到下一個輸入框
<input>
36. 檢測某個網(wǎng)站的鏈接速度:
把如下代碼加入<body>區(qū)域中:
<script language=javascript>
tim=1
setInterval("tim++",100)
b=1
var autourl=new Array()
autourl[1]="http://www.njcatv.net/";
autourl[2]="javacool.3322.net"
autourl[3]="http://www.sina.com.cn/";
autourl[4]="http://www.nuaa.edu.cn/";
autourl[5]="http://www.cctv.com/";
function butt(){
document.write("<form name=autof>"
for(var i=1;i<autourl.length;i++)
document.write("<input type=text name=txt"+i+" size=10 value=測試中……> =》<input type=text
name=url"+i+" size=40> =》<input type=button value=GO
onclick=window.open(this.form.url"+i+".value)><br>"
document.write("<input type=submit value=刷新></form>"
}
butt()
function auto(url){
document.forms[0]["url"+b].value=url
if(tim>200)
{document.forms[0]["txt"+b].value="鏈接超時"}
else
{document.forms[0]["txt"+b].value="時間"+tim/10+"秒"}
b++
}
function run(){for(var i=1;i<autourl.length;i++)document.write("<img
src=http://"+autourl+"/"+Math.random()+" width=1 height=1
onerror=auto(http://";+autourl+"`)>"}
run()</script>
37. 各種樣式的光標(biāo)
auto :標(biāo)準(zhǔn)光標(biāo)
default :標(biāo)準(zhǔn)箭頭
hand :手形光標(biāo)
wait :等待光標(biāo)
text :I形光標(biāo)
vertical-text :水平I形光標(biāo)
no-drop :不可拖動光標(biāo)
not-allowed :無效光標(biāo)
help :?幫助光標(biāo)
all-scroll :三角方向標(biāo)
move :移動標(biāo)
crosshair :十字標(biāo)
e-resize
n-resize
nw-resize
w-resize
s-resize
se-resize
sw-resize
38.頁面進(jìn)入和退出的特效
進(jìn)入頁面<meta http-equiv="Page-Enter" content="revealTrans(duration=x, transition=y)">
推出頁面<meta http-equiv="Page-Exit" content="revealTrans(duration=x, transition=y)">
這個是頁面被載入和調(diào)出時的一些特效。Duration表示特效的持續(xù)時間,以秒為單位。Transition表示使
用哪種特效,取值為1-23:
0 矩形縮小
1 矩形擴(kuò)大
2 圓形縮小
3 圓形擴(kuò)大
4 下到上刷新
5 上到下刷新
6 左到右刷新
7 右到左刷新
8 豎百葉窗
9 橫百葉窗
10 錯位橫百葉窗
11 錯位豎百葉窗
12 點擴(kuò)散
13 左右到中間刷新
14 中間到左右刷新
15 中間到上下
16 上下到中間
17 右下到左上
18 右上到左下
19 左上到右下
20 左下到右上
21 橫條
22 豎條
23 以上22種隨機(jī)選擇一種
39.在規(guī)定時間內(nèi)跳轉(zhuǎn)
<META http-equiv=V="REFRESH" content="5;URL=http://www.51js.com">
40.網(wǎng)頁是否被檢索
<meta name="ROBOTS" content="屬性值">
其中屬性值有以下一些:
屬性值為"all": 文件將被檢索,且頁上鏈接可被查詢;
屬性值為"none": 文件不被檢索,而且不查詢頁上的鏈接;
屬性值為"index": 文件將被檢索;
屬性值為"follow": 查詢頁上的鏈接;
屬性值為"noindex": 文件不檢索,但可被查詢鏈接;
屬性值為"nofollow": 文件不被檢索,但可查詢頁上的鏈接。
41.變換網(wǎng)頁的鼠標(biāo)光標(biāo)
<BODY style="CURSOR: url(http://203.73.125.205/~liangmi2/farmfrog01.cur`)">
42.怎樣實現(xiàn)在任務(wù)欄顯示小圖標(biāo)的效果? (要使用絕對地址)
有些站點,訪問時會在地址欄地址前顯出小圖標(biāo),添加到收藏夾后也在收藏欄中顯示圖標(biāo),
這樣很好的與其它站點有了區(qū)別。
要達(dá)到這個效果,先需做出這個圖標(biāo)文件,圖像為16*16像素,不要超過16色。文件格式為ico,然后上傳至你的網(wǎng)站。
然后,在需要的頁面中,加上以下html語句到文件的<head>和</head>之間(假設(shè)以上ico文件的地址http://happyisland.126.com/icon.ico)。
<link REL="SHORTCUT ICON"href="http:///happyisland.126.com/icon.ico";>
如果訪問者的瀏覽器是IE5.0,就不需加任何代碼,只要將圖標(biāo)文件上傳到網(wǎng)站的根目錄下即可。
1,META標(biāo)簽里的代碼是什么意思?
<META>是放于<HEAD>與</HEAD>之間的標(biāo)記.以下是我總結(jié)它在網(wǎng)頁中最常見的幾種。
<meta name="Keywords" content="圖片, 新聞, 音樂, 軟件">
該網(wǎng)頁的關(guān)鍵字,作用于搜索引擎的登錄,事實上它在現(xiàn)在的網(wǎng)站中并沒什么用。
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
設(shè)定這是 HTML 文件及其編碼語系,簡體中文網(wǎng)頁使用charset=gb2312,繁體中文使用charset=big5,或者不設(shè)編碼也可,純英文網(wǎng)頁建議使用 iso-8859-1。
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
這只表示該網(wǎng)頁由什么編輯器寫的。
<meta http-equiv="refresh" content="10; url=http://www.hkiwc.com">
這行較為實用,能于預(yù)定秒數(shù)內(nèi)自動轉(zhuǎn)到指定網(wǎng)址。原代碼中 10 表示 10秒。
2,怎么改變滾動條的顏色,只有ie5.5版本以上才能支持。
這是使用CSS語言,在次說明一下,它和我的瀏覽器版本有一定的關(guān)系。
scrollbar-arrow-color:上下按鈕上三角箭頭的顏色。
scrollbar-base-color:滾動條的基本顏色。
scrollbar-dark-shadow-color:立體滾動條強(qiáng)陰影的顏色
scrollbar-face-color:立體滾動條凸出部分的顏色
scrollbar-highlight-color:滾動條空白部分的顏色
scrollbar-shadow-color立體滾動條陰影的顏色。
scrollbar-track-color:#99CC33;
scrollbar-3dlight-color:#A8CBF1;
代碼如下:
<style>
<!--
BODY {
scrollbar-face-color:#99CC33;//(立體滾動條凸出部分的顏色)
scrollbar-highlight-color:#A8CBF1;//(滾動條空白部分的顏色)
scrollbar-shadow-color:#A8CBF1;//(立體滾動條陰影的顏色)
scrollbar-arrow-color:#FF9966;//(上下按鈕上三角箭頭的顏色)
scrollbar-base-color:#A8CBF1; //(滾動條的基本顏色)
scrollbar-darkshadow-color:#A8CBF1; //(立體滾動條強(qiáng)陰影的顏色)
scrollbar-track-color:#99CC33;
scrollbar-3dlight-color:#A8CBF1;
}
-->
</style>
//以下是其它的網(wǎng)頁的代碼
在這我補(bǔ)充幾點:
1.讓瀏覽器窗口永遠(yuǎn)都不出現(xiàn)滾動條。
<body style="overflow-x:hidden;overflow-y:hidden">或<body style="overflow:hidden"> 或<body scroll=no>
2,沒有水平滾動條
<body style="overflow-x:hidden">
3,沒有垂直滾動條
<body style="overflow-y:hidden">
3,如何給圖片抖動怎做的.
<SCRIPT language=javascript1.2>
<!--
var rector=2
var stopit=0
var a=1
var count=0
function init(which){
stopit=0
shake=which
shake.style.left=0
shake.style.top=0
}
function rattleimage(){
if ((!document.all&&!document.getElementById)||stopit==1||count==100)
return
count++
if (a==1){
shake.style.top=parseInt(shake.style.top)+rector
}
else if (a==2){
shake.style.left=parseInt(shake.style.left)+rector
}
else if (a==3){
shake.style.top=parseInt(shake.style.top)-rector
}
else{
shake.style.left=parseInt(shake.style.left)-rector
}
if (a<4)
a++
else
a=1
setTimeout("rattleimage()",50)
}
function stoprattle(which){
stopit=1
count=0
which.style.left=0
which.style.top=0
}
//-->
</SCRIPT>
<style>.shakeimage {POSITION: relative}
</style>
<img src="圖片的路徑" onmouseout=stoprattle(this) onmouseover=init(this);rattleimage() class=shakeimage>
4,在DW如何給水平線加顏色。
在DW中沒有此項設(shè)置,你只能在HTML中加入代碼:<hr color=red noshade>按F12的預(yù)覽在能看到。由于在NC中不支持<hr>的COLOR屬性,所以在DW中沒有此項設(shè)置。
5,如何在網(wǎng)頁中實現(xiàn)flash的全屏播放?
只要在調(diào)用swf文件的HTML中將WIDTH和HEIGHT的參數(shù)設(shè)為100%即可,當(dāng)然也可以在Flash導(dǎo)出HTML文件的設(shè)置中進(jìn)行設(shè)置,方法是:打開File菜單;選Publish Settings彈出導(dǎo)出設(shè)置對話框;在HTML標(biāo)簽下的Dimensions選項,下拉后選中Percent(百分比),并在WIDTH 和HEIGHT框中填100.就行了。
6,為什么我在DW中插入的Flash動畫缺看不找!
如果你沒有正確地安裝Dreamweaver和Flash,那么在你預(yù)覽的時候,Dreamweaver會提示你缺少播放的插件,請你按裝InstallAXFlash.exe 并從新啟動計算機(jī)。現(xiàn)在IE6已經(jīng)捆綁這個程序。
7,在Flash中,如果屏蔽鼠標(biāo)右鍵?FS命令都是什么意思?
fscommand ("fullscreen", "true/false";(全屏設(shè)置,TRUE開,F(xiàn)ALSE關(guān))
fscommand ("showmenu", "true/false";(右鍵菜單設(shè)置,TRUE顯示,F(xiàn)ALSE不顯示)
fscommand ("allowscale", "true/false";(縮放設(shè)置,TRUE自由縮放,F(xiàn)ALSE調(diào)整畫面不影響影片本身的尺寸)
fscommand ("trapallkeys", "true/false";(快捷鍵設(shè)置,TRUE快捷鍵開,F(xiàn)ALSE快捷鍵關(guān))
fscommand ("exec";(EXE程序調(diào)用)
fscommand ("quit";(退出關(guān)閉窗口)
8,F(xiàn)lash中什么是隱形按鈕。
利用button中的hit幀來制作只有感應(yīng)區(qū)域而完全透明的按鈕。
9,如何給Flash動畫做鏈接。
Dreamweaver是不能給Flash制作鏈接的,只能在Flash中用geturl()加鏈接,然后再插入Dreamweaver中。
10,DW中的層的技巧。
層是可以嵌套的,我個人給大家一個技巧,在層面板中按住CTRL再拖放層到你想去成為其子層的地方就行了,我認(rèn)為這是最簡單直觀的方法了。
11,如何改變鼠標(biāo)的形狀?
在Dreamweaver4中CSS樣式面板:
按CTR+SHIFT+E--出現(xiàn)樣式表對話框,點擊NEW,出現(xiàn)編輯對話框,在左邊最后一項extensions-cursor 選擇你要改的指針形式就可以了,然后把你要想改變的地方運用樣式表,如果整頁都有在<body bgcolor="#003063" text="#ffffff" id=all>中加入就行了。
<span style="cursor:X`>樣例</span>
這里選擇(文本)作為對象,還可以自己改為其他的,如link等。
x可以等于=hand(手形)、crosshair(十字)、text(文本光標(biāo))、wait(顧名思義啦)、default(默認(rèn)效果)、help(問號)、e-size(向右箭頭)、ne-resize(向右上的箭頭)、nw-resize(向左上的箭頭)、w-resize(向左的箭頭)、sw-resize(左下箭頭)、s-resize(向下箭頭)、se-resize(向右下箭頭)、auto(系統(tǒng)自動給出效果)。
12,用CSS做郵票,看看吧!
<input type=button value=我象不象郵票? style="height:80px;border:2px dashed #cccccc">
13,經(jīng)常上網(wǎng)的朋友可能會到過這樣一些網(wǎng)站,一進(jìn)入首頁立刻會彈出一個窗口,怎么做呢!
這javascript代碼即可實現(xiàn),摘錄藍(lán)色論壇。
【1、最基本的彈出窗口代碼】
其實代碼非常簡單:
<SCRIPT LANGUAGE="javascript">
<!--
window.open (`page.html`)
-->
</SCRIPT>
因為著是一段javascripts代碼,所以它們應(yīng)該放在<SCRIPT LANGUAGE="javascript">標(biāo)簽和</script>之間。<!-- 和 -->是對一些版本低的瀏覽器起作用,在這些老瀏覽器中不會將標(biāo)簽中的代碼作為文本顯示出來。要養(yǎng)成這個好習(xí)慣啊。
window.open (`page.html`) 用于控制彈出新的窗口page.html,如果page.html不與主窗口在同一路徑下,前面應(yīng)寫明路徑,絕對路徑(http://)和相對路徑(../)均可。用單引號和雙引號都可以,只是不要混用。
這一段代碼可以加入HTML的任意位置,<head>和</head>之間可以,<body bgcolor="#003063" text="#ffffff" id=all>間</body>也可以,越前越早執(zhí)行,尤其是頁面代碼長,又想使頁面早點彈出就盡量往前放。
【2、經(jīng)過設(shè)置后的彈出窗口】
下面再說一說彈出窗口的設(shè)置。只要再往上面的代碼中加一點東西就可以了。
我們來定制這個彈出的窗口的外觀,尺寸大小,彈出的位置以適應(yīng)該頁面的具體情況。
<SCRIPT LANGUAGE="javascript">
<!--
window.open (`page.html`, `newwindow`, `height=100, width=400, top=0,left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no`)
//寫成一行
-->
</SCRIPT>
參數(shù)解釋:
<SCRIPT LANGUAGE="javascript"> js腳本開始;
window.open 彈出新窗口的命令;
`page.html` 彈出窗口的文件名;
`newwindow` 彈出窗口的名字(不是文件名),非必須,可用空``代替;
height=100 窗口高度;
width=400 窗口寬度;
top=0 窗口距離屏幕上方的象素值;
left=0 窗口距離屏幕左側(cè)的象素值;
toolbar=no 是否顯示工具欄,yes為顯示;
menubar,scrollbars 表示菜單欄和滾動欄。
resizable=no 是否允許改變窗口大小,yes為允許;
location=no 是否顯示地址欄,yes為允許;
status=no 是否顯示狀態(tài)欄內(nèi)的信息(通常是文件已經(jīng)打開),yes為允許;
</SCRIPT> js腳本結(jié)束
【3、用函數(shù)控制彈出窗口】
下面是一個完整的代碼。
<html>
<head>
<script LANGUAGE="javascript">
<!--
function openwin() { window.open ("page.html", "newwindow", "height=100, width=400, toolbar=
no, menubar=no, scrollbars=no, resizable=no, location=no, status=no"
//寫成一行
}
//-->
</script>
</head>
<body>
…任意的頁面內(nèi)容…
</body>
</html>
這里定義了一個函數(shù)openwin(),函數(shù)內(nèi)容就是打開一個窗口。在調(diào)用它之前沒有任何用途。
怎么調(diào)用呢?
方法一:<body> 瀏覽器讀頁面時彈出窗口;
方法二:<body> 瀏覽器離開頁面時彈出窗口;
方法三:用一個連接調(diào)用:
<a href="#">打開一個窗口</a>
注意:使用的“#”是虛連接。
方法四:用一個按鈕調(diào)用:
<input type="button" value="打開窗口">
14,沒有用表格寫的,讓大家隨便看看,沒什么。
<html>
<head>
<title>江南荷花扇面</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
.font1 { font-size: 12px; color: #999999; text-decoration: none}
a { font-size: 12px; color: #999999; text-decoration: none}
a:hover { font-size: 12px; color: #000000; text-decoration: none}
-->
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="font1" style="writing-mode=tb-rl;height:200px" width=300>
<p>盛夏 尚 濤
<p><a href="index.htm">一夜露痕黃粉香 袁運甫 </a>
<p>瑤池昨夜新涼 王金嶺
<p>一朵白蓮隨意開 吳冠南
<p>新雨迎秋欲滿塘 齊辛民
<p>十里荷香 齊辛民
<p>濯清蓮而不妖 盧世曙
</div>
</body>
</html>
15,IE6已支持自定義cursor!
語法格式 cursor:url(圖標(biāo)) //cur或是ani文件.
cur就是WINDOWS中的光標(biāo)(cursor)文件,光標(biāo)文件與圖標(biāo)(ICON)文件除了文件頭有一個位置的值不同外,實際是一樣的。
ani是WINDOWS中的動畫光標(biāo)(圖標(biāo))文件。
<style type="text/css">
<!--
.unnamed1 { cursor:url(arrow2c.cur)}
-->
</style>
16,用marquee做的滾動字幕.這也我剛看到論壇的朋友在問。
語法:
align=# | top | middle| bottom //對齊方式)
BEHAVIOR=ALTERNATE | SCROLL | SLIDE //移動的方式
BGCOLOR=color//底色區(qū)域顏色
DIRECTION=DOWN | LEFT | RIGHT | UP //移動的方向
Loop=n //循環(huán)次數(shù)(默認(rèn)是循環(huán)不止)
Scrolldelay=milliseconds//延時
height=# width=# //區(qū)域面積
hspace=# vspace=# //空白區(qū)域
scrollamount=# //移動的速度
<marquee align=top behavior=ALTERNATE BGCOLOR=#000000 height=60 width=433 scrollamount=5></marquee>
17,在FLASH5中也存在一些字體,打散后變成一團(tuán)的事是為什么?有解決的辦法嗎。
這是大家很常見的問題!可能是對字庫支持的不好!我個是做成透明的gif圖片格式,然后倒入。
18,flash的網(wǎng)頁里“加入收藏夾”功能怎么實現(xiàn)?
在as中加getUrl("java script:window.external.addFavorite(http://skydesigner.51.net`,`我的工作室`)"
19,在Flash中,文本的動態(tài)屬性和輸入屬性的區(qū)別。
input text在運行時可被用戶或程序改變其值。
ynamic text僅允許被程序修改。
20,怎樣在IE中調(diào)用Dreamweaver進(jìn)行編輯.
相信很多在使用WinME或Window2000的朋友,會遇見是個問題。很簡單,把我們筆記本程序打開,保存為一個 *.reg 文件。雙擊它將信息添加到注冊表即可。
REGEDIT4
[HKEY_CLASSES_ROOT\.htm\OpenWithList\Dreamweaver]
[HKEY_CLASSES_ROOT\.htm\OpenWithList\Dreamweaver\shell]
[HKEY_CLASSES_ROOT\.htm\OpenWithList\Dreamweaver\shell\edit]
[HKEY_CLASSES_ROOT\.htm\OpenWithList\Dreamweaver\shell\edit\command]
@="\"c:\Program Files\Macromedia\Dreamweaver 4\dreamweaver.exe\" \"%1\""
21,設(shè)置表格虛線。
方法一:作一個1X2的圖。半黑半白,再利用表格作成線。
方法二:在css里面設(shè),要IE5。5才支持這種效果。
style="BORDER-LEFT: #000000 1PX DASHED; BORDER-RIGHT: #000000 1PX DASHED; BORDER-TOP: #000000 1PX DASHED; BORDER-BOTTOM: #000000 1PX DASHED"
22,看看在網(wǎng)頁中調(diào)用HHCtrl控件效果。
代碼如下:
<object id="HHC" type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"></object><script>HHC.TextPopup("哈哈,大家好,我是閃夢!","",50,5,128255,346751);</script>
22,如何讓一張圖片有淺到深的漸變。
<SCRIPT language=javascript1.2>
<!--
function high(which2){
theobject=which2
highlighting=setInterval("highlightit(theobject)",50)
}
function low(which2){
clearInterval(highlighting)
which2.filters.alpha.opacity=40
}
function highlightit(cur2){
if (cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=10
else if (window.highlighting)
clearInterval(highlighting)
}
</script>
<img onmouseout=low(this) onmouseover=high(this) style="FILTER: alpha(opacity=40)"src="logo.gif" >
23,雙擊鼠標(biāo)左鍵來滾動背景,單擊停止。
<SCRIPT language=javascript>
var currentpos,timer;
function initialize()
{
timer=setInterval("scrollwindow()",16);
}
function sc(){
clearInterval(timer);
}
function scrollwindow()
{
currentpos=document.body.scrollTop;
window.scroll(0,++currentpos);
if (currentpos != document.body.scrollTop)
sc();
}
document.onmousedown=sc
document.ondblclick=initialize
</SCRIPT>
24,如何在同一頁面設(shè)置不同文字鏈接效果的樣式.
代碼如下:
<HTML><HEAD><TITLE>如何在同一頁面設(shè)置不同文字鏈接效果的樣式</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
a:hover { font-size: 9pt; color: #FF0000; text-decoration: underline}
a:link { font-size: 9pt; color: #006699; text-decoration: underline}
a:visited { font-size: 9pt; color: #006699; text-decoration: underline}
a:active { font-size: 9pt; color: #FF0000; text-decoration: none}
a.r1:hover { font-size: 9pt; color: #FF0000; text-decoration: underline overline}
a.r1:link { font-size: 9pt; color: #000000; text-decoration: underline overline}
a.r1:visited { font-size: 9pt; color: #99CC00; text-decoration: underline overline}
a.r1:active { font-size: 9pt; color: #000000; text-decoration: underline overline}
-->
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<a href="#">下劃線鏈接 </a>
<p></p>
<a href="#" class="r1">雙下劃線鏈接</a>
</BODY>
</HTML>
補(bǔ)充說明:
a:hover 表示鼠標(biāo)劃過時的樣式.
a:link 表示鏈接的樣式.
a:active 表示當(dāng)前活動連接的樣式.
a:visited 表示已經(jīng)訪問過的連接的樣式.
25, 用CSS給文字加入陰影效果和文字描邊效果。
.glow{FONT-SIZE: 9pt; FILTER: Glow(Color=#000000, Strength=1)}
//文字描邊效果
.shadow {FONT-SIZE: 9pt; FILTER: DropShadow(OffX=1, OffY=1, DropShadow(OffX=1, OffY=1, color:#111111); COLOR: #ffffff; FONT-FAMILY: "宋體"}
//加入陰影效果
補(bǔ)充說明:
這兩種濾鏡要想實現(xiàn)效果,必須加在如:<td class=glow或shadow ><div>xxxxxxxxx</div></td>上
,并且要留有足夠的空間能夠顯示陰影或描邊,否則會出現(xiàn)半截的陰影或描邊現(xiàn)象。
26,如何給做帶顏色的下拉菜單。
<select style="FONT-SIZE: 10px; COLOR: #ffffff; FONT-FAMILY: Verdana;BACKGROUND-COLOR: #ff6600;" size=1 >
<option selected>:: Dreamweaver4 ::</option>
<option>::Flash5::</option>
<option>::Firewoks4::</option>
</select>
27,關(guān)于DW4的表格中的亮邊框和暗邊框問題。
在DW4的表格面板中并沒有亮邊框和暗邊框的屬性設(shè)置,因為NC不支持,只有你在代碼中添加了。
bordercolorlight="#999999" bordercolordark="#000000"
你也可以用Css定義一個class。例如:
<style>
.bordercolor { bordercolorlight: #999999; bordercolordark: #000000 }
</style>
然后在要加效果的表格里加上<table class="bordercolor">
28,自動顯示主頁最后更新日期.
<script>
document.write("最后更新日期:"+document.lastModified+""
</script>愛電臺有我
29,如何讓滾動條出現(xiàn)在左邊?
我想居然在論壇中有人發(fā)表了這段代碼,很有意思,它的確照顧一些左撇子,呵呵!
<html dir="rtl">
<body bgcolor="#000000" text="#FFFFFF">
<table height=18 width=212 align=center bgcolor=#FFFFFF dir="ltr" cellspacing="1" cellpadding="0">
<tr>
<td bgcolor="#FF0000" >是不是你的滾動條在左邊啊</td>
</tr>
</table>
</body>
</html>
30,如何加入網(wǎng)址前面的小圖標(biāo)?
首先,您必須了解所謂的圖標(biāo)(Icon)是一種特殊的圖形文件格式,它是以 .ico 作為擴(kuò)展名。你可用在網(wǎng)上找一個制作圖標(biāo)軟件,它具有特有的規(guī)格:圖標(biāo)的大小為 16 * 16(以像素為單位);顏色不得超過 16 色。 在該網(wǎng)頁文件的 HEAD 部分加入下面的內(nèi)容:<LINK REL="SHORTCUT ICON" HREF=" http://skydesigner.51.net/圖標(biāo)文件名">,并放在該網(wǎng)頁的根目錄下。
31,在800*600顯示器中,如何不讓網(wǎng)頁水平出現(xiàn)滾動條!
設(shè)至<body leftmargin="0" topmargin="0">,網(wǎng)頁中的表格寬度為778。
32,關(guān)于<!DOTYPE>的說明解釋。
在網(wǎng)頁中,經(jīng)常會看到〈!DOCTYPE HTML PUBLIC`-//W3C//DTD HTML 4.01//EN`>,是聲明HTML文件的版本信息。
33, 用圖片來關(guān)閉窗體.
<A href="java script:window.close()"><IMG height=20 width=20 alt="關(guān)閉窗口" src="close.gif" border=0></A>
補(bǔ)充說明:如何使用了ACTIVEX!,不再警告窗口?
<html>
<head>
<object id=closes type="application/x-oleobject"
classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<param name="Command" value="Close"></object>
</head>
<body bgcolor="#003063" text="#ffffff" id=all> <a href="#">關(guān)閉窗口無提示</a>
</body>
</html>
34,禁止鼠標(biāo)右鍵查看網(wǎng)頁源代碼。
<SCRIPT language=javascript>
function click()
{if (event.button==2) {alert(`你好,歡迎光臨!`) }}
document.onmousedown=click
</SCRIPT>
補(bǔ)充說明:
鼠標(biāo)完全被封鎖,可以屏蔽鼠標(biāo)右鍵和網(wǎng)頁文字。
< body>
35,通過按鈕來查看網(wǎng)頁源代碼。
<input type="BUTTON" value="查看源代碼" onClick= `window.location = "view-source:" + window.location.href` name="BUTTON">
36,怎么用文字聯(lián)結(jié)實現(xiàn)按鈕的SUBMIT功能?
<a href="#">OK</a>
這段文字要放在form里。formname是這里要寫在form中的name,<form name=form111>那么就應(yīng)該是form111.submit()
37,如何做一個空鏈接?
加#
38,利用<IFRAME>來給網(wǎng)頁中插入網(wǎng)頁。
經(jīng)常我看到很多網(wǎng)頁中又有一個網(wǎng)頁,還以為是用了框架,其實不然,是用了<IFRAME>,它只適用于IE,NS可是不支持<IFRAME>的,但圍著的字句只有在瀏覽器不支援 iframe 標(biāo)記時才會顯示,如<noframes>一樣,可以放些提醒字句之類的話。
你注意啊!下面請和我學(xué)習(xí)它的用法。
分析代碼:<iframe src="iframe.html" name="test" align="MIDDLE" width="300" height="100" marginwidth="1" marginheight="1" frameborder="1" scrolling="Yes"> </iframe>
src="iframe.html"
用來顯示<IFRAME>中的網(wǎng)頁來源,必要加上相對或絕對路徑。
name="test"
這是連結(jié)標(biāo)記的 target 參數(shù)所需要的。
align="MIDDLE"
可選值為 left, right, top, middle, bottom,作用不大 。
width="300" height="100"
框窗的寬及長,以 pixels 為單位。
marginwidth="1" marginheight="1"
該插入的文件與框邊所保留的空間。
frameborder="1"
使用 1 表示顯示邊框, 0 則不顯示。(可以是 yes 或 no)
scrolling="Yes"
使用 Yes 表示容許卷動(內(nèi)定), No 則不容許卷動。
39,請問<tbody>的用法?
tbody用法據(jù)說是加強(qiáng)對表格的控制能力的.例如:
<table><tbody>……..</tbody></table>
tbody代碼如果不是你用手寫的話,只有在你用IE5打開一個網(wǎng)頁的時候, 把它另存為
一下,你的另存為的文件在表格中就會生成tbody代碼。(即便你的表格根本就沒有
tbody代碼,IE5另存為的時候也會給你生成)。
40,Alt和Title都是提示性語言標(biāo)簽,請注意它們之間的區(qū)別。
在我們?yōu)g覽網(wǎng)頁時,當(dāng)鼠標(biāo)停留在圖片對象或文字鏈接上時,在鼠標(biāo)的右下角有時會出現(xiàn)一個提示信息框。對目標(biāo)進(jìn)行一定的注釋說明。在一些場合,它的作用是很重要的。
alt 用來給圖片來提示的。Title用來給鏈接文字或普通文字提示的。
用法如下:
<p Title="給鏈接文字提示">文字</p>
<a href="#" Title="給鏈接文字提示">文字</a>
<img src="圖片.gif" alt="給圖片提示">
補(bǔ)充知識:<TITLE><ALT>里面如何多行換行?在源代碼里Enter回車。
<a href="#" Title="個人簡歷
姓名:張培
網(wǎng)名:我是閃夢
性別:男的,不是女的。
愛好:網(wǎng)頁制作,軟件開發(fā)">個人簡歷</a>
例如:個人簡歷
41, 用javascript代碼來實現(xiàn)閃爍按鈕。
<body>
<form method="POST" action="--WEBBOT-SELF--">
<input type="button" name=SUB value="閃爍" id=flashit style="BORDER: 1px solid ;BACKGROUND-COLOR: #FFFFFF">
</form>
<script>
if (document.all&&document.all.flashit)
{
var flashelement=document.all.flashit
if (flashelement.length==null)
flashelement[0]=document.all.flashit
function changecolor(which)
{
if (flashelement[which].style.color==`#800000`)
flashelement[which].style.color="#0063A4"
else
flashelement[which].style.color="#800000"
}
if (flashelement.length==null)
setInterval("changecolor(0)",1000)
else
for (i=0;i<flashelement.length;i++)
{
var tempvariable=`setInterval("changecolor(`+i+`)",`+`1000)`
eval(tempvariable)
}
}
</script>
</body>
42,CSS給圖片定義顏色邊框。
img { border: 1px solid red}
43,在DW中如何使插入的FLASH透明。
方法一:選中swf,打開原代碼窗口,在</object>前輸入:<param name="wmode" value="transparent">
方法二:在Flash中的Flie→Publist Settings→HTML→Window Mode選擇transparent
44,在DW編輯文本中,如何輸入一個空格呢?
輸入空格的問題,在DW似乎已成了一個老生常談的問題。通過將輸入法調(diào)整到全角模式就可以避免了。本以人工智能ABC為例.按Shift+Space切換到全角狀態(tài)。
45,為何我的DW中圖形顯示不正常。
第一種:可能是因為你定義并正在使用一個site,而你的HTML文件或者圖片不在這個site包含的區(qū)域之內(nèi),因此dreamweaver使用file協(xié)議來
描述圖象的絕對路徑,可惜IE不支持src中使用file協(xié)議,所以圖象就顯示不出來了。
第二種:可能是放圖片的文件夾或圖片名為中文,也顯示不到網(wǎng)頁中去。
46,如何在本地機(jī)器上測試flash影片的loading?
我想這可能是很多人在問的題了,其實很簡單,在Test時,選選View->Show Streaming就可以看到了。
47,在網(wǎng)頁中做出一根豎的線有幾種辦法.
第一種方法:用一個像素圖的辦法!
如果你用Dreamwever的Edit→Preferences…→Layout View中的Spacer Image給你創(chuàng)建了一個缺省名為:spacer.gif的一個像素圖文件 。
代碼中:
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#FF0000" height="200" ><img src="spacer.gif" width="1" height="1"></td>
</tr>
</table>
第二種方法:用表格填顏色的辦法!把<td> </td>中的 刪掉 .
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#FF0000" height="200" width="1"></td>
</tr>
</table>
第三種方法:用水平條。
<hr color="red" width="1" size="100%">
48, 關(guān)于鼠標(biāo)拖動,改變層大小。──看看微軟的做法.
<script>
document.execCommand("2D-position",false,true);
</script>
<DIV>
<DIV style="WIDTH: 300px; POSITION: absolute; HEIGHT: 100px; BACKGROUND-COLOR: red">移動層</DIV>
</DIV>
覽器支持
所有主流瀏覽器都支持 <a> 標(biāo)簽。
標(biāo)簽定義及使用說明
<a> 標(biāo)簽定義超鏈接,用于從一個頁面鏈接到另一個頁面。
<a> 元素最重要的屬性是 href 屬性,它指定鏈接的目標(biāo)。
在所有瀏覽器中,鏈接的默認(rèn)外觀如下:
未被訪問的鏈接帶有下劃線而且是藍(lán)色的
已被訪問的鏈接帶有下劃線而且是紫色的
活動鏈接帶有下劃線而且是紅色的
提示和注釋
提示:如果沒有使用 href 屬性,則不能使用 hreflang、media、rel、target 以及 type 屬性。
提示:通常在當(dāng)前瀏覽器窗口中顯示被鏈接頁面,除非規(guī)定了其他 target。
提示:請使用 CSS 來改變鏈接的樣式。
HTML 4.01 與 HTML5之間的差異
在 HTML 4.01 中,<a> 標(biāo)簽既可以是超鏈接,也可以是錨。在 HTML5 中,<a> 標(biāo)簽是超鏈接,但是假如沒有 href 屬性,它僅僅是超鏈接的一個占位符。
HTML5 有一些新的屬性,同時不再支持一些 HTML 4.01 的屬性。
屬性
New :HTML5 中的新屬性。
屬性 | 值 | 描述 |
---|---|---|
charset | char_encoding | HTML5 不支持。規(guī)定目標(biāo) URL 的字符編碼。 |
coords | coordinates | HTML5 不支持。規(guī)定鏈接的坐標(biāo)。 |
downloadNew | filename | 指定下載鏈接 |
href | URL | 規(guī)定鏈接的目標(biāo) URL。 |
hreflang | language_code | 規(guī)定目標(biāo) URL 的基準(zhǔn)語言。僅在 href 屬性存在時使用。 |
mediaNew | media_query | 規(guī)定目標(biāo) URL 的媒介類型。默認(rèn)值:all。僅在 href 屬性存在時使用。 |
name | section_name | HTML5 不支持。規(guī)定錨的名稱。 |
rel | alternateauthorbookmarkhelplicensenextnofollownoreferrerprefetchprevsearchtag | 規(guī)定當(dāng)前文檔與目標(biāo) URL 之間的關(guān)系。僅在 href 屬性存在時使用。 |
rev | text | HTML5 不支持。規(guī)定目標(biāo) URL 與當(dāng)前文檔之間的關(guān)系。 |
shape | defaultrectcirclepoly | HTML5 不支持。規(guī)定鏈接的形狀。 |
target | _blank_parent_self_topframename | 規(guī)定在何處打開目標(biāo) URL。僅在 href 屬性存在時使用。 |
typeNew | MIME_type | 規(guī)定目標(biāo) URL 的 MIME 類型。僅在 href 屬性存在時使用。注:MIME = Multipurpose Internet Mail Extensions。 |
全局屬性
<a> 標(biāo)簽支持 HTML 的全局屬性。
事件屬性
<a> 標(biāo)簽支持 HTML 的事件屬性。
創(chuàng)建超級鏈接
本例演示如何在 HTML 文檔中創(chuàng)建鏈接。
將圖像作為鏈接
本例演示如何使用圖像作為鏈接。
在新的瀏覽器窗口打開鏈接
本例演示如何在新窗口打開一個頁面,這樣的話訪問者就無需離開您的站點了。
創(chuàng)建電子郵件鏈接
本例演示如何鏈接到一個郵件。(本例在安裝郵件客戶端程序后才能工作。)
創(chuàng)建電子郵件鏈接 2
本例演示更加復(fù)雜的郵件鏈接。
使用錨跳轉(zhuǎn)到同一個頁面的不同位置
本例演示如何使用錨的 id 屬性跳轉(zhuǎn)到頁面的不同位置( HTML5 不支持 name 屬性)
如您還有不明白的可以在下面與我留言或是與我探討QQ群308855039,我們一起飛!
*請認(rèn)真填寫需求信息,我們會在24小時內(nèi)與您取得聯(lián)系。