2016-11-11 2 views
-1

Я не хочу, чтобы эти значки списка отображались поверх значка Google до тех пор, пока он не щелкнут.Скрыть содержимое списка до тех пор, пока не щелкнули значок

i do not want that list icons on top of google icon when it is unclicked

Я попытался добавить display:none к каждому элементу.

(function(){ 
 
\t var ul=$("#navs"),li=$("#navs li"),i=li.length,n=i-1,r=120; 
 
\t ul.click(function(){ 
 
\t \t $(this).toggleClass('active'); 
 
\t \t if($(this).hasClass('active')){ 
 
\t \t \t for(var a=0;a<i;a++){ 
 
\t \t \t \t li.eq(a).css({ 
 
\t \t \t \t \t 'transition-delay':""+(50*a)+"ms", 
 
\t \t \t \t \t '-webkit-transition-delay':""+(50*a)+"ms", 
 
\t \t \t \t \t 'left':(r*Math.cos(90/n*a*(Math.PI/180))), 
 
\t \t \t \t \t 'top':(-r*Math.sin(90/n*a*(Math.PI/180))) 
 
\t \t \t \t }); 
 
\t \t \t } 
 
\t \t }else{ 
 
\t \t \t li.removeAttr('style'); 
 
\t \t } 
 
\t }); 
 
})($);
#navs { 
 
    position: fixed; 
 
    left:10px; 
 
    bottom:10px; 
 
    width: 128px; 
 
    height: 128px; 
 
    line-height: 40px; 
 
    list-style-type: none; 
 
    margin: 0; 
 
    padding: 0; 
 
    text-align: center; 
 
    color: #fff; 
 
    cursor: pointer; 
 
    background: url(https://cdn4.iconfinder.com/data/icons/new-google-logo-2015/400/new-google-favicon-128.png) no-repeat; 
 
    background-size: 100px 100px; 
 
    z-index: 1007; 
 
} 
 

 
#navs>li, 
 
#navs:after { 
 
    position: absolute; 
 
    left: 0; 
 
    top: 0; 
 
    width: 100%; 
 
    height: 100%; 
 
    border-radius: 50%; 
 
    -webkit-border-radius: 50%; 
 
} 
 

 
#navs>li { 
 
    transition: all .6s; 
 
    -webkit-transition: all .6s; 
 
    -moz-transition: .6s; 
 
} 
 

 
#navs a { 
 
    width: 60px; 
 
    height: 60px; 
 
    display: inline-block;; 
 
    border-radius: 50%; 
 
    -webkit-border-radius: 50%; 
 
    text-decoration: none; 
 
    color: #fff; 
 
    background-color: rgba(0,0,0, 0.5); 
 
    font-size: 30px; 
 
    line-height: 60px; 
 
}
<ul id="navs"> 
 
     <li><a href="#"><i class="fa fa-home"></i></a></li> 
 
     <li><a href="#about"><i class="fa fa-info"></i></a></li> 
 
     <li><a href="#contact"><i class="fa fa-phone"></i></a></li> 
 

 
    </ul>

+0

Добро пожаловать в переполнение стека! Чтобы дать вам отличный ответ, это может помочь нам, если у вас есть взгляд на [спросить], если вы еще этого не сделали. Это может быть полезно, если вы можете предоставить [mcve]. – Mat

ответ

0

Некоторые, как пытались скрыть li изначально. проверьте фрагмент. Однако вам нужно настроить размер этих circles

(function(){ 
 
\t var ul=$("#navs"),li=$("#navs li"),i=li.length,n=i-1,r=120; 
 
\t ul.click(function(){ 
 
     
 
\t \t $(this).toggleClass('active'); 
 
\t \t if($(this).hasClass('active')){ 
 
\t \t \t for(var a=0;a<i;a++){ 
 
\t \t \t \t li.eq(a).css({ 
 
\t \t \t \t \t 'transition-delay':""+(50*a)+"ms", 
 
\t \t \t \t \t '-webkit-transition-delay':""+(50*a)+"ms", 
 
\t \t \t \t \t 'left':(r*Math.cos(90/n*a*(Math.PI/180))), 
 
\t \t \t \t \t 'top':(-r*Math.sin(90/n*a*(Math.PI/180))), 
 
        'background-color': 'rgba(0,0,0, 0.5)' 
 
\t \t \t \t }); 
 
\t \t \t } 
 
\t \t }else{ 
 
\t \t \t li.removeAttr('style'); 
 
\t \t } 
 
\t }); 
 
})($);
#navs { 
 
    position: fixed; 
 
    left:10px; 
 
    bottom:10px; 
 
    width: 128px; 
 
    height: 128px; 
 
    line-height: 40px; 
 
    list-style-type: none; 
 
    margin: 0; 
 
    padding: 0; 
 
    text-align: center; 
 
    color: #fff; 
 
    cursor: pointer; 
 
    background: url(https://cdn4.iconfinder.com/data/icons/new-google-logo-2015/400/new-google-favicon-128.png) no-repeat; 
 
    background-size: 100px 100px; 
 
    z-index: 1007; 
 
} 
 

 
#navs>li, 
 
