Text 创建当鼠标悬停在上方时改变颜色的文本框

Text 创建当鼠标悬停在上方时改变颜色的文本框,text,colors,hover,Text,Colors,Hover,我正在尝试为我的网站创建文本框超链接。我想要透明的框,直到鼠标悬停在上面,然后我想要改变框的颜色,但不是文本。我想知道它们是否是实现这一点的一种方法?使用CSS,您需要向hover伪类添加背景色:yourcolor 下面是一个例子: <!-- Here's the HTML --> <div class="myDiv"> <p>Here is some text and then you will be <a href="mylink.html"&g

我正在尝试为我的网站创建文本框超链接。我想要透明的框,直到鼠标悬停在上面,然后我想要改变框的颜色,但不是文本。我想知道它们是否是实现这一点的一种方法?

使用CSS,您需要向hover伪类添加背景色:yourcolor

下面是一个例子:

<!-- Here's the HTML -->
<div class="myDiv">
  <p>Here is some text and then you will be <a href="mylink.html">linking</a> to another site</p>
</div>
很简单

.myDiv a:hover {
  background-color: red;
}