Submitting a form by pressing enter without a submit button

前端 未结 20 1823
你的背包
你的背包 2020-11-22 06:46

Well I am trying to submit a form by pressing enter but not displaying a submit button. I don\'t want to get into JavaScript if possible since I want everything to work on a

20条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-22 07:19

    I work with a bunch of UI frameworks. Many of them have a built-in class you can use to visually hide things.

    Bootstrap

    
    

    Angular Material

    
    

    Brilliant minds who created these frameworks have defined these styles as follows:

    .sr-only {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }
    
    .cdk-visually-hidden {
        border: 0;
        clip: rect(0 0 0 0);
        height: 1px;
        margin: -1px;
        overflow: hidden;
        padding: 0;
        position: absolute;
        width: 1px;
        outline: 0;
        -webkit-appearance: none;
        -moz-appearance: none;
    }
    

提交回复
热议问题