#navs:after { 
 
    position: absolute; 
 
    left: 0; 
 
    top: 0; 
 
    width: 100%; 
 
    height: 100%; 
 
    border-radius: 50%; 
 
    -webkit-border-radius: 50%; 
 
} 
 

 
#navs>li { 
 
    transition: all .6s; 
 
    -webkit-transition: all .6s; 
 
    -moz-transition: .6s; 
 
} 
 

 
#navs a { 
 
    width: 60px; 
 
    height: 60px; 
 
    display: inline-block;; 
 
    border-radius: 50%; 
 
    -webkit-border-radius: 50%; 
 
    text-decoration: none; 
 
    color: #fff; 
 
    /*background color removed from here and given to transition logic of js*/ 
 
    font-size: 30px; 
 
    line-height: 60px; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script> 
 
<ul id="navs"> 
 
     <li><a href="#"><i class="fa fa-home"></i></a></li> 
 
     <li><a href="#about"><i class="fa fa-info"></i></a></li> 
 
     <li><a href="#contact"><i class="fa fa-phone"></i></a></li> 
 

 
    </ul>

0

Добавить непрозрачности 0 в CSS и непрозрачностью 1 в функции мыши сценария

#navs>li{ 
opacity: 0; 
... 
} 

li.eq(a).css({ 
    ... 
    'opacity':1 
}) 

(function(){ 
 
\t var ul=$("#navs"),li=$("#navs li"),i=li.length,n=i-1,r=120; 
 
\t ul.click(function(){ 
 
\t \t $(this).toggleClass('active'); 
 
\t \t if($(this).hasClass('active')){   
 
\t \t \t for(var a=0;a<i;a++){ 
 
\t \t \t \t li.eq(a).css({ 
 
\t \t \t \t \t 'transition-delay':""+(50*a)+"ms", 
 
\t \t \t \t \t '-webkit-transition-delay':""+(50*a)+"ms", 
 
\t \t \t \t \t 'left':(r*Math.cos(90/n*a*(Math.PI/180))), 
 
\t \t \t \t \t 'top':(-r*Math.sin(90/n*a*(Math.PI/180))), 
 
        'opacity':1 
 
\t \t \t \t }); 
 
\t \t \t } 
 
\t \t }else{ 
 
\t \t \t li.removeAttr('style'); 
 
\t \t } 
 
\t }); 
 
})($);
#navs { 
 
    position: fixed; 
 
    left:10px; 
 
    bottom:10px; 
 
    width: 128px; 
 
    height: 128px; 
 
    line-height: 40px; 
 
    list-style-type: none; 
 
    margin: 0; 
 
    padding: 0; 
 
    text-align: center; 
 
    color: #fff; 
 
    cursor: pointer; 
 
    background: url(https://cdn4.iconfinder.com/data/icons/new-google-logo-2015/400/new-google-favicon-128.png) no-repeat; 
 
    background-size: 100px 100px; 
 
    z-index: 1007; 
 
} 
 

 
#navs>li, 
 
#navs:after { 
 
    position: absolute; 
 
    left: 0; 
 
    top: 0; 
 
    width: 100%; 
 
    height: 100%; 
 
    border-radius: 50%; 
 
    -webkit-border-radius: 50%; 
 
} 
 

 
#navs>li { 
 
    transition: all .6s; 
 
    -webkit-transition: all .6s; 
 
    -moz-transition: .6s; 
 
    opacity: 0; 
 
} 
 

 
#navs a { 
 
    width: 60px; 
 
    height: 60px; 
 
    display: inline-block;; 
 
    border-radius: 50%; 
 
    -webkit-border-radius: 50%; 
 
    text-decoration: none; 
 
    color: #fff; 
 
    background-color: rgba(0,0,0, 0.5); 
 
    font-size: 30px; 
 
    line-height: 60px; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<ul id="navs"> 
 
     <li><a href="#"><i class="fa fa-home"></i></a></li> 
 
     <li><a href="#about"><i class="fa fa-info"></i></a></li> 
 
     <li><a href="#contact"><i class="fa fa-phone"></i></a></li> 
 

 
    </ul>

+0

Он работает и в идеальном состоянии ссылки на список и круг не отображаются, но его ссылки активны. так что, хотя я нажимаю верхний правый значок Google, но он нажимает на ссылку списка. так как есть способ не только скрыть круги, но и отключить их, прежде чем нажимать значок Google? – dhaval

+0

Я разобрал его. #navs a { ... дисплей: нет; } и (функция() { \t ... 'дисплей': "встроенный блок" }); \t \t \t} \t \t} еще { \t \t \t li.removeAttr ('стиль'); lia.removeAttr ('style'); \t \t} \t}); }) ($); – dhaval

Смежные вопросы