也許晚點亮吧!但是,這個怎麼樣:
CSS
.KeyboardRow {
text-align: center;
}
.KeyboardKey {
display: inline-block;
border: 1px solid #dcdcdc;
padding: 10px;
margin-bottom: 5px;
-moz-box-shadow: inset 0px 1px 0px 0px #ffffff;
-webkit-box-shadow: inset 0px 1px 0px 0px #ffffff;
box-shadow: inset 0px 1px 0px 0px #ffffff;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #ededed), color-stop(1, #dfdfdf));
background: -moz-linear-gradient(center top, #ededed 5%, #dfdfdf 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ededed', endColorstr='#dfdfdf');
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
cursor: pointer;
display: inline-block;
color: #777777;
font-family: arial;
font-size: 15px;
font-weight: bold;
font-style: normal;
height: 50px;
line-height: 50px;
width: 75px;
text-decoration: none;
text-align: center;
text-shadow: 1px 1px 0px #ffffff;
}
.KeyboardKey:hover {
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #dfdfdf), color-stop(1, #ededed));
background: -moz-linear-gradient(center top, #dfdfdf 5%, #ededed 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#dfdfdf', endColorstr='#ededed');
background-color: #dfdfdf;
}
.KeyboardKey:active {
position: relative;
top: 1px;
}
.KeyboardRow .active {
background-color: #0c57a8;
-moz-box-shadow: inset 0px 1px 0px 0px #9fc5f2;
-webkit-box-shadow: inset 0px 1px 0px 0px #9fc5f2;
box-shadow: inset 0px 1px 0px 0px #9fc5f2;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #0c57a8), color-stop(1, #043078));
background: -moz-linear-gradient(center top, #0c57a8 5%, #043078 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0c57a8', endColorstr='#043078');
border: 1px solid #2358a1;
display: inline-block;
text-shadow: 1px 1px 0px #07294a;
color: #ffffff;
}
.KeyboardRow .active:hover {
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #043078), color-stop(1, #0c57a8));
background: -moz-linear-gradient(center top, #043078 5%, #0c57a8 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#043078', endColorstr='#0c57a8');
background-color: #043078;
}
HTML
<!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 content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>KeyBoard</title>
<link href="style.keyboard.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="keyboard">
<div class="KeyboardRow">
<span class="KeyboardKey">Q</span>
<span class="KeyboardKey">W</span>
<span class="KeyboardKey">E</span>
<span class="KeyboardKey">R</span>
<span class="KeyboardKey">T</span>
<span class="KeyboardKey">Y</span>
<span class="KeyboardKey">U</span>
<span class="KeyboardKey">I</span>
<span class="KeyboardKey">O</span>
<span class="KeyboardKey">P</span>
</div>
<div class="KeyboardRow">
<span class="KeyboardKey active">A</span>
<span class="KeyboardKey">S</span>
<span class="KeyboardKey">D</span>
<span class="KeyboardKey">F</span>
<span class="KeyboardKey">G</span>
<span class="KeyboardKey">H</span>
<span class="KeyboardKey">J</span>
<span class="KeyboardKey">K</span>
<span class="KeyboardKey">L</span>
</div>
<div class="KeyboardRow">
<span class="KeyboardKey">Z</span>
<span class="KeyboardKey">X</span>
<span class="KeyboardKey">C</span>
<span class="KeyboardKey">V</span>
<span class="KeyboardKey">B</span>
<span class="KeyboardKey">N</span>
<span class="KeyboardKey">M</span>
</div>
</div>
</body>
我改變的情況下,你想使用這個成一個更大的項目的類名稱。.key不是真正唯一的名稱。
我的小提琴鏈接:
http://jsfiddle.net/ferencik/EpnL3/
看鍵盤在你的面前。它看起來像鑰匙像桌子一樣排列?當然不是;)所以不要使用'display:table'。 –
你可以使用'block'作爲表格和行,'inline-block'作爲單元格。 – helderdarocha