jquery - css transform property not working on element as expected -


i have got navigation side bar expands on click of button , contracts on clicking same button again.

when navigation bar collapsed, text on button says expand >

and when navigation bar expanded, text on button says collapse <

see codepen link

problem text "expand" or "collapse" on button appears horizontally while wanted them appear vertically this.

i used css transform property following way rotate text -90deg , worked fine initially.

#expand, #collapse{     font-size: 0.8em;     font-weight: bold;     font-family: 'ubuntu', serif;     -webkit-transform: rotate(-90deg);     -ms-transform: rotate(-90deg);     transform: rotate(-90deg); } 

but when wrote following jquery code, text no longer appears rotated.

if( $('.option').hasclass('non-visible') ){     // collapsed          $('.open-menu').css('display','unset');         $('.close-menu').css('display','none');      } else {    // expanded          $('.open-menu').css('display','none');         $('.close-menu').css('display','unset');      } 

here html code button:

            <button id="button-expand">                 <p id="expand" class="open-menu">expand</p>                 <i class="fa fa-chevron-right open-menu" aria-hidden="true"></i>                  <p id="collapse" class="close-menu">collapse</p>                 <i class="fa fa-chevron-left close-menu" aria-hidden="true"></i>                  <p><!-- nothing --></p>             </button> 

the jquery code required selectively display "expand" or "collapse" on button (depending on navigation bar whether expanded or collapsed).

kindly tell me i'm doing wrong. there kind of conflict/overriding taking place?

thanks!

replace unset values blanks "". when use unset looks if styles go out chain reaction (cascading perhaps?). anyways, when toggling between display:none, it's common practice use "" blanks because that'll trigger default display(initial)

codepen

    $('.open-menu').css('display','');     $('.close-menu').css('display','none');  } else {    // expanded      $('.open-menu').css('display','none');     $('.close-menu').css('display',''); 

Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -