Chosen harvesthq resize width dynamically

前端 未结 12 1630
渐次进展
渐次进展 2020-12-30 03:49

How can you have a harvesthq Chosen dropdown with a dynamic width style?

By default it has a fixed width and if you try to modify it with CSS you will have several p

12条回答
  •  不知归路
    2020-12-30 04:28

    I just want to share my solution about how to resize chosen dropdown width on screen resize:

    Firstly you have to add this style on your css:

    #form_paciente{
        width: 100% !important;
    }
    

    Where *#form_paciente* is your selection ID.

    After that add this script on your view:

    window.addEventListener("resize", function() {
        $('.chzn-container').innerWidth($('#selecciona_paciente_estadisticas_form').innerWidth());
        $('.chzn-search input').innerWidth($('#selecciona_paciente_estadisticas_form').innerWidth()-12);
        $('.chzn-drop').innerWidth($('#selecciona_paciente_estadisticas_form').innerWidth()-2);  
    }, false);
    

    In that case *#selecciona_paciente_estadisticas_form* is the form parent ID of *#form_paciente*

    That's all!

提交回复
热议问题