Fieldset: Center legend

后端 未结 2 963
傲寒
傲寒 2021-01-19 10:06

as asked many times before (but never really answered) I want to center a legend in a fieldset.

The trick was done perfectly here, which I also bought for my project

相关标签:
2条回答
  • 2021-01-19 10:52

    The theme uses the code <legend align="center"> which fixes the Firefox issue:

    http://jsfiddle.net/ncv8H/

    <legend align="center">legend</legend>
    
    0 讨论(0)
  • 2021-01-19 11:05

    In HTML 5, the legend align attribute has been depreciated so here is how I did it.

    Note that Bootstrap 4 (don't know about 3) completely hides a field set border and sets the legend width to 100%. So in addition to adding the width:auto, you would also have to use css to set the fieldset border if you want it to display.

    legend {
        width: auto;
        margin-left: auto;
        margin-right: auto;
    }
    

    for

    <legend>Legend</legend>
    
    0 讨论(0)
提交回复
热议问题