Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何在“字段集图例”中设置中间位置的文本`_Html_Css_Legend_Fieldset - Fatal编程技术网

Html 如何在“字段集图例”中设置中间位置的文本`

Html 如何在“字段集图例”中设置中间位置的文本`,html,css,legend,fieldset,Html,Css,Legend,Fieldset,如何在字段集中设置边框中间的图例文本 我尝试了以下html代码: <fieldset> <legend align="center"> This is text appear at center of border </legend> </fieldset> 这是显示在边框中心的文本 我也试过使用左边距:100px,但由于设计限制,我不想使用左边距。CSS是你的朋友吗 legend { w

如何在
字段集中设置边框中间的图例文本

我尝试了以下html代码:

<fieldset>
    <legend align="center"> 
              This is text appear at center of border
    </legend>
</fieldset>

这是显示在边框中心的文本

我也试过使用左边距:100px,但由于设计限制,我不想使用左边距。

CSS是你的朋友吗

legend {
    width: 100%;
    text-align: center;
}
尝试为“图例元素”指定一个宽度,百分比为10%。 然后给它留有45%的余量(100-10)/2)

}


它将位于边框之间的中间

它以两种方式工作:。这很容易,您可以将边框添加到其中。将问题中的现有css粘贴到添加边框的位置,无论是添加到
legend
还是
fieldset
,如果将边框添加到fieldset,它将围绕包含后续字段的所有区域添加边框。如果您只向图例添加边框,则它将按预期只向图例区域添加边框
legend {
width: 10%;
text-align: center;
margin-left:45%;