我是css的新手,我正在尝试创建一个带边框的div元素,比如
我的HTML
位于以下位置:
<div class="mystyle">
<h3>header message<h3>
<p> this is my content</p>
</div>
答案 0 :(得分:6)
使用<fieldset>
标记,其中包含<legend>
。
试试这段代码:
<fieldset>
<legend>Example</legend>
<div class="mystyle">
<h3>header message</h3>
<p>this is my content</p>
</div>
</fieldset>
答案 1 :(得分:0)
我们可以在2个HTML标记的帮助下完成此操作:
1.<fieldset></fieldset> and <legend></legend> tags.
<legend> tag defines a caption for the <fieldset> tag and that caption comes with the border which you are looking for...
例如:
<fieldset>
<legend>What is Lorem Ipsum?</legend>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</fieldset>