首页 > 解决方案 > HTML 中是否有任何标签或元素可以执行如下图所示的操作:

问题描述

在此处输入图像描述

我需要制作类似这个容器的东西,它有一个边框和居中的标题。

标签: htmltwitter-bootstrapdombootstrap-4frontend

解决方案


<fieldset><legend>元素可以做到这一点。

legend {
  margin: 0 auto;
}
input {
  width: 100%;
}
<form>
  <fieldset>
    <legend>Comment</legend>
    <input type="text" placeholder="Add your comment"/>
  </fieldset>
</form>


推荐阅读