简体   繁体   English

在悬停时更改块链接的背景颜色

[英]Changing background color of a block link on hovering

I am creating a few links on my web page and I wanted to have an effect, like a change in the background or the size of the text seeming to grow up, whenever I hover over those links. 我正在我的网页上创建一些链接,我想要有效果,比如当我将鼠标悬停在这些链接上时,背景的变化或看起来长大的文本的大小。 The links are displayed like blocks . 链接显示为blocks


html part HTML部分

<div>
   <a class="leftimagelinks" href="#">Submit a paper</a><br>
   <a class="leftimagelinks" href="#">Get the brochure</a><br>
   <a class="leftimagelinks" href="#">Housing and travel</a>
</div>

css part css部分

.leftimagelinks {
margin: auto;
display: block;
width: 190px;
height: 25px;
border-radius: 8px;
text-align: center;
padding: 4px;
color: yellow;
background-color: black;
background-color: #32CD32;
}

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

But even after the above whenever I hover over the links, nothing changes. 但是,即使在我将鼠标悬停在链接上面之后,也没有任何变化。 Whats the mistake here ? 这里的错误是什么?

The CSS selector .leftimageslinks a:hover tries to select a link inside '.leftimageslinks'. CSS选择器.leftimageslinks a:hover尝试选择'.leftimageslinks'中的链接。 Instead, try this: 相反,试试这个:

.leftimagelinks:hover{
  background-color: red;
}

http://jsfiddle.net/BGJJn/ http://jsfiddle.net/BGJJn/

Use 采用

.leftimagelinks:hover

You are using wrong selector. 您使用了错误的选择器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM