溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

怎么用純HTML做出實(shí)用網(wǎng)頁效果

發(fā)布時(shí)間:2022-03-05 15:50:29 來源:億速云 閱讀:285 作者:iii 欄目:web開發(fā)

這篇“怎么用純HTML做出實(shí)用網(wǎng)頁效果”文章的知識點(diǎn)大部分人都不太理解,所以小編給大家總結(jié)了以下內(nèi)容,內(nèi)容詳細(xì),步驟清晰,具有一定的借鑒價(jià)值,希望大家閱讀完這篇文章能有所收獲,下面我們一起來看看這篇“怎么用純HTML做出實(shí)用網(wǎng)頁效果”文章吧。

1. 折疊手風(fēng)琴

使用Details和Summary標(biāo)簽可以創(chuàng)建沒有JavaScript代碼的可折疊手風(fēng)琴。

效果:

 怎么用純HTML做出實(shí)用網(wǎng)頁效果

HTML

<details>
<summary>Languages Used</summary>
<p>This page was written in HTML and CSS. The CSS was compiled from SASS. Regardless, this could all be done in plain HTML and CSS</p>
</details>

<details>
<summary>How it Works</summary>
<p>Using the sibling and checked selectors, we can determine the styling of sibling elements based on the checked state of the checkbox input element. </p>
</details>

CSS

