首页htmlaHTML Element Style - 如何样式锚定到按钮,像点击效果

HTML Element Style - 如何样式锚定到按钮,像点击效果

我们想知道如何样式锚定到按钮,像点击效果。

<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.txt {
  line-height: 50px;
  padding: 5px 20px 5px 20px;
  background-color: red;
  text-decoration: none;
  border-radius: 10px;
  margin-left: 50px;
  margin-top: 100px;
  font-family: verdana;
  border: 2px solid black;
  color: #fff;
}

.txt:active {
  background-color: aqua;
  color: #000;
}
</style>
</head>
<body>
  <a href="#" class="txt">Yo</a>
</body>
</html>