How to fit a select tag in a table cell properly

后端 未结 3 792
无人共我
无人共我 2021-02-19 09:20

I am desperately trying to make a select tag fit in a table cell like it belongs there, not like someone wedged it in with a crowbar. Here is the code followed by the picture o

3条回答
  •  没有蜡笔的小新
    2021-02-19 10:01

    You can hide borders on the select element, for example:

    ISIN Code 0

    and the CSS might be:

    table {
        outline: 1px solid black;
        font-family: Arial, sans-serif;
        font-size: 20px;
    }
    table td {
        border: 1px solid blue;
        padding: 5px;
    }
    select { 
        width: 140px;
        border: none;
        font-family: inherit;
        font-size: inherit;
    }
    

    You may not get much control over the down arrow in the select menu.

    Make sure that you use inherit to keep the font-family and size consistent in the select menu.

    The rest of my borders are eye-candy for the demo.

    Fiddle: http://jsfiddle.net/audetwebdesign/Em79R/

提交回复
热议问题