1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務(wù)時(shí)間:8:30-17:00
      你可能遇到了下面的問題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
      HTML怎么實(shí)現(xiàn)移動(dòng)端固定懸浮半透明搜索框

      本文將為大家詳細(xì)介紹“HTML怎么實(shí)現(xiàn)移動(dòng)端固定懸浮半透明搜索框”,內(nèi)容步驟清晰詳細(xì),細(xì)節(jié)處理妥當(dāng),而小編每天都會(huì)更新不同的知識(shí)點(diǎn),希望這篇“HTML怎么實(shí)現(xiàn)移動(dòng)端固定懸浮半透明搜索框”能夠給你意想不到的收獲,請(qǐng)大家跟著小編的思路慢慢深入,具體內(nèi)容如下,一起去收獲新知識(shí)吧。

      目前成都創(chuàng)新互聯(lián)已為上千家的企業(yè)提供了網(wǎng)站建設(shè)、域名、虛擬空間、成都網(wǎng)站托管、企業(yè)網(wǎng)站設(shè)計(jì)、定邊網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。

      html是什么

      html的全稱為超文本標(biāo)記語言,它是一種標(biāo)記語言,包含了一系列標(biāo)簽.通過這些標(biāo)簽可以將網(wǎng)絡(luò)上的文檔格式統(tǒng)一,使分散的Internet資源連接為一個(gè)邏輯整體,html文本是由html命令組成的描述性文本,html命令可以說明文字,圖形、動(dòng)畫、聲音、表格、鏈接等,主要和css+js配合使用并構(gòu)建優(yōu)雅的前端網(wǎng)頁。

      現(xiàn)在互聯(lián)網(wǎng)已經(jīng)有成千上百個(gè)網(wǎng)站,然而網(wǎng)站少不了的一個(gè)功能就是搜索,我們可以看到很多網(wǎng)站的搜索框各有不同,在移動(dòng)端也是如此,例如:

      HTML怎么實(shí)現(xiàn)移動(dòng)端固定懸浮半透明搜索框

      要制作這樣的搜索框,技術(shù)關(guān)鍵在于:

      fixed 搜索框定位

      opacity 設(shè)置透明度

      Solution. 解決

      首先我們定義一個(gè) html 片段:

      
      
        
          
            
            搜索
          

           

      header 標(biāo)簽為搜索框,下面的 p 為一個(gè)背景圖。

      同時(shí)附上 CSS 樣式:

      
      body {
        margin: 0;  padding: 0;
        font-size: 14px; font-family: "microsoft yahei",'Arial', 'Verdana','Helvetica', sans-serif;
      }
      .bar {
        position: fixed; top: 0; left: 0; right: 0; /* 決定了搜索框置頂 */
        height: 44px; padding: 0 10px;
        background-color: #fff; opacity: 0.8; /* 搜索框半透明效果 */
        z-index: 10;
      }
      .bar form {
        display: block; padding: 0;margin: 0;
      }
      .search-row {
        position: relative;
        height: 30px; padding: 7px 0;
      }
      .search-row input[type=search] {
        position: absolute; top: 7px;
        height: 30px; line-height: 21px; width: 100%; padding: 10px 15px 10px 30px;
        border: 0; border-radius: 6px; outline: 0; background-color: rgba(0,0,0,0.1);
        font-size: 16px; text-align: center;
        z-index: 100;
      }
      .search-row .placeholder {
        position: absolute; top: 2px; left: 0; right: 0;
        display: inline-block; height: 34px; line-height: 34px;
        border: 0; border-radius: 6px;
        font-size: 16px; text-align: center; color: #999;
        z-index: 1;  
      }
      .search-row .placeholder .iconfont {
        display: inline-block; width: 19px; line-height: 24px; padding: 10px 0; 
        font-size: 21px; color: #666;
      }
      .search-row .placeholder .text {
        line-height: 40px;
        vertical-align: top;
      }
      .background img {
        width: 100%;
      }
      .active:before {
        position: absolute; top: 11px; left: 5px; right: auto;
        display: block; margin-right: 0;
        font-size: 21px;
      }
      .active input[type=search] {
        text-align: left
      }
      .active .placeholder{
        display: none
      }
      

      很長的一段 CSS 樣式,但是其核心就兩句話position: fixed; /* 決定了搜索框置頂 */ 和 background-color: #fff; opacity: 0.8; /* 搜索框半透明效果 */,其他的樣式均為了頁面的排版,排版的細(xì)節(jié)需要各位讀者自己寫一遍理解,過程可能需要花費(fèi)點(diǎn)時(shí)間。

      這樣我們就完成了一個(gè)靜態(tài)的搜索框:

      HTML怎么實(shí)現(xiàn)移動(dòng)端固定懸浮半透明搜索框

      備注:這里的搜索圖標(biāo)使用了 iconfont,讀者可自行到 iconfont矢量圖標(biāo)庫 下載。

      至此,我們還需要通過 JS 實(shí)現(xiàn)一些動(dòng)效:

      HTML怎么實(shí)現(xiàn)移動(dòng)端固定懸浮半透明搜索框

      用于實(shí)現(xiàn)用戶切換輸入時(shí)「搜索」位置圖標(biāo)的切換,原理很簡單,增加和移除 class 類,這些類定義了樣式。

      .active:before {
        position: absolute; top: 11px; left: 5px; right: auto;
        display: block; margin-right: 0;
        font-size: 21px;
      }
      .active input[type=search] {
        text-align: left
      }
      .active .placeholder{
        display: none
      }
      

      備注:這里需要引入 jQuery,千萬別忘了!

      Extension. 擴(kuò)展

      完整 html 代碼:

      
      
      
      
      
      
      
      
      body {
        margin: 0;  padding: 0;
        font-size: 14px; font-family: "microsoft yahei",'Arial', 'Verdana','Helvetica', sans-serif;
      }
      .bar {
        position: fixed; top: 0; left: 0; right: 0; /* 決定了搜索框置頂 */
        height: 44px; padding: 0 10px;
        background-color: #fff; opacity: 0.8; /* 搜索框半透明效果 */
        z-index: 10;
      }
      .bar form {
        display: block; padding: 0;margin: 0;
      }
      .search-row {
        position: relative;
        height: 30px; padding: 7px 0;
      }
      .search-row input[type=search] {
        position: absolute; top: 7px;
        height: 30px; line-height: 21px; width: 100%; padding: 10px 15px 10px 30px;
        border: 0; border-radius: 6px; outline: 0; background-color: rgba(0,0,0,0.1);
        font-size: 16px; text-align: center;
        z-index: 100;
      }
      .search-row .placeholder {
        position: absolute; top: 2px; left: 0; right: 0;
        display: inline-block; height: 34px; line-height: 34px;
        border: 0; border-radius: 6px;
        font-size: 16px; text-align: center; color: #999;
        z-index: 1;  
      }
      .search-row .placeholder .iconfont {
        display: inline-block; width: 19px; line-height: 24px; padding: 10px 0; 
        font-size: 21px; color: #666;
      }
      .search-row .placeholder .text {
        line-height: 40px;
        vertical-align: top;
      }
      .background img {
        width: 100%;
      }
      .active:before {
        position: absolute; top: 11px; left: 5px; right: auto;
        display: block; margin-right: 0;
        font-size: 21px;
      }
      .active input[type=search] {
        text-align: left
      }
      .active .placeholder{
        display: none
      }
      
      
      
      
      
        
          
            
            搜索
          

           

      如果你能讀到這里,小編希望你對(duì)“HTML怎么實(shí)現(xiàn)移動(dòng)端固定懸浮半透明搜索框”這一關(guān)鍵問題有了從實(shí)踐層面最深刻的體會(huì),具體使用情況還需要大家自己動(dòng)手實(shí)踐使用過才能領(lǐng)會(huì),如果想閱讀更多相關(guān)內(nèi)容的文章,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!


      當(dāng)前名稱:HTML怎么實(shí)現(xiàn)移動(dòng)端固定懸浮半透明搜索框
      網(wǎng)站地址:http://www.ef60e0e.cn/article/pcpsee.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        常州市| 会理县| 绥德县| 上饶市| 乐安县| 宜都市| 中山市| 林甸县| 桂林市| 嫩江县| 清新县| 疏勒县| 镇江市| 穆棱市| 黎城县| 鄂伦春自治旗| 尼木县| 织金县| 盐源县| 永吉县| 临潭县| 洛隆县| 东城区| 淄博市| 永平县| 鄂托克前旗| 栾城县| 邵东县| 安阳县| 灵璧县| 汝阳县| 长乐市| 曲沃县| 肥乡县| 临沭县| 宝坻区| 晴隆县| 海晏县| 平顶山市| 东莞市| 内丘县|