用鍵盤控制DIV,紅色方塊為鍵盤操作地區,您可以進行如下操作:
上:↑ 下:↓ 左:← 右:→
Ctrl + 1 : 背景變為綠色
Ctrl + 2 : 背景變為黃色
Ctrl + 3 : 背景變為藍色
Ctrl + ↑ : 放大
Ctrl + ↓ : 縮小
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>用鍵盤控制DIV</title> <style type="text/css"> html,body{overflow:hidden;} body{margin:0;padding:0;} pre{color:green;padding:10px 15px;background:#f0f0f0;border:1px dotted #333;font:12px/1.5 Courier New;margin:12px;} span{color:#999;} #box{position:absolute;top:50px;left:300px;width:100px;height:100px;background:red;} </style> </head> <body> <pre> 紅色方塊為鍵盤操作地區,您可以進行如下操作: 上:↑ 下:↓ 左:← 右:→ Ctrl + 1 : 背景變為綠色 Ctrl + 2 : 背景變為黃色 Ctrl + 3 : 背景變為藍色 Ctrl + ↑ : 放大 Ctrl + ↓ : 縮小 </pre> </body> </html>
[Ctrl+A 全選 注:如需引入外部Js需重新整理才能執行]