我有两个不同的按钮,但是CSS将第二个HTML按钮的悬停颜色应用于第一个。你怎么解决这个问题?
我试着有两个不同颜色的按钮。当我尝试时,它使.hicodested的悬停颜色为.styled。此外,.hicodested按钮在悬停时处于空闲状态。当尝试添加不同的类时,它仍然无法区分这两个按钮 .风格{ 浮动:对; 边界:0; 线高:1.5; 填充:0 20px; 字号:1rem; 文本对齐:居中; 颜色:fff; 文本阴影:1px 1px 1px 000; 边界半径:10px; 背景色:rgba0,220,0,1; 背景图像:左上角线性渐变,rgba0,0,0,2,rgba0,0,0,2 30%,rgba0,0,0,0; 框阴影:插入2PX2PX3PXRGBA255、255、255.6,插入-2px-2PX3PXRGBA0、0、0.6; } .styled:悬停{ 背景色:rgba0,255,0,1; } .样式:活动{ 框阴影:插入-2px-2px 3px rgba255、255、255、.6,插入2px 2px 3px rgba0、0、0、.6; } .hicodested{ 浮动:对; 边界:0; 线高:1.5; 填充:0 20px; 字号:1rem; 文本对齐:居中; 颜色:fff; 文本阴影:1px 1px 1px 000; 边界半径:10px; 背景色:rgba0、220、220、1; 背景图像:左上角线性渐变,rgba0,0,0,2,rgba0,0,0,2 30%,rgba0,0,0,0; 框阴影:插入2PX2PX3PXRGBA255、255、255.6,插入-2px-2PX3PXRGBA0、0、0.6; } .styled:悬停{ 背景色:rgba0、220、220、1; } .样式:活动{ 框阴影:插入-2px-2px 3px rgba255、255、255、.6,插入2px 2px 3px rgba0、0、0、.6; }我有两个不同的按钮,但是CSS将第二个HTML按钮的悬停颜色应用于第一个。你怎么解决这个问题?,html,css,Html,Css,我试着有两个不同颜色的按钮。当我尝试时,它使.hicodested的悬停颜色为.styled。此外,.hicodested按钮在悬停时处于空闲状态。当尝试添加不同的类时,它仍然无法区分这两个按钮 .风格{ 浮动:对; 边界:0; 线高:1.5; 填充:0 20px; 字号:1rem; 文本对齐:居中; 颜色:fff; 文本阴影:1px 1px 1px 000; 边界半径:10px; 背景色:rgba0,220,0,1; 背景图像:左上角线性渐变,rgba0,0,0,2,rgba0,0,0,2
这似乎是覆盖HicodedButton类的一个问题。在下面的代码中,我更改了悬停颜色,并替换了Hicodested的第二个样式化按钮声明。代码现在应该可以正常工作,但是为了测试的目的,颜色当前设置为红色和较深的绿色。我建议你根据需要更换
<style>
.styled {
float: right;
border: 0;
line-height: 1.5;
padding: 0 20px;
font-size: 1rem;
text-align: center;
color: #fff;
text-shadow: 1px 1px 1px #000;
border-radius: 10px;
background-color: rgba(0, 220, 0, 1);
background-image: linear-gradient(to top left,
rgba(0, 0, 0, .2),
rgba(0, 0, 0, .2) 30%,
rgba(0, 0, 0, 0));
box-shadow: inset 2px 2px 3px rgba(255, 255, 255, .6),
inset -2px -2px 3px rgba(0, 0, 0, .6);
}
.styled:hover {
background-color: red
}
.styled:active {
box-shadow: inset -2px -2px 3px rgba(255, 255, 255, .6),
inset 2px 2px 3px rgba(0, 0, 0, .6);
}
.hicodestled {
float: right;
border: 0;
line-height: 1.5;
padding: 0 20px;
font-size: 1rem;
text-align: center;
color: #fff;
text-shadow: 1px 1px 1px #000;
border-radius: 10px;
background-color: rgba(0, 220, 220, 1);
background-image: linear-gradient(to top left,
rgba(0, 0, 0, .2),
rgba(0, 0, 0, .2) 30%,
rgba(0, 0, 0, 0));
box-shadow: inset 2px 2px 3px rgba(255, 255, 255, .6),
inset -2px -2px 3px rgba(0, 0, 0, .6);
}
.hicodestled:hover {
background-color: green;
}
.hicodestled:active {
box-shadow: inset -2px -2px 3px rgba(255, 255, 255, .6),
inset 2px 2px 3px rgba(0, 0, 0, .6);
}
</style>
<a href=http://point90.42web.io style=text-decoration:none><font color=#ffffff>
<button class="styled"
type="button">
<b>Back up</b>
</button>
<button class="hicodestled"
type="button">
<b>View code</b>
</button>
</font></a>