滑鼠移入移出改變CSS樣式的小例子

來源:互聯網
上載者:User

網頁上的某個地區,當滑鼠移入時改變樣式,滑鼠移出時自動回復樣式,可以是一個圖片的邊框,也可以一段文字變色,掌握了原理,貌似可以做更加豐富生動的網頁互動效果,這裡主要是利用Js控制Hover標籤所在的DIV產生動作,也是學習的好範例。 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"><br /><style> body{color:#fff;font:12px/1.5 Tahoma;}#div1{width:150px;height:150px;margin:0 auto;padding:10px;background:black;border:10px solid #000;cursor:crosshair;}#div1.hover{color:red;background:#f0f0f0;border:10px solid red;}</style><p>滑鼠移入改變樣式,滑鼠移出恢複。<p>
[Ctrl+A 全選 注:如需引入外部Js需重新整理才能執行]
相關文章

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.