* {
    font-size: 1rem;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
details {
    border: 1px solid #aaa;
    border-radius: 4px;
    padding: .5em .5em 0;
}

summary {
    font-weight: bold;
    margin: -.5em -.5em 0;
    padding: .5em;
}

details[open] {
    padding: .5em;
}

details[open] summary {
    border-bottom: 1px solid #aaa;
    margin-bottom: .5em;
}

瀏覽器支持:

怎么用純HTML做出實(shí)用網(wǎng)頁效果

2. 進(jìn)度條

該Meter和Progress 的元素標(biāo)簽的基礎(chǔ)上,你可以調(diào)整屬性呈現(xiàn)在屏幕上的進(jìn)度條。進(jìn)步有兩個(gè)屬性:max和value校準(zhǔn)進(jìn)度條,而Meter標(biāo)簽提供了更多的定制屬性。

效果:

怎么用純HTML做出實(shí)用網(wǎng)頁效果

HTML:

<label for="upload">Upload progress:</label>

<meter id="upload" name="upload"
       min="0" max="100"
       low="33" high="66" optimum="80"
       value="50">
    at 50/100
</meter>

<hr/>

<label for="file">File progress:</label>

<progress id="file" max="100" value="70"> 70% </progress>

CSS:

body {
  margin: 50px;
}

label {
    padding-right: 10px;
    font-size: 1rem;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

瀏覽器支持:

怎么用純HTML做出實(shí)用網(wǎng)頁效果

3. 更多輸入類型

在定義輸入元素時(shí),您要知道現(xiàn)代瀏覽器已經(jīng)允許您指定足夠多的輸入類型了。除了你應(yīng)該已經(jīng)知道text,email,password,number這些類型外,還有下面的這些。

  • date 將顯示本機(jī)日期選擇器

  • datetime-local 更豐富的日期和時(shí)間選擇器

  • month 友好的月份選擇器

  • tel會(huì)讓你輸入一個(gè)電話號碼。在移動(dòng)瀏覽器上打開它,彈出的鍵盤將發(fā)生變化,同樣的email也是如此。

  • search 將輸入文本框設(shè)置為友好的搜索樣式。

效果:

怎么用純HTML做出實(shí)用網(wǎng)頁效果

HTML:

<label for="date">Enter date:</label>
<input type="date" id="date"/>

<label for="datetime">Enter date & time:</label>
<input type="datetime-local" id="datetime"/>

<label for="month">Enter month:</label>
<input type="month" id="month"/>

<label for="search">Search for:</label>
<input type="search" id="search"/>

<label for="tel">Enter Phone:</label>
<input type="tel" id="tel">

CSS:

input, label {display:block; margin: 5px;}
input {margin-bottom:18px;}

各種新輸入類型的MDN文檔非常廣泛且信息量很大。此外,檢查移動(dòng)輸入類型以了解用戶在移動(dòng)瀏覽器上時(shí)這些輸入元素的鍵盤行為。

4. 視頻和音頻

video和audio元素雖然現(xiàn)在已經(jīng)成為HTML規(guī)范的一部分,但是你一樣會(huì)驚訝于你可以使用video標(biāo)簽在屏幕上渲染出一個(gè)體面的視頻播放器。

<video controls>

    <source src="https://addpipe.com/sample_vid/short.mp4" 
            poster="https://addpipe.com/sample_vid/poster.png">

    Sorry, your browser doesn't support embedded videos.
</video

視頻標(biāo)記中值得注意的一些屬性包括:

  • poster 下載視頻時(shí)要顯示封面的URL

  • preload 是否在頁面加載時(shí)預(yù)加載整個(gè)視頻

  • autoplay 視頻是否應(yīng)該在頁面加載后自動(dòng)播放

瀏覽器支持:

 怎么用純HTML做出實(shí)用網(wǎng)頁效果

5. 校對文本

當(dāng)你想顯示歷史編輯及校對的情況時(shí),blockquote,del和ins元素標(biāo)簽可以派上用場了。

示例:

怎么用純HTML做出實(shí)用網(wǎng)頁效果

 HTML:

<blockquote>
    There is <del>nothing</del> <ins>no code</ins> either good or bad, but <del>thinking</del> <ins>running it</ins> makes it so.
</blockquote>

CSS:

del {
    text-decoration: line-through;
    background-color: #fbb;
    color: #555;
}

ins {
    text-decoration: none;
    background-color: #d4fcbc;
}

blockquote {
    padding-left: 15px;
    line-height: 30px;
    border-left: 3px solid #d7d7db;
    font-size: 1rem;
    background: #eee;
    width: 200px;
}

6.更統(tǒng)一的引號

由于中英文引號的不同,使用<q>標(biāo)記可以讓您很好的解決這個(gè)問題,它可使你的內(nèi)容在大多數(shù)瀏覽器上更一致地呈現(xiàn)引號。

 怎么用純HTML做出實(shí)用網(wǎng)頁效果

 HTML:

Don Corleone said <q cite="https://www.imdb.com/title/tt0068646/quotes/qt0361877">I'm gonna make him an offer he can't refuse. Okay? I want you to leave it all to me. Go on, go back to the party.</q></p>


<hr/>

Don Corleone said <i>"I'm gonna make him an offer he can't refuse. Okay? I want you to leave it all to me. Go on, go back to the party."</i>

CSS:

body {
  margin: 50px;
}

q {
    font-style: italic;
    color: #000000bf;
}

7. 鍵盤標(biāo)簽

<kbd>標(biāo)簽應(yīng)該是一個(gè)少為人知的冷門標(biāo)簽,但這個(gè)能使用更好的方式來說明組合鍵的樣式。

怎么用純HTML做出實(shí)用網(wǎng)頁效果

 HTML:

<p>I know that <kbd>CTRL</kbd>+<kbd>C</kbd> and <kbd>CTRL</kbd>+<kbd>V</kbd> a are like the most used key combinations</p>

CSS:

body {
  margin: 50px;
}

kbd {
    display: inline-block;
    margin: 0 .1em;
    padding: .1em .6em;
    font-size: 11px;
    line-height: 1.4;
    color: #242729;
    text-shadow: 0 1px 0 #FFF;
    background-color: #e1e3e5;
    border: 1px solid #adb3b9;
    border-radius: 3px;
    box-shadow: 0 1px 0 rgba(12,13,14,0.2), 0 0 0 2px #FFF inset;
    white-space: nowrap;
}

8.使用HTML共享代碼

使用figcaption pre code標(biāo)簽,您可以使用純HTML和CSS呈現(xiàn)出不錯(cuò)的代碼片段。

怎么用純HTML做出實(shí)用網(wǎng)頁效果

HTML:

<figure>
  <figcaption>
      Defining a css <code>color</code> property for a class called 'golden'
  </figcaption>
  
  <pre>
    <code>
      .golden {
        color: golden;
      }
    </code>
  </pre>
</figure>

CSS:

pre {
  background-color: #ffbdbd;
}

以上就是關(guān)于“怎么用純HTML做出實(shí)用網(wǎng)頁效果”這篇文章的內(nèi)容,相信大家都有了一定的了解,希望小編分享的內(nèi)容對大家有幫助,若想了解更多相關(guān)的知識內(nèi)容,請關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI