Create a group box around certain controls on a web form using CSS

前端 未结 3 965
栀梦
栀梦 2021-02-04 23:10

I have three controls on my web form of three drop down lists.

I want to create a graphical \"box\" around these controls. The reason for this is that selecting these co

3条回答
  •  攒了一身酷
    2021-02-05 00:03

    A fieldset with a legend provides a visual and semantic grouping for form controls. You can then style this as desired with CSS. A fieldset is somewhat unique in that the legend is capable of visually interrupting the border of its parent fieldset (possible with other elements, but difficult).

    Example: http://jsfiddle.net/NUMcr/1/

    Group 1
    fieldset {
        margin: 8px;
        border: 1px solid silver;
        padding: 8px;    
        border-radius: 4px;
    }
    
    legend {
        padding: 2px;    
    }
    

提交回复
热议问题