I want a tab that will open 50% in window and 100% on mobile phone, how can I achieve this by using js. Here is my js fill which I am using right now.
    <script>
        function openNav() {
          document.getElementById("mySidecmnt").style.width = "100%";
        }
        
        function closeNav() {
          document.getElementById("mySidecmnt").style.width = "0";
        }
    </script>
Html file
    <div id="mySidecmnt" class="sidecmnt">
          <a href="javascript:void(0)" class="closebtnsty" onclick="closeNav()"><svg width="25" height="25" viewBox="0 0 25 25" class="hp"><path d="M18.13 6.11l-5.61 5.61-5.6-5.61-.81.8 5.61 5.61-5.61 5.61.8.8 5.61-5.6 5.61 5.6.8-.8-5.6-5.6 5.6-5.62"></path></svg></a>
                
        <!-- comments -->
        <?php 
            if (comments_open() || get_comments_number()) :
                comments_template();
            endif;
        ?>
        <!-- end comments -->
    </div>
    <span style="font-size:30px;cursor:pointer" onclick="openNav()">open</span>
 
     
    