Setting the width of a dropdown list in Bootstrap 3.0

后端 未结 4 823
执笔经年
执笔经年 2020-12-05 07:04

How can I set the width of a dropdown triggering button in bootstrap 3.0 to be equal to the width of the dropdown list? Similar to what is achieved when using bootstrap-sele

4条回答
  •  离开以前
    2020-12-05 07:29

    You can set the width of .dropdown-toggle. I recommend to use text-overflow ellipsis when the dropdown becomes too small. It's not necessary to style .dropdown-menu. You can set the width of the dropdown to any other value if you want to use it in .input-group or not in the grid.

    .dropdown-toggle {   
        overflow: hidden;
        padding-right: 24px /* Optional for caret */;
        text-align: left;
        text-overflow: ellipsis;    
        width: 100%;
    }
    
    /* Optional for caret */
    .dropdown-toggle .caret {
        position: absolute;
        right: 12px;
        top: calc(50% - 2px);
    }
    

提交回复
热议问题