您好,我有一个让我发疯的按钮!
这是jfiddle
HTML:
<div class="dropdown">
<button class="dropbtn">Dropdown</button>
<div class="dropdown-content">
<a href="#">Link 1</a>
<a href="#">Link 2</a>
<a href="#">Link 3</a>
</div>
</div>
CSS:
/* Dropdown Button */
.dropbtn {
background-color: Transparent;
background-repeat:no-repeat;
border: none;
cursor:pointer;
overflow: hidden;
outline:none;
text-shadow:none !important;
box-shadow:none !important;
}
/* The container <div> - needed to position the dropdown content */
.dropdown {
position: relative;
display: inline-block;
}
/* Dropdown Content (Hidden by Default) */
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
}
/* Links inside the dropdown */
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
/* Change color of dropdown links on hover */
.dropdown-content a:hover {background-color: #f1f1f1}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
display: block;
}
/* Change the background color of the dropdown button when the dropdown content is shown */
.dropdown:hover {
background-color: #3e8e41;
}
.dropbtn:hover
{
text-color: black;
}
正如您所看到的,当单击按钮或当前显示子链接时,它是绿色的!我试图使其透明,以便仅显示文本。
我认为这是一个 :hover 或 :active 但似乎从来没有起作用,所以我不知道是什么导致它变成绿色或者我如何解决这个问题。有什么帮助吗?
最佳答案
/* Change the background color of the dropdown button when the dropdown content is shown */
.dropdown:hover {
background-color: #3e8e41;
}
应该是
.dropdown:hover {
background-color: transparent;
}
关于html - 更改悬停/事件按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34799029/