【发布时间】:2012-07-11 16:27:50
【问题描述】:
我知道怎么做border opacity,怎么做background image opacity,但我想要一个元素没有边框不透明度,背景图像不透明度。我不想在图像编辑器中修改图像,所以我正在寻找 CSS 设置的不透明度。可能吗?
在我下面的 CSS 中,我想用清晰的不透明边框修改 "disabled" 状态。请指教...
使用示例:this fiddle
按钮样式:
div.button, div.button:hover
{
background: none;
border: 2px solid #6C7B8B;
border-radius: 8px;
clear: none;
color: transparent;
cursor: pointer;
display: inline-block;
filter: alpha(opacity=100);
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
float: none;
height: 24px;
margin-bottom: 0px;
margin-left: 3px;
margin-right: 0px;
margin-top: 7px;
opacity: 1;
-moz-opacity: 1;
outline: none;
overflow: hidden;
padding: none;
vertical-align: top;
width: 24px;
}
点击效果:
div.button:active
{
left: 1px;
position: relative;
top: 1px;
}
DISABLED 状态的额外样式:
div.disabled, div.disabled:hover
{
cursor: default;
filter: alpha(opacity=50);
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
opacity: 0.50;
-moz-opacity: 0.50;
}
div.disabled:active
{
left: 0px;
position: relative;
top: 0px;
}
开启状态的额外样式:
div.on, div.on:hover
{
border: 2px solid #007FFF;
}
【问题讨论】:
-
要赋予边框不透明度,您可以在边框的颜色部分使用 rgba({values})。您也可以赋予透明(在同一部分)以使边框消失。
-
为什么要不透明度,而不仅仅是降低颜色?您有一个带有
color: transparent; background: none;的按钮,顺便说一句 - 您可以向我们展示您的页面吗? -
为什么要使用 div.button 而不是真正的按钮,甚至还有一个 disabled 属性?
-
@Bergi - 我已经用示例小提琴更新了这个问题(三个按钮:正常、打开、禁用)。我希望“禁用”按钮与普通按钮具有相同的边框。我使用
div.button是因为我想要我的样式,就像你在我的 CSS 中看到的那样。 -
@ppsreejith - 我没有运气 - 请参阅我更新的问题中的小提琴链接 - 如果可以,请使用解决方案更新该小提琴。
标签: javascript html css