如何从CSS3菜单中删除透明度

时间:2013-07-30 15:37:59

标签: css3

我的菜单有以下Css设置: -

.wrap {
    width: 100%;
    margin-bottom: 1%;

}

nav {
    background: -webkit-gradient(linear, center top, center bottom, from(#fff), to(#ccc));
    background-image: linear-gradient(#fff, #ccc);
    border-radius: 6px;
    box-shadow: 0px 0px 4px 2px rgba(0,0,0,0.4);
    padding: 0 10px;
    position: relative;
}

.menu li {
    float: left;
    position: relative;
    list-style-type: none;
     /*background: url('img/denim.png');
    font-family: 'Droid Sans', sans-serif;*/
}

.menu li a {
    color: #444;
    display: block;
    font-size: 14px;
    line-height: 20px;
    padding: 6px 12px;
    margin: 8px 8px;
    vertical-align: middle;
    text-decoration: none;
}

.menu li a:hover {
    background: -webkit-gradient(linear, center top, center bottom, from(#ededed), to(#fff));
    background-image: linear-gradient(#ededed, #fff);
    border-radius: 12px;
    box-shadow: inset 0px 0px 1px 1px rgba(0,0,0,0.1);
    color: #222;
}

/* Dropdown styles */

.menu ul {
    position: absolute;
    left: -9999px;
    list-style: none;
    opacity: 0;
    transition: opacity 1s ease;
}

.menu ul li {
    float: none;
}

.menu ul a {
    white-space: nowrap;
}

/* Displays the dropdown on hover and moves back into position */
.menu li:hover ul {
    background: rgba(255,255,255,0.7);
    border-radius: 0 0 6px 6px;
    box-shadow: inset 0px 2px 4px rgba(0,0,0,0.4);
    left: 5px;
    opacity: 1;
}

/* Persistant Hover State */
.menu li:hover a {
    background: -webkit-gradient(linear, center top, center bottom, from(#ccc), to(#ededed));
    background-image: linear-gradient(#ccc, #ededed);
    border-radius: 12px;
    box-shadow: inset 0px 0px 1px 1px rgba(0,0,0,0.1);
    color: #222;
}

.menu li:hover ul a {
    background: none;
    border-radius: 0;
    box-shadow: none;
}

.menu li:hover ul li a:hover {
    background: -webkit-gradient(linear, center top, center bottom, from(#eee), to(#fff));
    background-image: linear-gradient(#ededed, #fff);
    border-radius: 12px;
    box-shadow: inset 0px 0px 4px 2px rgba(0,0,0,0.3);
}




@font-face {
  font-family: 'IconicStroke';
    src: url("~/fonts/iconic/iconic_stroke.eot");
    src: local('IconicStroke'),
       url("~/fonts/iconic/iconic_stroke.svg#iconic") format('svg'),
       url("~/fonts/iconic/iconic_stroke.otf") format('opentype');

但我面临的一个问题是,对于菜单项,背景是透明的,因此菜单项将不会被清除,因为它们背后的文本将会显示。那我怎么能删除菜单项透明度?

2 个答案:

答案 0 :(得分:0)

嗯,你这里有几个问题,没有小提琴,我无法回答,但你的不透明问题很容易解决。

<强> CSS

.menu ul {
position: absolute;
left: -9999px;
list-style: none;
opacity: 0; /* for a css drop down I would recommend using display none/block instead of opacity 0/1 */
transition: opacity 1s ease;
}



.menu li:hover ul {
background: rgba(255,255,255,0.7); /* this is why your drop down is transparent, rgba <-- the a means alpha or transparency so change that to 1.0 */
border-radius: 0 0 6px 6px;
box-shadow: inset 0px 2px 4px rgba(0,0,0,0.4);
left: 5px;
opacity: 1;

}

新CSS

.menu ul {
position: absolute;
left: -9999px;
list-style: none;
display: none;
transition: opacity 1s ease;
}



.menu li:hover ul {
background: rgba(255,255,255,1.0); /* or background: rgb(255, 255, 255); */
border-radius: 0 0 6px 6px;
box-shadow: inset 0px 2px 4px rgba(0,0,0,0.4);
left: 5px;
display: block;

}

我会告诉你一个小提琴。

Before

After

答案 1 :(得分:0)

嘿,我有一个简单的解决方案......

只需将文件上传控制的宽度自动设置为40%“无文件选择”文本将消失