Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 日本高清色视频在线观看免费,欧美人在线观看免费视频,一区二区高清视频在线观看

          整合營銷服務(wù)商

          電腦端+手機端+微信端=數(shù)據(jù)同步管理

          免費咨詢熱線:

          寫個網(wǎng)頁更簡單了!讓AI根據(jù)手繪原型生成HTML - 教程+代碼

          小新 編譯自 Insight Data Blog

          量子位 出品 | 公眾號 QbitAI

          寫個網(wǎng)頁能有多麻煩?在大多數(shù)公司里,這項工作分為三步:

          1. 產(chǎn)品經(jīng)理完成用戶調(diào)研任務(wù)后,列出一系列技術(shù)要求;

          2. 設(shè)計師根據(jù)這些要求來設(shè)計低保真原型,逐漸修改得到高保真原型和UI設(shè)計圖;

          3. 工程師將這些設(shè)計圖實現(xiàn)為代碼,最終變成用戶使用的產(chǎn)品。

          這么多環(huán)節(jié),任何地方出一點問題,都會拉長開發(fā)周期。因此,不少公司,比如Airbnb已經(jīng)開始用機器學(xué)習(xí)來提高這個過程的效率。

          Airbnb內(nèi)部的AI工具,從圖紙到代碼一步到位

          看起來很美好,但Airbnb還沒公開該模型中端到端訓(xùn)練的細節(jié),以及手工設(shè)計的圖像特征對該模型的貢獻度。這是該公司特有的閉源解決方案專利,可能不會進行公開。

          好在,一個叫Ashwin Kumar的程序員創(chuàng)建了一個開源版本,讓開發(fā)者/設(shè)計師的工作變得更簡單。

          以下內(nèi)容翻譯自他的博客:

          理想上,這個模型可以根據(jù)網(wǎng)站設(shè)計的簡單手繪原型,很快地生成一個可用的HTML網(wǎng)站:

          SketchCode模型利用手繪線框圖來生成HTML網(wǎng)站

          事實上,上面例子就是利用訓(xùn)練好的模型在測試集上生成的一個實際網(wǎng)站,代碼請訪問:https://github.com/ashnkumar/sketch-code。

          從圖像標注中獲取靈感

          目前要解決的問題屬于一種更廣泛的任務(wù),叫做程序綜合(program synthesis),即自動生成工作源代碼。盡管很多程序綜合研究通過自然語言規(guī)范或執(zhí)行追蹤法來生成代碼,但在當(dāng)前任務(wù)中,我會充分利用源圖像,即給出的手繪線框圖來展開工作。

          在機器學(xué)習(xí)中有一個十分熱門的研究領(lǐng)域,稱為圖像標注(image caption),目的是構(gòu)建一種把圖像和文本連接在一起的模型,特別是用于生成源圖像內(nèi)容的描述。

          圖像標注模型生成源圖像的文本描述

          我從一篇pix2code論文和另一個應(yīng)用這種方法的相關(guān)項目中獲得靈感,決定把我的任務(wù)按照圖像標注方式來實現(xiàn),把繪制的網(wǎng)站線框圖作為輸入圖像,并將其相應(yīng)的HTML代碼作為其輸出內(nèi)容。

          注:上段提到的兩個參考項目分別是

          pix2code論文:https://arxiv.org/abs/1705.07962

          floydhub教程:https://blog.floydhub.com/turning-design-mockups-into-code-with-deep-learning/?source=techstories.org

          獲取合適的數(shù)據(jù)集

          確定圖像標注方法后,理想中使用的訓(xùn)練數(shù)據(jù)集會包含成千上萬對手繪線框圖和對應(yīng)的HTML輸出代碼。但是,目前還沒有我想要的相關(guān)數(shù)據(jù)集,我只好為這個任務(wù)來創(chuàng)建數(shù)據(jù)集。

          最開始,我嘗試了pix2code論文給出的開源數(shù)據(jù)集,該數(shù)據(jù)集由1750張綜合生成網(wǎng)站的截圖及其相應(yīng)源代碼組成。

          pix2code數(shù)據(jù)集中的生成網(wǎng)站圖片和源代碼

          這是一個很好的數(shù)據(jù)集,有幾個有趣的地方:

          • 該數(shù)據(jù)集中的每個生成網(wǎng)站都包含幾個簡單的輔助程序元素,如按鈕、文本框和DIV對象。盡管這意味著這個模型受限于將這些少數(shù)元素作為它的輸出內(nèi)容,但是這些元素可通過選擇生成網(wǎng)絡(luò)來修改和擴展。這種方法應(yīng)該很容易地推廣到更大的元素詞匯表。

          • 每個樣本的源代碼都是由領(lǐng)域?qū)S谜Z言(DSL)的令牌組成,這是該論文作者為該任務(wù)所創(chuàng)建的。每個令牌對應(yīng)于HTML和CSS的一個片段,且加入編譯器把DSL轉(zhuǎn)換為運行的HTML代碼。

          彩色網(wǎng)站圖像變手繪圖

          為了修改我的任務(wù)數(shù)據(jù)集,我要讓網(wǎng)站圖像看起來像手工繪制出的。我嘗試使用Python中的OpenCV庫和PIL庫等工具對每張圖像進行修改,包括灰度轉(zhuǎn)換和輪廓檢測。

          最終,我決定直接修改原始網(wǎng)站的CSS樣式表,通過執(zhí)行以下操作:

          1. 更改頁面上元素的邊框半徑來平滑按鈕和DIV對象的邊緣;

          2. 模仿繪制的草圖來調(diào)整邊框的粗細,并添加陰影;

          3. 將原有字體更改為類似手寫的字體;

          最終實現(xiàn)的流程中還增加了一個步驟,通過添加傾斜、移動和旋轉(zhuǎn)來實現(xiàn)圖像增強,來模擬實際繪制草圖中的變化。

          使用圖像標注模型架構(gòu)

          現(xiàn)在,我已經(jīng)處理好數(shù)據(jù)集,接下來是構(gòu)建模型。

          我利用了圖像標注中使用的模型架構(gòu),該架構(gòu)由三個主要部分組成:

          1. 一種使用卷積神經(jīng)網(wǎng)絡(luò)(CNN)的計算機視覺模型,從源圖像提取圖像特征;

          2. 一種包含門控單元GRU的語言模型,對源代碼令牌序列進行編碼;

          3. 一個解碼器模型,也屬于GRU單元,把前兩個步驟的輸出作為輸入,并預(yù)測序列中的下一個令牌。

          以令牌序列為輸入來訓(xùn)練模型

          為了訓(xùn)練模型,我將源代碼拆分為令牌序列。模型的輸入為單個部分序列及它的源圖像,其標簽是文本中的下一個令牌。該模型使用交叉熵函數(shù)作為損失函數(shù),將模型的下個預(yù)測令牌與實際的下個令牌進行比較。

          在模型從頭開始生成代碼的過程中,該推理方式稍有不同。圖像仍然通過CNN網(wǎng)絡(luò)進行處理,但文本處理開始時僅采用一個啟動序列。在每個步驟中,模型對序列中輸出的下個預(yù)測令牌將會添加到當(dāng)前輸入序列,并作為新的輸入序列送到模型中;重復(fù)此操作直到模型的預(yù)測令牌為,或該過程達到每個文本中令牌數(shù)目的預(yù)定義值。

          當(dāng)模型生成一組預(yù)測令牌后,編譯器就會將DSL令牌轉(zhuǎn)換為HTML代碼,這些HTML代碼可以在任何瀏覽器中運行。

          用BLEU分數(shù)評估模型

          我決定使用BLEU分數(shù)來評估模型。這是機器翻譯任務(wù)中常用的一種度量標準,通過在給定相同輸入的情況下,衡量機器生成的文本與人類可能產(chǎn)生內(nèi)容的近似程度。

          實際上,BLEU通過比較生成文本和參考文本的N元序列,以創(chuàng)建修改后的準確版本。它非常適用于這個項目,因為它會影響生成HTML代碼中的實際元素,以及它們之間的相互關(guān)系。

          最棒的是,我還可以通過檢查生成的網(wǎng)站來比較當(dāng)前的實際BLEU分數(shù)。

          觀察BLEU分數(shù)

          當(dāng)BLEU分數(shù)為1.0時,則說明給定源圖像后該模型能在正確位置設(shè)置合適的元素,而較低的BLEU分數(shù)這說明模型預(yù)測了錯誤元素或是把它們放在相對不合適的位置。我們最終模型在評估數(shù)據(jù)集上的BLEU分數(shù)為0.76。

          福利:定制網(wǎng)頁風(fēng)格

          后來,我還想到,由于該模型只生成當(dāng)前頁面的框架,即文本的令牌,因此我可以在編譯過程中添加一個定制的CSS層,并立刻得到不同風(fēng)格的生成網(wǎng)站。

          一個手繪圖生成多種風(fēng)格的網(wǎng)頁

          把風(fēng)格定制和模型生成兩個過程分開,在使用模型時帶來了很多好處:

          1.如果想要將SketchCode模型應(yīng)用到自己公司的產(chǎn)品中,前端工程師可以直接使用該模型,只需更改一個CSS文件來匹配該公司的網(wǎng)頁設(shè)計風(fēng)格;

          2. 該模型內(nèi)置的可擴展性,即通過單一源圖像,模型可以迅速編譯出多種不同的預(yù)定義風(fēng)格,因此用戶可以設(shè)想出多種可能的網(wǎng)站風(fēng)格,并在瀏覽器中瀏覽這些生成網(wǎng)頁。

          總結(jié)和展望

          受到圖像標注研究的啟發(fā),SketchCode模型能夠在幾秒鐘內(nèi)將手繪網(wǎng)站線框圖轉(zhuǎn)換為可用的HTML網(wǎng)站。

          但是,該模型還存在一些問題,這也是我接下來可能的工作方向:

          1. 由于這個模型只使用了16個元素進行訓(xùn)練,所以它不能預(yù)測這些數(shù)據(jù)以外的令牌。下一步方向可能是使用更多元素來生成更多的網(wǎng)站樣本,包括網(wǎng)站圖片,下拉菜單和窗體,可參考啟動程序組件(https://getbootstrap.com/docs/4.0/components/buttons/)來獲得思路;

          2. 在實際網(wǎng)站構(gòu)建中,存在很多變化。創(chuàng)建一個能更好反映這種變化的訓(xùn)練集,是提高生成效果的一種好方法,可以通過獲取更多網(wǎng)站的HTML/CSS代碼以及內(nèi)容截圖來提高;

          3. 手繪圖紙也存在很多CSS修改技巧無法捕捉到的變化。解決這個問題的一種好方法是使用生成對抗網(wǎng)絡(luò)GAN來創(chuàng)建更逼真的繪制網(wǎng)站圖像。

          相關(guān)地址

          代碼:https://github.com/ashnkumar/sketch-code

          原文:https://blog.insightdatascience.com/automated-front-end-development-using-deep-learning-3169dd086e82

          — 完 —

          誠摯招聘

          量子位正在招募編輯/記者,工作地點在北京中關(guān)村。期待有才氣、有熱情的同學(xué)加入我們!相關(guān)細節(jié),請在量子位公眾號(QbitAI)對話界面,回復(fù)“招聘”兩個字。

          量子位 QbitAI · 頭條號簽約作者

          ?'?' ? 追蹤AI技術(shù)和產(chǎn)品新動態(tài)

          譯自: https://medium.freecodecamp.org/for-your-first-html-code-lets-help-batman-write-a-love-letter-64c203b9360b

          作者: Kunal Sarkar

          譯者: MjSeven

          在一個美好的夜晚,你的肚子拒絕消化你在晚餐吃的大塊披薩,所以你不得不在睡夢中沖進洗手間。

          在浴室里,當(dāng)你在思考為什么會發(fā)生這種情況時,你聽到一個來自通風(fēng)口的低沉聲音:“嘿,我是蝙蝠俠。”

          這時,你會怎么做呢?

          在你恐慌并處于關(guān)鍵時刻之前,蝙蝠俠說:“我需要你的幫助。我是一個超級極客,但我不懂 HTML。我需要用 HTML 寫一封情書,你愿意幫助我嗎?”

          誰會拒絕蝙蝠俠的請求呢,對吧?所以讓我們用 HTML 來寫一封蝙蝠俠的情書。

          你的第一個 HTML 文件

          HTML 網(wǎng)頁與你電腦上的其它文件一樣。就同一個 .doc 文件以 MS Word 打開,.jpg 文件在圖像查看器中打開一樣,一個 .html 文件在瀏覽器中打開。

          那么,讓我們來創(chuàng)建一個 .html 文件。你可以在 Notepad 或其它任何編輯器中完成此任務(wù),但我建議使用 VS Code。 在這里下載并安裝 VS Code 。它是免費的,也是我唯一喜歡的微軟產(chǎn)品。

          在系統(tǒng)中創(chuàng)建一個目錄,將其命名為 “HTML Practice”(不帶引號)。在這個目錄中,再創(chuàng)建一個名為 “Batman’s Love Letter”(不帶引號)的目錄,這將是我們的項目根目錄。這意味著我們所有與這個項目相關(guān)的文件都會在這里。

          打開 VS Code,按下 ctrl+n 創(chuàng)建一個新文件,按下 ctrl+s 保存文件。切換到 “Batman’s Love Letter” 文件夾并將其命名為 “l(fā)oveletter.html”,然后單擊保存。

          現(xiàn)在,如果你在文件資源管理器中雙擊它,它將在你的默認瀏覽器中打開。我建議使用 Firefox 來進行 web 開發(fā),但 Chrome 也可以。

          讓我們將這個過程與我們已經(jīng)熟悉的東西聯(lián)系起來。還記得你第一次拿到電腦嗎?我做的第一件事是打開 MS Paint 并繪制一些東西。你在 Paint 中繪制一些東西并將其另存為圖像,然后你可以在圖像查看器中查看該圖像。之后,如果要再次編輯該圖像,你在 Paint 中重新打開它,編輯并保存它。

          我們目前的流程非常相似。正如我們使用 Paint 創(chuàng)建和編輯圖像一樣,我們使用 VS Code 來創(chuàng)建和編輯 HTML 文件。就像我們使用圖像查看器查看圖像一樣,我們使用瀏覽器來查看我們的 HTML 頁面。

          HTML 中的段落

          我們有一個空的 HTML 文件,以下是蝙蝠俠想在他的情書中寫的第一段。

          “After all the battles we fought together, after all the difficult times we saw together, and after all the good and bad moments we’ve been through, I think it’s time I let you know how I feel about you.”

          復(fù)制這些到 VS Code 中的 loveletter.html。單擊 “View -> Toggle Word Wrap (alt+z)” 自動換行。

          保存并在瀏覽器中打開它。如果它已經(jīng)打開,單擊瀏覽器中的刷新按鈕。

          瞧!那是你的第一個網(wǎng)頁!

          我們的第一段已準備就緒,但這不是在 HTML 中編寫段落的推薦方法。我們有一種特定的方法讓瀏覽器知道一個文本是一個段落。

          如果你用 <p> 和 </p> 來包裹文本,那么瀏覽器將識別 <p> 和 </p> 中的文本是一個段落。我們這樣做:

          <p>After all the battles we fought together, after all the difficult times we saw together, after all the good and bad moments we've been through, I think it's time I let you know how I feel about you.</p>

          通過在 <p> 和 </p>中編寫段落,你創(chuàng)建了一個 HTML 元素。一個網(wǎng)頁就是 HTML 元素的集合。

          讓我們首先來認識一些術(shù)語:<p> 是開始標簽,</p> 是結(jié)束標簽,“p” 是標簽名稱。元素開始和結(jié)束標簽之間的文本是元素的內(nèi)容。

          “style” 屬性

          在上面,你將看到文本覆蓋屏幕的整個寬度。

          我們不希望這樣。沒有人想要閱讀這么長的行。讓我們設(shè)定段落寬度為 550px。

          我們可以通過使用元素的 style 屬性來實現(xiàn)。你可以在其 style 屬性中定義元素的樣式(例如,在我們的示例中為寬度)。以下行將在 p 元素上創(chuàng)建一個空樣式屬性:

          <p style="">...</p>

          你看到那個空的 "" 了嗎?這就是我們定義元素外觀的地方。現(xiàn)在我們要將寬度設(shè)置為 550px。我們這樣做:

          <p style="width:550px;">

          After all the battles we fought together, after all the difficult times we saw together, after all the good and bad moments we've been through, I think it's time I let you know how I feel about you.

          </p>

          我們將 width 屬性設(shè)置為 550px,用冒號 : 分隔,以分號 ; 結(jié)束。

          另外,注意我們?nèi)绾螌?<p> 和 </p> 放在單獨的行中,文本內(nèi)容用一個制表符縮進。像這樣設(shè)置代碼使其更具可讀性。

          HTML 中的列表

          接下來,蝙蝠俠希望列出他所欽佩的人的一些優(yōu)點,例如:

          You complete my darkness with your light. I love:

          - the way you see good in the worst things

          - the way you handle emotionally difficult situations

          - the way you look at Justice

          I have learned a lot from you. You have occupied a special place in my heart over time.

          這看起來很簡單。

          讓我們繼續(xù),在 </p> 下面復(fù)制所需的文本:

          <p style="width:550px;">

          After all the battles we faught together, after all the difficult times we saw together, after all the good and bad moments we've been through, I think it's time I let you know how I feel about you.

          </p>

          <p style="width:550px;">

          You complete my darkness with your light. I love:

          - the way you see good in the worse

          - the way you handle emotionally difficult situations

          - the way you look at Justice

          I have learned a lot from you. You have occupied a special place in my heart over the time.

          </p>

          保存并刷新瀏覽器。



          哇!這里發(fā)生了什么,我們的列表在哪里?

          如果你仔細觀察,你會發(fā)現(xiàn)沒有顯示換行符。在代碼中我們在新的一行中編寫列表項,但這些項在瀏覽器中顯示在一行中。

          如果你想在 HTML(新行)中插入換行符,你必須使用 <br>。讓我們來使用 <br>,看看它長什么樣:

          <p style="width:550px;">

          After all the battles we faught together, after all the difficult times we saw together, after all the good and bad moments we've been through, I think it's time I let you know how I feel about you.

          </p>

          <p style="width:550px;">

          You complete my darkness with your light. I love: <br>

          - the way you see good in the worse <br>

          - the way you handle emotionally difficult situations <br>

          - the way you look at Justice <br>

          I have learned a lot from you. You have occupied a special place in my heart over the time.

          </p>

          保存并刷新:



          好的,現(xiàn)在它看起來就像我們想要的那樣!

          另外,注意我們沒有寫一個 </br>。有些標簽不需要結(jié)束標簽(它們被稱為自閉合標簽)。

          還有一件事:我們沒有在兩個段落之間使用 <br>,但第二個段落仍然是從一個新行開始,這是因為 <p> 元素會自動插入換行符。

          我們使用純文本編寫列表,但是有兩個標簽可以供我們使用來達到相同的目的:<ul> and <li>。

          讓我們解釋一下名字的意思:ul 代表 無序列表(Unordered List),li 代表 列表項目(List Item)。讓我們使用它們來展示我們的列表:

          <p style="width:550px;">

          After all the battles we faught together, after all the difficult times we saw together, after all the good and bad moments we've been through, I think it's time I let you know how I feel about you.

          </p>

          <p style="width:550px;">

          You complete my darkness with your light. I love:

          <ul>

          <li>the way you see good in the worse</li>

          <li>the way you handle emotionally difficult situations</li>

          <li>the way you look at Justice</li>

          </ul>

          I have learned a lot from you. You have occupied a special place in my heart over the time.

          </p>

          在復(fù)制代碼之前,注意差異部分:

          • 我們刪除了所有的 <br>,因為每個 <li> 會自動顯示在新行中
          • 我們將每個列表項包含在 <li> 和 </li> 之間
          • 我們將所有列表項的集合包裹在 <ul> 和 </ul> 之間
          • 我們沒有像 <p> 元素那樣定義 <ul> 元素的寬度。這是因為 <ul> 是 <p> 的子節(jié)點,<p> 已經(jīng)被約束到 550px,所以 <ul> 不會超出這個范圍。

          讓我們保存文件并刷新瀏覽器以查看結(jié)果:



          你會立即注意到在每個列表項之前顯示了重點標志。我們現(xiàn)在不需要在每個列表項之前寫 “-”。

          經(jīng)過仔細檢查,你會注意到最后一行超出 550px 寬度。這是為什么?因為 HTML 不允許 <ul> 元素出現(xiàn)在 <p> 元素中。讓我們將第一行和最后一行放在單獨的 <p> 元素中:

          <p style="width:550px;">

          After all the battles we faught together, after all the difficult times we saw together, after all the good and bad moments we've been through, I think it's time I let you know how I feel about you.

          </p>

          <p style="width:550px;">

          You complete my darkness with your light. I love:

          </p>

          <ul style="width:550px;">

          <li>the way you see good in the worse</li>

          <li>the way you handle emotionally difficult situations</li>

          <li>the way you look at Justice</li>

          </ul>

          <p style="width:550px;">

          I have learned a lot from you. You have occupied a special place in my heart over the time.

          </p>

          保存并刷新。

          注意,這次我們還定義了 <ul> 元素的寬度。那是因為我們現(xiàn)在已經(jīng)將 <ul> 元素放在了 <p> 元素之外。

          定義情書中所有元素的寬度會變得很麻煩。我們有一個特定的元素用于此目的:<div> 元素。一個 <div> 元素就是一個通用容器,用于對內(nèi)容進行分組,以便輕松設(shè)置樣式。

          讓我們用 <div> 元素包裝整個情書,并為其賦予寬度:550px 。

          <div style="width:550px;">

          <p>

          After all the battles we faught together, after all the difficult times we saw together, after all the good and bad moments we've been through, I think it's time I let you know how I feel about you.

          </p>

          <p>

          You complete my darkness with your light. I love:

          </p>

          <ul>

          <li>the way you see good in the worse</li>

          <li>the way you handle emotionally difficult situations</li>

          <li>the way you look at Justice</li>

          </ul>

          <p>

          I have learned a lot from you. You have occupied a special place in my heart over the time.

          </p>

          </div>

          棒極了,我們的代碼現(xiàn)在看起來簡潔多了。

          HTML 中的標題

          到目前為止,蝙蝠俠對結(jié)果很高興,他希望在情書上標題。他想寫一個標題: “Bat Letter”。當(dāng)然,你已經(jīng)看到這個名字了,不是嗎?:D

          你可以使用 <h1>、<h2>、<h3>、<h4>、<h5> 和 <h6> 標簽來添加標題,<h1> 是最大的標題和最主要的標題,<h6> 是最小的標題。



          讓我們在第二段之前使用 <h1> 做主標題和一個副標題:

          <div style="width:550px;">

          <h1>Bat Letter</h1>

          <p>

          After all the battles we faught together, after all the difficult times we saw together, after all the good and bad moments we've been through, I think it's time I let you know how I feel about you.

          </p>

          <h2>You are the light of my life</h2>

          <p>

          You complete my darkness with your light. I love:

          </p>

          <ul>

          <li>the way you see good in the worse</li>

          <li>the way you handle emotionally difficult situations</li>

          <li>the way you look at Justice</li>

          </ul>

          <p>

          I have learned a lot from you. You have occupied a special place in my heart over the time.

          </p>

          </div>

          保存,刷新。



          HTML 中的圖像

          我們的情書尚未完成,但在繼續(xù)之前,缺少一件大事:蝙蝠俠標志。你見過是蝙蝠俠的東西但沒有蝙蝠俠的標志嗎?

          并沒有。

          所以,讓我們在情書中添加一個蝙蝠俠標志。

          在 HTML 中包含圖像就像在一個 Word 文件中包含圖像一樣。在 MS Word 中,你到 “菜單 -> 插入 -> 圖像 -> 然后導(dǎo)航到圖像位置為止 -> 選擇圖像 -> 單擊插入”。

          在 HTML 中,我們使用 <img> 標簽讓瀏覽器知道我們需要加載的圖像,而不是單擊菜單。我們在 src 屬性中寫入文件的位置和名稱。如果圖像在項目根目錄中,我們可以簡單地在 src 屬性中寫入圖像文件的名稱。

          在我們深入編碼之前,從 這里 下載蝙蝠俠標志。你可能希望裁剪圖像中的額外空白區(qū)域。復(fù)制項目根目錄中的圖像并將其重命名為 “bat-logo.jpeg”。

          <div style="width:550px;">

          <h1>Bat Letter</h1>

          <img src="bat-logo.jpeg">

          <p>

          After all the battles we faught together, after all the difficult times we saw together, after all the good and bad moments we've been through, I think it's time I let you know how I feel about you.

          </p>

          <h2>You are the light of my life</h2>

          <p>

          You complete my darkness with your light. I love:

          </p>

          <ul>

          <li>the way you see good in the worse</li>

          <li>the way you handle emotionally difficult situations</li>

          <li>the way you look at Justice</li>

          </ul>

          <p>

          I have learned a lot from you. You have occupied a special place in my heart over the time.

          </p>

          </div>

          我們在第 3 行包含了 <img> 標簽。這個標簽也是一個自閉合的標簽,所以我們不需要寫 </img>。在 src 屬性中,我們給出了圖像文件的名稱。這個名稱應(yīng)與圖像名稱完全相同,包括擴展名(.jpeg)及其大小寫。

          保存并刷新,查看結(jié)果。



          該死的!剛剛發(fā)生了什么?

          當(dāng)使用 <img> 標簽包含圖像時,默認情況下,圖像將以其原始分辨率顯示。在我們的例子中,圖像比 550px 寬得多。讓我們使用 style 屬性定義它的寬度:

          <div style="width:550px;">

          <h1>Bat Letter</h1>

          <img src="bat-logo.jpeg" style="width:100%">

          <p>

          After all the battles we faught together, after all the difficult times we saw together, after all the good and bad moments we've been through, I think it's time I let you know how I feel about you.

          </p>

          <h2>You are the light of my life</h2>

          <p>

          You complete my darkness with your light. I love:

          </p>

          <ul>

          <li>the way you see good in the worse</li>

          <li>the way you handle emotionally difficult situations</li>

          <li>the way you look at Justice</li>

          </ul>

          <p>

          I have learned a lot from you. You have occupied a special place in my heart over the time.

          </p>

          </div>

          你會注意到,這次我們定義寬度使用了 “%” 而不是 “px”。當(dāng)我們在 “%” 中定義寬度時,它將占據(jù)父元素寬度的百分比。因此,100% 的 550px 將為我們提供 550px。

          保存并刷新,查看結(jié)果。



          太棒了!這讓蝙蝠俠的臉露出了羞澀的微笑 :)。

          HTML 中的粗體和斜體

          現(xiàn)在蝙蝠俠想在最后幾段中承認他的愛。他有以下文本供你用 HTML 編寫:

          “I have a confession to make

          It feels like my chest does have a heart. You make my heart beat. Your smile brings a smile to my face, your pain brings pain to my heart.

          I don’t show my emotions, but I think this man behind the mask is falling for you.”

          當(dāng)閱讀到這里時,你會問蝙蝠俠:“等等,這是給誰的?”蝙蝠俠說:

          “這是給超人的。”



          你說:哦!我還以為是給神奇女俠的呢。

          蝙蝠俠說:不,這是給超人的,請在最后寫上 “I love you Superman.”。

          好的,我們來寫:

          <div style="width:550px;">

          <h1>Bat Letter</h1>

          <img src="bat-logo.jpeg" style="width:100%">

          <p>

          After all the battles we faught together, after all the difficult times we saw together, after all the good and bad moments we've been through, I think it's time I let you know how I feel about you.

          </p>

          <h2>You are the light of my life</h2>

          <p>

          You complete my darkness with your light. I love:

          </p>

          <ul>

          <li>the way you see good in the worse</li>

          <li>the way you handle emotionally difficult situations</li>

          <li>the way you look at Justice</li>

          </ul>

          <p>

          I have learned a lot from you. You have occupied a special place in my heart over the time.

          </p>

          <h2>I have a confession to make</h2>

          <p>

          It feels like my chest does have a heart. You make my heart beat. Your smile brings smile on my face, your pain brings pain to my heart.

          </p>

          <p>

          I don't show my emotions, but I think this man behind the mask is falling for you.

          </p>

          <p>I love you Superman.</p>

          <p>

          Your not-so-secret-lover, <br>

          Batman

          </p>

          </div>

          這封信差不多完成了,蝙蝠俠另外想再做兩次改變。蝙蝠俠希望在最后段落的第一句中的 “does” 一詞是斜體,而 “I love you Superman” 這句話是粗體的。

          我們使用 <em> 和 <strong> 以斜體和粗體顯示文本。讓我們來更新這些更改:

          <div style="width:550px;">

          <h1>Bat Letter</h1>

          <img src="bat-logo.jpeg" style="width:100%">

          <p>

          After all the battles we faught together, after all the difficult times we saw together, after all the good and bad moments we've been through, I think it's time I let you know how I feel about you.

          </p>

          <h2>You are the light of my life</h2>

          <p>

          You complete my darkness with your light. I love:

          </p>

          <ul>

          <li>the way you see good in the worse</li>

          <li>the way you handle emotionally difficult situations</li>

          <li>the way you look at Justice</li>

          </ul>

          <p>

          I have learned a lot from you. You have occupied a special place in my heart over the time.

          </p>

          <h2>I have a confession to make</h2>

          <p>

          It feels like my chest <em>does</em> have a heart. You make my heart beat. Your smile brings smile on my face, your pain brings pain to my heart.

          </p>

          <p>

          I don't show my emotions, but I think this man behind the mask is falling for you.

          </p>

          <p><strong>I love you Superman.</strong></p>

          <p>

          Your not-so-secret-lover, <br>

          Batman

          </p>

          </div>



          HTML 中的樣式

          你可以通過三種方式設(shè)置樣式或定義 HTML 元素的外觀:

          • 內(nèi)聯(lián)樣式:我們使用元素的 style 屬性來編寫樣式。這是我們迄今為止使用的,但這不是一個好的實踐。
          • 嵌入式樣式:我們在由 <style> 和 </style> 包裹的 “style” 元素中編寫所有樣式。
          • 鏈接樣式表:我們在具有 .css 擴展名的單獨文件中編寫所有元素的樣式。此文件稱為樣式表。

          讓我們來看看如何定義 <div> 的內(nèi)聯(lián)樣式:

          <div style="width:550px;">

          我們可以在 <style> 和 </style> 里面寫同樣的樣式:

          div{

          width:550px;

          }

          在嵌入式樣式中,我們編寫的樣式是與元素分開的。所以我們需要一種方法來關(guān)聯(lián)元素及其樣式。第一個單詞 “div” 就做了這樣的活。它讓瀏覽器知道花括號 {...} 里面的所有樣式都屬于 “div” 元素。由于這種語法確定要應(yīng)用樣式的元素,因此它稱為一個選擇器。

          我們編寫樣式的方式保持不變:屬性(width)和值(550px)用冒號(:)分隔,以分號(;)結(jié)束。

          讓我們從 <div> 和 <img> 元素中刪除內(nèi)聯(lián)樣式,將其寫入 <style> 元素:

          <style>

          div{

          width:550px;

          }

          img{

          width:100%;

          }

          </style>

          <div>

          <h1>Bat Letter</h1>

          <img src="bat-logo.jpeg">

          <p>

          After all the battles we faught together, after all the difficult times we saw together, after all the good and bad moments we've been through, I think it's time I let you know how I feel about you.

          </p>

          <h2>You are the light of my life</h2>

          <p>

          You complete my darkness with your light. I love:

          </p>

          <ul>

          <li>the way you see good in the worse</li>

          <li>the way you handle emotionally difficult situations</li>

          <li>the way you look at Justice</li>

          </ul>

          <p>

          I have learned a lot from you. You have occupied a special place in my heart over the time.

          </p>

          <h2>I have a confession to make</h2>

          <p>

          It feels like my chest <em>does</em> have a heart. You make my heart beat. Your smile brings smile on my face, your pain brings pain to my heart.

          </p>

          <p>

          I don't show my emotions, but I think this man behind the mask is falling for you.

          </p>

          <p><strong>I love you Superman.</strong></p>

          <p>

          Your not-so-secret-lover, <br>

          Batman

          </p>

          </div>

          保存并刷新,結(jié)果應(yīng)保持不變。

          但是有一個大問題,如果我們的 HTML 文件中有多個 <div> 和 <img> 元素該怎么辦?這樣我們在 <style> 元素中為 div 和 img 定義的樣式就會應(yīng)用于頁面上的每個 div 和 img。

          如果你在以后的代碼中添加另一個 div,那么該 div 也將變?yōu)?550px 寬。我們并不希望這樣。

          我們想要將我們的樣式應(yīng)用于現(xiàn)在正在使用的特定 div 和 img。為此,我們需要為 div 和 img 元素提供唯一的 id。以下是使用 id 屬性為元素賦予 id 的方法:

          <div id="letter-container">

          以下是如何在嵌入式樣式中將此 id 用作選擇器:

          #letter-container{

          ...

          }

          注意 # 符號。它表示它是一個 id,{...} 中的樣式應(yīng)該只應(yīng)用于具有該特定 id 的元素。

          讓我們來應(yīng)用它:

          <style>

          #letter-container{

          width:550px;

          }

          #header-bat-logo{

          width:100%;

          }

          </style>

          <div id="letter-container">

          <h1>Bat Letter</h1>

          <img id="header-bat-logo" src="bat-logo.jpeg">

          <p>

          After all the battles we faught together, after all the difficult times we saw together, after all the good and bad moments we've been through, I think it's time I let you know how I feel about you.

          </p>

          <h2>You are the light of my life</h2>

          <p>

          You complete my darkness with your light. I love:

          </p>

          <ul>

          <li>the way you see good in the worse</li>

          <li>the way you handle emotionally difficult situations</li>

          <li>the way you look at Justice</li>

          </ul>

          <p>

          I have learned a lot from you. You have occupied a special place in my heart over the time.

          </p>

          <h2>I have a confession to make</h2>

          <p>

          It feels like my chest <em>does</em> have a heart. You make my heart beat. Your smile brings smile on my face, your pain brings pain to my heart.

          </p>

          <p>

          I don't show my emotions, but I think this man behind the mask is falling for you.

          </p>

          <p><strong>I love you Superman.</strong></p>

          <p>

          Your not-so-secret-lover, <br>

          Batman

          </p>

          </div>

          HTML 已經(jīng)準備好了嵌入式樣式。

          但是,你可以看到,隨著我們包含越來越多的樣式,<style></style> 將變得很大。這可能很快會混亂我們的主 HTML 文件。

          因此,讓我們更進一步,通過將 <style> 標簽內(nèi)的內(nèi)容復(fù)制到一個新文件來使用鏈接樣式。

          在項目根目錄中創(chuàng)建一個新文件,將其另存為 “style.css”:

          #letter-container{

          width:550px;

          }

          #header-bat-logo{

          width:100%;

          }

          我們不需要在 CSS 文件中寫 <style> 和 </style>。

          我們需要使用 HTML 文件中的 <link> 標簽來將新創(chuàng)建的 CSS 文件鏈接到 HTML 文件。以下是我們?nèi)绾巫龅竭@一點:

          <link rel="stylesheet" type="text/css" href="style.css">

          我們使用 <link> 元素在 HTML 文檔中包含外部資源,它主要用于鏈接樣式表。我們使用的三個屬性是:

          • rel:關(guān)系。鏈接文件與文檔的關(guān)系。具有 .css 擴展名的文件稱為樣式表,因此我們保留 rel=“stylesheet”。
          • type:鏈接文件的類型;對于一個 CSS 文件來說它是 “text/css”。
          • href:超文本參考。鏈接文件的位置。

          link 元素的結(jié)尾沒有 </link>。因此,<link> 也是一個自閉合的標簽。

          <link rel="gf" type="cute" href="girl.next.door">

          如果只是得到一個女朋友,那么很容易:D

          可惜沒有那么簡單,讓我們繼續(xù)前進。

          這是我們 “l(fā)oveletter.html” 的內(nèi)容:

          <link rel="stylesheet" type="text/css" href="style.css">

          <div id="letter-container">

          <h1>Bat Letter</h1>

          <img id="header-bat-logo" src="bat-logo.jpeg">

          <p>

          After all the battles we faught together, after all the difficult times we saw together, after all the good and bad moments we've been through, I think it's time I let you know how I feel about you.

          </p>

          <h2>You are the light of my life</h2>

          <p>

          You complete my darkness with your light. I love:

          </p>

          <ul>

          <li>the way you see good in the worse</li>

          <li>the way you handle emotionally difficult situations</li>

          <li>the way you look at Justice</li>

          </ul>

          <p>

          I have learned a lot from you. You have occupied a special place in my heart over the time.

          </p>

          <h2>I have a confession to make</h2>

          <p>

          It feels like my chest <em>does</em> have a heart. You make my heart beat. Your smile brings smile on my face, your pain brings pain to my heart.

          </p>

          <p>

          I don't show my emotions, but I think this man behind the mask is falling for you.

          </p>

          <p><strong>I love you Superman.</strong></p>

          <p>

          Your not-so-secret-lover, <br>

          Batman

          </p>

          </div>

          “style.css” 內(nèi)容:

          #letter-container{

          width:550px;

          }

          #header-bat-logo{

          width:100%;

          }

          保存文件并刷新,瀏覽器中的輸出應(yīng)保持不變。

          一些手續(xù)

          我們的情書已經(jīng)準備好給蝙蝠俠,但還有一些正式的片段。

          與其他任何編程語言一樣,HTML 自出生以來(1990 年)經(jīng)歷過許多版本,當(dāng)前版本是 HTML5。

          那么,瀏覽器如何知道你使用哪個版本的 HTML 來編寫頁面呢?要告訴瀏覽器你正在使用 HTML5,你需要在頁面頂部包含 <!DOCTYPE html>。對于舊版本的 HTML,這行不同,但你不需要了解它們,因為我們不再使用它們了。

          此外,在之前的 HTML 版本中,我們曾經(jīng)將整個文檔封裝在 <html></html> 標簽內(nèi)。整個文件分為兩個主要部分:頭部在 <head></head> 里面,主體在 <body></body> 里面。這在 HTML5 中不是必須的,但由于兼容性原因,我們?nèi)匀贿@樣做。讓我們用 <Doctype>, <html>、 <head> 和 <body> 更新我們的代碼:

          <!DOCTYPE html>

          <html>

          <head>

          <link rel="stylesheet" type="text/css" href="style.css">

          </head>

          <body>

          <div id="letter-container">

          <h1>Bat Letter</h1>

          <img id="header-bat-logo" src="bat-logo.jpeg">

          <p>

          After all the battles we faught together, after all the difficult times we saw together, after all the good and bad moments we've been through, I think it's time I let you know how I feel about you.

          </p>

          <h2>You are the light of my life</h2>

          <p>

          You complete my darkness with your light. I love:

          </p>

          <ul>

          <li>the way you see good in the worse</li>

          <li>the way you handle emotionally difficult situations</li>

          <li>the way you look at Justice</li>

          </ul>

          <p>

          I have learned a lot from you. You have occupied a special place in my heart over the time.

          </p>

          <h2>I have a confession to make</h2>

          <p>

          It feels like my chest <em>does</em> have a heart. You make my heart beat. Your smile brings smile on my face, your pain brings pain to my heart.

          </p>

          <p>

          I don't show my emotions, but I think this man behind the mask is falling for you.

          </p>

          <p><strong>I love you Superman.</strong></p>

          <p>

          Your not-so-secret-lover, <br>

          Batman

          </p>

          </div>

          </body>

          </html>

          主要內(nèi)容在 <body> 里面,元信息在 <head> 里面。所以我們把 <div> 保存在 <body> 里面并加載 <head> 里面的樣式表。

          保存并刷新,你的 HTML 頁面應(yīng)顯示與之前相同的內(nèi)容。

          HTML 的標題

          我發(fā)誓,這是最后一次改變。

          你可能已經(jīng)注意到選項卡的標題正在顯示 HTML 文件的路徑:



          我們可以使用 <title> 標簽來定義 HTML 文件的標題。標題標簽也像鏈接標簽一樣在 <head> 內(nèi)部。讓我們我們在標題中加上 “Bat Letter”:

          <!DOCTYPE html>

          <html>

          <head>

          <title>Bat Letter</title>

          <link rel="stylesheet" type="text/css" href="style.css">

          </head>

          <body>

          <div id="letter-container">

          <h1>Bat Letter</h1>

          <img id="header-bat-logo" src="bat-logo.jpeg">

          <p>

          After all the battles we faught together, after all the difficult times we saw together, after all the good and bad moments we've been through, I think it's time I let you know how I feel about you.

          </p>

          <h2>You are the light of my life</h2>

          <p>

          You complete my darkness with your light. I love:

          </p>

          <ul>

          <li>the way you see good in the worse</li>

          <li>the way you handle emotionally difficult situations</li>

          <li>the way you look at Justice</li>

          </ul>

          <p>

          I have learned a lot from you. You have occupied a special place in my heart over the time.

          </p>

          <h2>I have a confession to make</h2>

          <p>

          It feels like my chest <em>does</em> have a heart. You make my heart beat. Your smile brings smile on my face, your pain brings pain to my heart.

          </p>

          <p>

          I don't show my emotions, but I think this man behind the mask is falling for you.

          </p>

          <p><strong>I love you Superman.</strong></p>

          <p>

          Your not-so-secret-lover, <br>

          Batman

          </p>

          </div>

          </body>

          </html>

          保存并刷新,你將看到在選項卡上顯示的是 “Bat Letter” 而不是文件路徑。

          蝙蝠俠的情書現(xiàn)在已經(jīng)完成。

          恭喜!你用 HTML 制作了蝙蝠俠的情書。



          我們學(xué)到了什么

          我們學(xué)習(xí)了以下新概念:

          • 一個 HTML 文檔的結(jié)構(gòu)
          • 在 HTML 中如何寫元素(<p></p>)
          • 如何使用 style 屬性在元素內(nèi)編寫樣式(這稱為內(nèi)聯(lián)樣式,盡可能避免這種情況)
          • 如何在 <style>...</style> 中編寫元素的樣式(這稱為嵌入式樣式)
          • 在 HTML 中如何使用 <link> 在單獨的文件中編寫樣式并鏈接它(這稱為鏈接樣式表)
          • 什么是標簽名稱,屬性,開始標簽和結(jié)束標簽
          • 如何使用 id 屬性為一個元素賦予 id
          • CSS 中的標簽選擇器和 id 選擇器

          我們學(xué)習(xí)了以下 HTML 標簽:

          • <p>:用于段落
          • <br>:用于換行
          • <ul>、<li>:顯示列表
          • <div>:用于分組我們信件的元素
          • <h1>、<h2>:用于標題和子標題
          • <img>:用于插入圖像
          • <strong>、<em>:用于粗體和斜體文字樣式
          • <style>:用于嵌入式樣式
          • <link>:用于包含外部樣式表
          • <html>:用于包裹整個 HTML 文檔
          • <!DOCTYPE html>:讓瀏覽器知道我們正在使用 HTML5
          • <head>:包裹元信息,如 <link> 和 <title>
          • <body>:用于實際顯示的 HTML 頁面的主體
          • <title>:用于 HTML 頁面的標題

          我們學(xué)習(xí)了以下 CSS 屬性:

          • width:用于定義元素的寬度
          • CSS 單位:“px” 和 “%”

          朋友們,這就是今天的全部了,下一個教程中見。


          作者簡介:開發(fā)者 + 作者 | supersarkar.com | twitter.com/supersarkar


          via: https://medium.freecodecamp.org/for-your-first-html-code-lets-help-batman-write-a-love-letter-64c203b9360b

          作者: Kunal Sarkar 譯者: MjSeven 校對: wxy

          本文由 LCTT 原創(chuàng)編譯, Linux中國 榮譽推出

          點擊“了解更多”可訪問文內(nèi)鏈接

          .結(jié)構(gòu)性定義

          文件類型 <HTML></HTML> (放在檔案的開頭與結(jié)尾)

          文件主題 <TITLE></TITLE> (必須放在「文頭」區(qū)塊內(nèi))

          文頭 <HEAD></HEAD> (描述性資料,像是「主題」)

          文體 <BODY></BODY> (文件本體)

          (由瀏覽器控制的顯示風(fēng)格)

          標題 <H?></H?> (從1到6,有六層選擇)

          標題的對齊 <H? ALIGN=LEFT|CENTER|RIGHT></H?>

          區(qū)分 <DIV></DIV>

          區(qū)分的對齊 <DIV ALIGN=LEFT|RIGHT|CENTER|JUSTIFY></DIV>

          引文區(qū)塊 <BLOCKQUOTE></BLOCKQUOTE> (通常會內(nèi)縮)

          強調(diào) <EM></EM> (通常會以斜體顯示)

          特別強調(diào) <STRONG></STRONG> (通常會以加粗顯示)

          引文 <CITE></CITE> (通常會以斜體顯示)

          碼 <CODE></CODE> (顯示原始碼之用)

          樣本 <SAMP></SAMP>

          鍵盤輸入 <KBD></KBD>

          變數(shù) <VAR></VAR>

          定義 <DFN></DFN> (有些瀏覽器不提供)

          地址 <ADDRESS></ADDRESS>

          大字 <BIG></BIG>

          小字 <SMALL></SMALL>

          與外觀相關(guān)的標簽(作者自訂的表現(xiàn)方式)

          加粗 <B></B>

          斜體 <I></I>

          底線 <U></U> (尚有些瀏覽器不提供)

          刪除線 <S></S> (尚有些瀏覽器不提供)

          下標 <SUB></SUB>

          上標 <SUP></SUP>

          打字機體 <TT></TT> (用單空格字型顯示)

          預(yù)定格式 <PRE></PRE> (保留文件中空格的大小)

          預(yù)定格式的寬度 <PRE WIDTH=?></PRE>(以字元計算)

          向中看齊 <CENTER></CENTER> (文字與圖片都可以)

          閃耀 <BLINK></BLINK> (有史以來最被嘲弄的標簽)

          字體大小 <FONT SIZE=?></FONT>(從1到7)

          改變字體大小 <FONT SIZE=+|-?></FONT>

          基本字體大小 <BASEFONT SIZE=?> (從1到7; 內(nèi)定為3)

          字體顏色 <FONT COLOR="#$$$$$$"></FONT>

          說明 <!-- *** --> (瀏覽器不會顯示)

          <!--修改滾動條-->

          <style type="text/css">

          body {

          scrollbar-face-color: #330033;

          scrollbar-shadow-color: #FFFFFF;

          scrollbar-highlight-color: #FFFFFF;

          scrollbar-3dlight-color: #FFFFFF;

          scrollbar-darkshadow-color: #FFFFFF;

          scrollbar-track-color: #330033;

          scrollbar-arrow-color: #FFFFFF;

          }

          </style>

          <!--修改滾動條結(jié)束-->

          將上面的代碼放在葉子代碼的<head></head>之間,顏色可根據(jù)自己的需要修改。

          滾動條的代碼意思如下:

          Scrollbar-Face-Color為滾動條表面顏色設(shè)定;

          Scrollbar-Track-Color為滾動條底板顏色設(shè)定;

          Scrollbar-Darkshadow為滾動條下邊和右邊邊沿顏色設(shè)定;

          Scrollbar-Highlight-Color為滾動條上斜面和左斜面顏色設(shè)定;

          Scrollbar-Shadow-Color為滾動條下斜面和右斜面顏色設(shè)定;

          Scrollbar-3Dlight-Color為滾動條上邊和左邊的邊沿顏色設(shè)定;

          Scrollbar-Arrow-Color為滾動條兩端箭頭顏色設(shè)定。

          <!> 跑馬燈

          <marquee>...</marquee>普通捲動

          <marquee behavior=slide>...</marquee>滑動

          <marquee behavior=scroll>...</marquee>預(yù)設(shè)捲動

          <marquee behavior=alternate>...</marquee>來回捲動

          <marquee direction=down>...</marquee>向下捲動

          <marquee direction=up>...</marquee>向上捲動

          <marquee direction=right></marquee>向右捲動

          <marquee direction=’left’></marquee>向左捲動

          <marquee loop=2>...</marquee>捲動次數(shù)

          <marquee width=180>...</marquee>設(shè)定寬度

          <marquee height=30>...</marquee>設(shè)定高度

          <marquee bgcolor=FF0000>...</marquee>設(shè)定背景顏色

          <marquee scrollamount=30>...</marquee>設(shè)定捲動距離

          <marquee scrolldelay=300>...</marquee>設(shè)定捲動時間

          1)貼圖:<img src="圖片地址">

          2)加入連接:<a href="所要連接的相關(guān)地址">寫上你想寫的字</a>

          3)在新窗口打開連接:<a href="相關(guān)地址" 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位進制)之間

          12)消除連接的下劃線:<a href="相關(guān)地址" style="text-decoration:none">寫上你想寫的字</a>

          13)貼音樂:<embed src="音樂地址" width="寬度" height="高度" 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>

          1、店鋪音樂代碼:音樂網(wǎng)址" loop="-1">

          2、圖片制作代碼:<img src="這里放圖片地址">

          3、公告圖片代碼:<img border="0" src="這里放圖片地址" />或<img src="這里放圖片地址"/>

          4、懸浮掛飾代碼:<img src="這里放圖片地址" style="left:20px; position: relative; top:0px" />

          5、商品分類代碼:<img src="這里放圖片地址"/>

          6、字體大小代碼:<font size="2">這里放要處理的文字,可用3、4、5等設(shè)置大小</font>

          7、字體顏色代碼:<font color="red">這里放要處理的文字,可以換成blue,yellow等</font>

          8、文字鏈接代碼:<a href="網(wǎng)頁地址">鏈接的文字,在分類欄里用時鏈接的網(wǎng)頁地址必須縮短</a>

          9、移動文字代碼:<marquee>從右到左移動的文字</marquee>

          10、背景音樂代碼:<bgsound loop="-1" src="這里放音樂地址"></bgsound>

          11、圖片附加音樂代碼:<img border=0 src="這里放圖片地址" dynsrc="這里放音樂地址">

          12、浮動圖片代碼:<img alt="1" height="150" src="這里放圖片地址"/>

          公告圖片的代碼:公告掛飾:店鋪分類代碼:背景音樂代碼:換行代碼

          計數(shù)器代碼顏色代碼:

          1白色 #FFFFFF

          2紅色#FF0000

          3綠色#00FF00

          4藍色#0000FF

          5牡丹紅#FF00FF

          6青色 #00FFFF

          7黃色#FFFF00

          8黑色#000000

          9海藍#70DB93

          10巧克力色#5C3317

          11藍紫色 #9F5F9F

          12黃銅色#B5A642

          13亮金色#D9D919

          14棕色#A67D3D

          15青銅色 #8C7853

          162號青銅色 #A67D3D

          17士官服藍色 #5F9F9F

          18冷銅色 #D98719

          19銅色 #B87333

          20珊瑚紅 #FF7F00

          21紫藍色 #42426F

          22深棕 #5C4033

          23深綠 #2F4F2F

          24深銅綠色 #4A766E

          25深橄欖綠 #4F4F2F

          26深蘭花色 #9932CD

          27深紫色 #871F78

          28深石板藍 #6B238E

          29深鉛灰色 #2F4F4F

          30深棕褐色 #97694F

          32深綠松石色 #7093DB

          33暗木色 #855E42

          34淡灰色 #545454

          35土灰玫瑰紅色 #856363

          36長石色 #D19275

          37火磚色#8E2323

          38森林綠 #238E23

          39金色 #CD7F32

          40鮮黃色 #DBDB70

          41灰色 #C0C0C0

          42銅綠色 #527F76

          43青黃色 #93DB70

          44獵人綠 #215E21

          45印度紅 #4E2F2F

          46土黃色 #9F9F5F

          47淺藍色 #C0D9D9

          48淺灰色 #A8A8A8

          49淺鋼藍色 #8F8FBD

          59淺木色 #E9C2A6

          60石灰綠色 #32CD32

          61桔黃色 #E47833

          62褐紅色 #8E236B

          63中海藍色 #32CD99

          64中藍色 #3232CD

          65中森林綠 #6B8E23

          66中鮮黃色 #EAEAAE

          67中蘭花色 #9370DB

          68中海綠色 #426F42

          69中石板藍色 #7F00FF

          70中春綠色 #7FFF00

          71中綠松石色 #70DBDB

          72中紫紅色 #DB7093

          73中木色 #A68064

          74深藏青色 #2F2F4F

          75海軍藍 #23238E

          76霓虹籃 #4D4DFF

          77霓虹粉紅 #FF6EC7

          78新深藏青色 #00009C

          79新棕褐色 #EBC79E

          80暗金黃色 #CFB53B

          81橙色 #FF7F00

          82橙紅色 #FF2400

          83淡紫色 #DB70DB

          84淺綠色 #8FBC8F

          85粉紅色 #BC8F8F

          86李子色 #EAADEA

          87石英色 #D9D9F3

          88艷藍色 #5959AB

          89鮭魚色 #6F4242

          90猩紅色 #BC1717

          91海綠色 #238E68

          92半甜巧克力色 #6B4226

          93赭色 #8E6B23

          94銀色 #E6E8FA

          95天藍 #3299CC

          96石板藍 #007FFF

          97艷粉紅色 #FF1CAE

          98春綠色 #00FF7F

          99鋼藍色 #236B8E

          100亮天藍色 #38B0DE

          101棕褐色 #DB9370

          102紫紅色 #D8BFD8

          103石板藍色 #ADEAEA

          104濃深棕色 #5C4033

          105淡淺灰色 #CDCDCD

          106紫羅蘭色 #4F2F4F

          107紫羅蘭紅色 #CC3299

          108麥黃色#D8D8BF

          109黃綠色 #99CC32

          簡單常用HTML代碼大全(修改網(wǎng)頁必備)

          網(wǎng)頁常用HTML代碼大全

          超鏈接,用的最多:

          點擊在當(dāng)前頁打開網(wǎng)站

          <a >這是我的網(wǎng)站</a>

          效果:這是我的網(wǎng)站

          點擊彈出網(wǎng)站

          <a target="_blank">這是我的網(wǎng)站</a>

          <br>這個是向下一行,比如

          歡迎光臨我的網(wǎng)站<br>希望開心

          演示效果就是:

          歡迎光臨我的網(wǎng)站

          希望開心

          <p>向下一大行,比如

          歡迎光臨我的網(wǎng)站<p>希望開心

          演示效果就是:

          歡迎光臨我的網(wǎng)站

          希望開心

          <b>這是粗體字

          比如 <b >我的網(wǎng)站</ b>

          演示效果:我的網(wǎng)站

          我的網(wǎng)站這是字體的顏色BLUE是藍,RED是紅

          演示

          忽視右鍵

          <body >

          <body style="overflow-y:hidden">

          如何幾秒后轉(zhuǎn)到別的頁面?

          <META. HTTP-EQUIV="Refresh" C>

          點擊關(guān)閉窗口

          <a href="javascript.:top.window.close();">點擊關(guān)閉窗口</a>!

          請問如何去掉主頁右面的滾動條?

          <body scroll="no">

          <body style="overflow-y:hidden">

          如何做到讓一個網(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 >

          這個窗口會在10秒過后自動關(guān)閉,而且不會出現(xiàn)提示. </body>

          如何在不刷新頁面的情況下刷新css?

          <style>

          button{ color:#000000;}

          </style>

          <button nclick=document.styleSheets[0].rules[0].style.color=‘‘‘‘red‘‘‘‘>點擊按鈕直接修改style標簽里button選擇符使按鈕改為紅色</button>

          請問如何讓網(wǎng)頁自動刷新?

          在head部記入<META. HTTP-EQUIV="Refresh" c>其中20為20秒后自動刷新,你可以更改為任意值。

          如何讓頁面自動刷新?

          方法一,用refresh

          HTML 代碼片段如下:

          <head>

          <meta. http-equiv="refresh" c>

          </head>

          5表示刷新時間

          [Ctrl+A 全部選擇 提示:你可先修改部分代碼,再按運行]

          方法二,使用setTimeout控制

          <img src=/logo.gif>

          <script>

          function rl(){

          document.location.reload()

          }

          setTimeout(rl,2000)

          </script>

          如何讓超鏈接沒有下劃線

          在源代碼中的<HEAD>…</HEAD>之間輸入如下代碼:

          <style. type="text/css"> <!--

          a { text-decoration: none}

          --> </style>

          請問如何去掉IE的上下滾動條?

          <body style=‘‘‘‘overflow:scroll;overflow-y:hidden‘‘‘‘>

          </body>

          怎樣才能把RealPlayer文件在網(wǎng)頁做一個試聽連接?

          <embed height=25 src=51js.rm type=audio/x-pn-realaudio-plugin width=50 autostart="false" c>

          如何用html實現(xiàn)瀏覽器上后退按鈕的功能?

          <a href="java script.:history.go(-1)">點擊后退</a>

          或者

          <script> history.back() </script>

          請問怎么在網(wǎng)頁中改變鼠標的箭頭形狀?

          HTML 代碼片段如下:

          <body>

          <a href="#" style="cursor: auto;">auto</a><br>

          <a href="#" style="cursor: crosshair ">crosshair </a><br>

          <a href="#" style="cursor: default ">default </a><br>

          <a href="#" style="cursor: hand ">hand </a><br>

          <a href="#" style="cursor: move ">move </a><br>

          <a href="#" style="cursor: e-resize ">e-resize </a><br>

          <a href="#" style="cursor: ne-resize ">ne-resize </a><br>

          <a href="#" style="cursor: nw-resize">nw-resize</a><br>

          <a href="#" style="cursor: n-resize">n-resize</a><br>

          <a href="#" style="cursor: se-resize">se-resize</a><br>

          <a href="#" style="cursor: sw-resize">sw-resize</a><br>

          <a href="#" style="cursor: s-resize">s-resize</a><br>

          <a href="#" style="cursor: w-resize">w-resize</a><br>

          <a href="#" style="cursor: text">text</a><br>

          <a href="#" style="cursor: wait">wait</a><br>

          <a href="#" style="cursor: help">help</a><br>

          </body>

          怎樣不使用頁面的緩存?即每一次打開頁面時不是調(diào)用緩存中的東西

          <META. HTTP-EQUIV="

          ragma" C>

          頁面打開時自動彈出一個窗口的代碼怎么寫?

          HTML 代碼片段如下:

          <html>

          <head>

          <title>Untitled Document</title>

          <meta. http-equiv="Content-Type" c>

          <script. language="<B style="color:black;background-color:#A0FFFF">javascript</B>">

          <!--

          function MM_openBrWindow(theURL,winName,features) { //v2.0

           window.open(theURL,winName,features);

          }

          //-->

          </script>

          </head>

          <body bgcolor="#FFFFFF" text="#000000" >

          </body>

          </html>

          如何讓我的頁面出現(xiàn)一個會講話的小人?Merlin

          HTML 代碼片段如下:

          <HTML>

          <HEAD>

          <TITLE>默林</TITLE>

          <META. http-equiv=Content-Type c>

          </HEAD>

          <BODY>

          <p><OBJECT id=sims classid=CLSID

          45FD31B-5C6E-11D1-9EC1-00C04FD7081F>

           </OBJECT>

           <SCRIPT>

          var MerlinID;

          var MerlinACS;

          sims.Connected = true;

          MerlinLoaded = LoadLocalAgent(MerlinID, MerlinACS);

          Merlin = sims.Characters.Character(MerlinID);

          Merlin.Show();

          Merlin.Play("Surprised");

          Merlin.Speak("大家好");

          Merlin.Play("GestureLeft");

          Merlin.Think("我是默林!");

          Merlin.Play("

          leased");

          Merlin.Think("可愛嗎?");

          Merlin.Play("GestureDown");

          Merlin.Speak("哈哈!");

          Merlin.Hide();

          function LoadLocalAgent(CharID, CharACS){

          LoadReq = sims.Characters.Load(CharID, CharACS);

          return(true);

          }

          </SCRIPT>

          </p>

          <p> </p>

          <p>看此效果必須裝有office2000!!!</p>

          </BODY>

          </HTML>

          在頁面中如何加入不是滿鋪的背景圖片,拉動頁面時背景圖不動

          HTML 代碼片段如下:

          <html><head>

          <STYLE>

          body  {background-image:url(logo.gif);

          background-repeat:no-repeat; background-position:center }

          </STYLE>

          </head>

          <body bgproperties="fixed" >

          </body>

          </html>

          [Ctrl+A 全部選擇 提示:你可先修改部分代碼,再按運行]

          background-repeat:no-repeat; 是讓背景圖不占滿整個頁面

          body bgproperties="fixed" 是拉動scroll時背景圖不動

          文本輸入框什么屬性能實現(xiàn)不可輸入?

          HTML 代碼片段如下:

          <input type="text" name="textfield" disabled>

          或者

          <input type="text" name="textfield" readonly>

          如何禁止自己的頁面在別人的框架里打開?

          把以下代碼加至你的<head>區(qū)

          <script>

          if (window.top!=self){

          window.top.location=self.location

          }

          </script>

          如何實現(xiàn)首頁全屏幕顯示?

          HTML 代碼片段如下:

          <html>

          <body><script. language="<B style="color:black;background-color:#A0FFFF">javascript</B>">

          var coolw=642

          var coolh=400

          var coolhuang=window.open("http://www.51js.com","coolhuang","width="+coolw+",height="+coolh+",

          fullscreen=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0")

          window.close()

          </script></body></html>

          如何監(jiān)聽一個窗口被關(guān)閉了?

          HTML 代碼片段如下:

          <body >

          如何禁止Ctrl+N?

          HTML 代碼片段如下:

          <body nkeydown=return(!(event.keyCode==78&&event.ctrlKey))>

          如何把頁面加入用戶的收藏夾?

          HTML 代碼片段如下:

          <a href="<B style="color:black;background-color:#A0FFFF">javascript</B>:window.external.AddFavorite(‘‘‘‘http://www.51js.com‘‘‘‘,‘‘‘‘無憂腳本‘‘‘‘)">收藏?zé)o憂腳本</a>

          如何在我的頁面中加入背景音樂?

          IE: <bgsound src="*.mid" loop=infinite>

          NS:<embed src="*.mid" autostart=true hidden=true loop=true>

          *.mid你的背景音樂的midi格式文件

          關(guān)于頁面轉(zhuǎn)換效果

          <meta. http-equiv="page-enter" c>

          <meta. http-equiv="page-exit" c>

          說明:Transition=23是隨機效果,另可以選0-22任一數(shù)字固定某個效果

          如何設(shè)定打開頁面的大小

          HTML 代碼片段如下:

          <body ><!--(width,height)-->

          怎樣雙擊滾屏,單擊停止?

          HTML 代碼片段如下:

          <html>

          <head>

          <title>新網(wǎng)頁1</title>

          </head>

          <body>

          <script. language"<B style="color:black;background-color:#A0FFFF">javascript</B>">

          var currentpos,timer;

          function initialize()

          {

          timer=setInterval("scrollwindow()",10);

          }

          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>

          <p>a</p><p>a</p><p>a</p><p>aa</p><p>aa</p><p>aa</p>

          <p>aa</p><p>aa</p><p>aa</p><p>aa</p><p>aa</p><p>aa</p>

          <p>aa</p><p>aa</p><p>aa</p><p>aa</p><p>aa</p><p>aa</p>

          <p>aa</p><p>aa</p><p>aa</p><p>aa</p><p>a</p>

          </body>

          </html>

          如何讓body中的文字不被選中?

          HTML 代碼片段如下:

          <body >aaa</body>

          如何讓彈出的窗口不能關(guān)閉?

          在新開的窗口中加入如下代碼

          <body nunload=open(location.href)>

          </body>

          如何讓瀏覽器在保存頁面時保存失敗?

          HTML 代碼片段如下:

          <NOSCRIPT>

          <<B style="color:black;background-color:#ffff66">IFRAME</B> SRC="*.html">

          </<B style="color:black;background-color:#ffff66">IFRAME</B>>

          </NOSCRIPT>

          表單中如何用圖片按鈕實現(xiàn) reset?

          <html>

          <head>

          <script>

          function aaa(){

          document.forms[0].reset()

          }

          </script>

          </head>

          <body>

          <form>

          <textarea rows="2" name="S1" cols="20"></textarea>

          <input type="submit" values="提交" name="B1">

          <image src="logo.gif" nclick=aaa()>

          </form>

          </body></html>

          進入網(wǎng)頁時彈出的信息對話框

          <body >

          關(guān)閉窗口后彈出對話框

          <body >

          告別提示

          <body nUnload= alert("再見,感謝你的訪問!")>

          只要你肯干,沒有什么不能成功的.

          1。忽視右鍵

            <body ncontextmenu="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="#"

            nclick="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。隨機替換圖片

            <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>標內(nèi)加入如:<body nload="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 nload="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. ncontextmenu="window.event.returnValue=false" 將徹底屏蔽鼠標右鍵

          <table border ncontextmenu=return(false)><td>no</table> 可用于Table

          17. <body nselectstart="return false"> 取消選取、防止復(fù)制

          18.onpaste="return false" 不準粘貼

          19.oncopy="return false;" ncut="return false;" 防止復(fù)制

          20. <link rel="Shortcut Icon" href="favicon.ico"> IE地址欄前換成自己的圖標

          21. <link rel="Bookmark" href="favicon.ico"> 可以在收藏夾中顯示出你的圖標

          22. <input style="ime-mode:disabled"> 關(guān)閉輸入法

          23. 永遠都會帶著框架

          <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.刪除時確認

          <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="#" nFocus="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 nload="top.resizeTo(300,200);">

          打開頁面的位置<body nload="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 npropertychange="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" nclick="checkme()">

          </BODY></HTML>

          43.腳本永不出錯

          <SCRIPT. LANGUAGE="JavaScript">

          <!-- Hide function killErrors(){return true;} window.onerror = killErrors; // -->

          </SCRIPT>

          44.ENTER鍵可以讓光標移到下一個輸入框

          <input nkeydown="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. 各種樣式的光標

          auto :標準光標

          default :標準箭頭

          hand :手形光標

          wait :等待光標

          text :I形光標

          vertical-text :水平I形光標

          no-drop :不可拖動光標

          not-allowed :無效光標

          help :?幫助光標

          all-scroll :三角方向標

          move :移動標

          crosshair :十字標

          e-resize

          n-resize

          nw-resize

          w-resize

          s-resize

          se-resize

          sw-resize

          47、禁止鼠標右鍵,把Demo的圖片全都設(shè)為表格的背景,表格的大小與圖片的大小一樣。這樣做看起來是一樣的,主要是防止鼠標經(jīng)過圖片時會出現(xiàn)另存的按鈕。禁止鼠標右鍵的代碼很簡單:<script. LANGUAGE="JavaScript"> function click() { if (event.button==2) {alert('呵呵,不好意思,你甭想使用右鍵下載圖片:)'); } } document.onmousedown=click</script>

          1. 怎 樣 定 義 網(wǎng) 頁 語 言( 字 符 集)?

          ----在 制 作 網(wǎng) 頁 過 程 中, 你 首 先 要 定 義 網(wǎng) 頁 語 言, 以 便 訪 問 者 瀏 覽 器 自 動 設(shè) 置 語 言, 而 我 們 用 所 見 即 所 得 的HTML 工 具 時, 都 沒 有 注 意 到 這 個 問 題, 因 為 它 是 默 認 設(shè) 置。 要 設(shè) 置 的 語 言 可 以 在HTML 代 碼 狀 態(tài) 下 找 到:

          $#@60; meta http -equiv="Content Type" content="text/html; charset=gb2312" $#@62;

          ----把charset=gb2312 改 換 成 其 它 語 言 代 碼 即 可, 比 如 英 文:charset=en.

          2. 怎 樣 防 止 別 人 把 你 的 網(wǎng) 頁 放 到 框 架 里?

          ----因 為 框 架(frame) 的 緣 故, 有 許 多 人 把 別 人 的 網(wǎng) 頁 放 置 到 自 己 的 框 架 里, 使 之 成 為 自 己 的 一 頁。 如 果你 要 防 止 別 人 這 樣 做, 可 以 加 入 下 列JavaScript 代 碼 即 可, 它 會 自 動 監(jiān) 測, 然 后 跳 出 別 人 的 框 架。

          $#@60; script language="javascript" $#@62;

          ??if (self != top) { top.location = self.location; }

          $#@60; /script $#@62;

          3. 怎 樣 設(shè) 置 字 體?

          ----在 制 作 網(wǎng) 頁 過 程 中, 大 家 都 喜 歡 使 用 漂 亮 的 字 體。 但 是, 如 果 訪 客 瀏 覽 器 沒 有 安 裝 同 樣 的 字 體, 看 到你 的 網(wǎng) 頁 會 是 很 普 通 的 字 體。 如 何 防 止 這 種 情 況 出 現(xiàn) 呢? 大 家 知 道 字 體 設(shè) 置 的 標 簽 是Font, 而 它 有 個 屬性 是Face, 該 屬 性 是 定 義 字 體 的, 你 可 以 這 樣 設(shè) 置:, 訪 客 的 瀏 覽 器 就 會 按 照Face 定 義 的 字 體 順 序 設(shè) 置 已 安裝 的 字 體。 目 前 動 態(tài) 主 頁 有 種 技 術(shù), 可 以 把 字 體 信 息 用 向 量 格 式 存 儲, 然 后 利 用 訪 客 本 身 機 器 含 有 的 公共 信 息 庫 把 字 體 快 速 的 組 裝 起 來, 這 樣, 就 不 用 擔(dān) 心 訪 客 是 否 安 裝 有 某 種 字 體 了。

          4. 怎 樣 在 網(wǎng) 頁 中 加 入 注 釋?

          ----在 共 同 開 發(fā) 網(wǎng) 頁 中, 加 入 注 釋 是 防 止 分 工 被 搞 混 淆 或 者 注 釋 某 段 代 碼 特 殊 的 含 加 入 注 釋 的 格 式 是:

          $#@60; ! - - Microsoft FrontPage 3.0 - - $#@62;。

          5. 怎 樣 測 試 瀏 覽 器 并 自 動 裝 入 所 需 要 的 網(wǎng) 頁?

          ----目 前 微 軟 和 網(wǎng) 景 的 瀏 覽 器 并 不 能 完 全 兼 容 所 有 網(wǎng) 頁, 有 的 在 某 種 瀏 覽 器 里 非 常 漂 亮, 而 用 其 它 瀏 覽 器查 看 時 卻 一 團 糟。 如 果 你 需 要 測 試 瀏 覽 器, 可 以 加 入 以 下JavaScript 代 碼 并 保 存 單 獨 一 個 網(wǎng) 頁:

          $#@60; script LANGUAGE="JavaScript" $#@62;

          function TestBrowser(){

          ie = ((navigator.appName ==

          "Microsoft Internet Explorer") & &

          (parseInt(navigator.appVersion) $#@62;= 3 ))

          ns = ((navigator.appName == "Netscape") & &

          (parseInt(navigator.appVersion) $#@62;= 3 ))

          if (ns) {

          setTimeout(location.href="nn4.htm",10);

          } else {

          setTimeout(location.href="ie4.htm",10);

          }

          }

          $#@60; /script $#@62;

          實 例 請 參 考:

          http://www.netease.com/~tiantao/test.htm

          6. 怎 樣 讓 鏈 接 沒 有 下 劃 線?

          ----只 要 在 加 入 以 下 代 碼, 所 有 鏈 接 就 都 沒 有 下 劃 線 了:

          $#@60; style type="text/css" $#@62;

          $#@60; ! - -

          A{text -transform: none;

          text -decoration: none ;}

          a:hover { text -decoration:underline }

          - - $#@62;

          $#@60; /style $#@62;

          7. 怎 樣 在 網(wǎng) 頁 中 加 入E-mail 鏈 接 并 顯 示 預(yù) 定 的 主 題?

          A HREF=mailto:lovett@163.net?subject=test

          8. 怎 樣 讓 背 景 圖 像 不 滾 動?

          ----Internet Explorer 瀏 覽 器 支 持 一 個Body 屬 性Bgproperties, 它 可 以 讓 背 景 不 滾 動。

          $#@60; Body Background="c98.gif" Bgproperties="fixed" $#@62;

          9. 怎 樣 評 定 網(wǎng) 頁 的 級 別?

          ----在IE4.0 瀏 覽 器 中, 有 一 項 功 能 是 過 濾 網(wǎng) 站 的, 一 些 受 限 制 的 網(wǎng) 站 被 過 濾 掉, 而 該 網(wǎng) 站 必 須 被RSAC( 美 國娛 樂 委 員 會) 評 定 了 級 別IE4.0 才 能 過 濾, 如 果 你 要 評 級 可 以 在 網(wǎng) 頁 中 加 入 以 下 代 碼:

          $#@60; meta http -equiv="PICS -Label"????

          content=(PICS -1.1 "http://www.rsac.org/ratingsv01.html"

          ??l gen true comment "RSACi North America Server"

          ??for "http://youHostname"

          ??on "1998.11.26GMT08:15 ?0500"

          ??r (n 0 s 0 v 0 l 0))$#@62;

          10. 怎 樣 定 義 本 網(wǎng) 頁 的 關(guān) 鍵 字?

          ----在 網(wǎng) 頁 中 加 入 關(guān) 鍵 字, 可 以 供 某 些 搜 索 站 臺 機 器 人 的 使 用, 它 們 會 利 用 該 關(guān) 鍵 字 為 你 的 網(wǎng) 站 做 索 引, 這樣, 當(dāng) 別 人 用 關(guān) 鍵 字 搜 索 網(wǎng) 站 時, 如 果 你 的 網(wǎng) 頁 包 含 該 關(guān) 鍵 字, 那 么 就 可 以 被 列 出 了, 定 義 本 網(wǎng) 頁 關(guān) 鍵 字, 可 以 加 入 以 下 代 碼:

          ----$#@60; meta name="Keywords" content="china,enterprise,business,net" $#@62;

          ----Content 所 包 含 的 就 是 關(guān) 鍵 字, 你 可 以 自 行 設(shè) 置。

          ----這 里 有 個 技 巧, 你 可 以 重 復(fù) 某 一 個 單 詞, 這 樣 可 以 提 高 自 己 網(wǎng) 站 的 排 行 位 置, 如:

          ----$#@60; meta name="Keywords" CONTENT="china,china,china,china" $#@62;

          11. 怎 樣 鏈 接 本 網(wǎng) 頁 的 對 象?

          ----有 時 鏈 接 發(fā) 生 在 一 個 網(wǎng) 頁 里, 比 如 頁 面 上 半 部 分 列 出 了 目 錄, 下 部 分 就 列 出 了 內(nèi) 容, 而 單 擊 目 錄 任 何 一個 項 目 都 可 以 跳 到 指 定 部 分, 可 以 在 要 被 鏈 接 的 內(nèi) 容 部 分 設(shè) 置 如 下 方 式:

          $#@60; A NAME=" #t1" $#@62;$#@60; /A $#@62;

          而 要 鏈 接 到 以 上 設(shè) 置 的 部 分, 可 以 如 下 編 制:

          $#@60; A HREF="index.htm #t1" $#@62;t1$#@60; /A $#@62;

          12. 怎 樣 為 不 支 持 框 架 結(jié) 構(gòu) 的 瀏 覽 器 指 定 內(nèi) 容?

          ----為 了 防 止 不 支 持 框 架 結(jié) 構(gòu) 的 瀏 覽 器 訪 問 你 的 網(wǎng) 頁, 可 以 在 你 的 網(wǎng) 頁 中 加 入 以 下 內(nèi) 容:

          $#@60; body $#@62;

          $#@60; noframes $#@62;

          本 網(wǎng) 頁 是 框 架 結(jié) 構(gòu), 請 下 載 新 的 瀏 覽 器 瀏 覽

          $#@60; /noframes $#@62;

          $#@60; /body $#@62;

          13. 怎 樣 刪 除 表 格 邊 框?

          ----有 時 需 要 刪 除 表 格 的 邊 框, 你 可 以 把Border 設(shè) 置 為 如 下 代 碼:

          $#@60; body $#@62;

          $#@60; table border="0" width="100 %" $#@62;

          $#@60; tr $#@62;

          $#@60; td width="100 %" $#@62;$#@60; /td $#@62;

          $#@60; /tr $#@62;

          $#@60; /table $#@62;

          $#@60; /body $#@62;

          14. 怎 樣 隱 藏 在 狀 態(tài) 欄 里 出 現(xiàn) 的LINK 信 息?

          ----大 家 知 道, 當(dāng) 你 指 向 一 個 鏈 接 時, 該 鏈 接 的 信 息 會 出 現(xiàn) 在 瀏 覽 器 狀 態(tài) 欄 里, 如 果 需 要 隱 藏 信 息, 可 以 如 下設(shè) 置:

          $#@60; a onMouseOver="window.status=none ;

          return true" $#@62;test$#@60; /a $#@62;

          15. 怎 樣 在 網(wǎng) 頁 中 加 入 多 媒 體 文 件?

          ----有 些 多 媒 體 文 件 無 需 其 他 程 序 就 可 以 播 放, 而 有 許 多 多 媒 體 文 件 需 要 外 部 程 序 的 幫 助, 當(dāng) 瀏 覽 器 下 載不 支 持 的 格 式 時 會 調(diào) 用 外 部 程 序。 如 果 瀏 覽 器 沒 有 安 裝 這 種 外 部 程 序, 那 么 瀏 覽 器 會 自 動 去 下 載; 如 果你 需 要 加 入 多 媒 體 格 式, 可 設(shè) 置 如 下 代 碼:

          $#@60; EMBED SRC="tt.ram" AUTOSTART="TRUE" LOOP="2" WIDTH="80" HEIGHT="30" $#@62;

          ----對 于 不 支 持EMBED 標 簽 的 瀏 覽 器, 可 以 改 用 標 簽。

          16. 怎 樣 在 網(wǎng) 頁 中 加 入 電 子 郵 件 表 單 提 交?

          ----表 單 提 交 需 要CGI 程 序 的 支 持, 但 你 也 可 以 利 用E ?mail 提 交, 當(dāng) 你 設(shè) 計 好 表 單 后, 把Action 內(nèi) 容 加 入 郵 件地 址 即 可, 如 下:

          form method="POST" action="mailto:lovett@163.net" ENCTYPE="text/plain"$#@62;

          17. 怎 樣 隱 藏 熱 訊 分 析 的 圖 標?

          ----熱 訊 分 析 是 許 多 網(wǎng) 友 使 用 的 服 務(wù), 它 能 幫 助 你 分 析 網(wǎng) 站 的 流 量, 如 果 你 想 隱 藏 該 服 務(wù) 圖 標, 可 以 把 服 務(wù)代 碼 中 的 width=88 height=31 都 改 為1 即 可。

          18. 怎 樣 在 網(wǎng) 頁 中 加 入 最 后 修 改 日 期?

          ----在 中 加 入 以 下 代 碼 即 可:

          $#@60; Script Language="Java Script" $#@62;

          document.write

          (" 最 后 修 改 日 期" +document.lastModified);

          $#@60; /Script $#@62;


          主站蜘蛛池模板: 国产成人高清亚洲一区91| 亚洲综合在线成人一区| 日韩高清一区二区三区不卡 | 色婷婷香蕉在线一区二区| 亚洲综合色自拍一区| 午夜无码视频一区二区三区| 日韩电影一区二区| 一区高清大胆人体| 在线播放一区二区| 波多野结衣一区视频在线| 久久婷婷色一区二区三区| 国精产品一区二区三区糖心| 国产激情无码一区二区app| 中文字幕一区二区人妻性色| 亚洲成AV人片一区二区密柚| 果冻传媒董小宛一区二区| 亚洲电影一区二区三区| 久久久精品人妻一区二区三区蜜桃| 亚洲国产精品自在线一区二区| 无码少妇一区二区| 日韩一区二区三区视频久久| 精品乱子伦一区二区三区高清免费播放| 国产精品区AV一区二区| 亚洲AV美女一区二区三区| 国产成人久久精品一区二区三区 | 精品人妻中文av一区二区三区| 中文字幕精品亚洲无线码一区应用 | 一区二区三区在线免费看| 国产一区二区免费| 竹菊影视欧美日韩一区二区三区四区五区 | 亚洲国产成人久久综合一区| 亚洲AV无码一区二区三区电影 | 国产日韩一区二区三区在线播放| 成人丝袜激情一区二区| 综合久久一区二区三区| 国产精品成人免费一区二区 | 国产无线乱码一区二三区| 人妻无码一区二区三区AV| 一区二区三区影院| 国产一区二区三区在线| 国产一区二区三区影院|