門戶網站 靜態頁面總結2

來源:互聯網
上載者:User

標籤:

頭部結構

1、logo區設定寬高後(高度值與父元素相同即可),由背景圖片引入,left center。

2、user區包含searchbox和nav,為user設定一個需要的高度、寬度,float:right,設定margin-top來實現置中。子項目float:left;margin-right控制間距。

  2.1searchbox包含input和button,通常為做成外觀一體,為searchbox設定border。

    input{border:0;background:0;outline:0;}一般會為其設定text-indent:2px;

    button{border:0;}

  2.2usernav部分,選項間有“|”的情況 <li><a href="#">xx</a>|</li>,為<a>設定左右padding即可實現效果。

3、headtitle區,結構是包裹<div>下的<a>排列,<a>xxx</a>。

  基礎樣式:為xx置中分開,為div設定line-height,<a>設定左右padding,margin-right值即可。

  實現效果樣式:滑鼠划過xx時出現border-bottom有漸層樣式。

    偽類與虛擬元素知識前提:1190000000484493

    ::after在被選元素的內容後面插入內容,並用content屬性來指定插入內容。    

 1 a{ 2     padding:0 25px;margin-right:30px; 3     position:relative;display:inline-block; 4 } 5 a::after{ 6     width:100%;height:2px;background:#1e96d5;  7     opacity:0;content:"."; 8     position:absolute;top:100%;left:0; 9     transform:sacle(0.85);10     transition:height 0.5s,opacity 0.5s,transform 0.5s;11 }12     /*-moz-//-webkit-//transform/transition*/ 13  a:hover::after{height:3px;opacity:1;transform:scale(1); 

     注意點:

      <a>設定display:inline-block後<a>的高度將變成父元素的line-height值。

    <a>需要設定相對定位,以方便a::after絕對位置(子項目絕對位置不能撐開父元素,用a::after插入的內容絕對位置後不佔a的高度)。

    a::after插入內容放在<a>中,width:100%,表示繼承了a的寬度。絕對位置top值為100%表示在a的bottom。content:".";作用是撐開對象。

    opacity:0;表示完全透明(以隱藏),1表示完全不透明。

    transform對元素進行旋轉,縮放,移動,傾斜。

      屬性值scale(x)通過設定軸的值來定義縮放旋轉,更多屬性值見http://www.w3school.com.cn/cssref/pr_transform.asp

    transition用於表現簡單的動畫效果。

    以上代碼僅能實現hover時的效果。不能實現點擊效果固定。可設定一個class為current,jq實現click事件removeClass與addClass。

    a.current(表示class為current的a標籤)::after{height:3px;opacity:1;transform:scale(1}即可。

    

 

門戶網站 靜態頁面總結2

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.