css 边框上如何写入文字?

html-css014

css 边框上如何写入文字?,第1张

需要准备的材料分别有:电脑、浏览器、html编辑器。

1、首先,打开html编辑器,新建html文件,例如:index.html。

2、在index.html中的<body>标签中,输入html代码:。

<div style="margin-top: 30pxwidth: 200pxheight:80pxborder: 1px solid blue">

<div style="background-color: whiteposition: absoluteleft: 30pxtop: 15px">文字</div>

</div>

3、浏览器运行index.html页面,此时实现了边框角落开口显示文字。

这个有两种常见方法,

1.直接使用标签

<form>

  <fieldset>

    <legend>用户信息表</legend>

    姓名: <input type="text" />

    年龄: <input type="text" />

  </fieldset>

</form>

2.使用定位,用css控制标题和边框的位置

<style>

*{margin:0padding: 0}

form{border:1px solid #cccdisplay: blockheight:200pxpadding:20px 10pxmargin-

top:100pxposition:relative}/*边框 宽高 内外边距 可根据自己实际情况定义*/

h3{display:inline-blockpadding:0 6pxfont-size: 14pxheight:30pxline-height:30pxposition:absoluteleft:20pxtop:-15pxbackground: #fff}

</style>

<form>

<h3>用户信息表</h3>

   姓名: <input type="text" />

   年龄: <input type="text" />

</form>

一般表单的这类标题就直接使用标签就可以,具体问题再具体使用不同方法

table{ border-collapse:collapse} //去掉表格的间隙

table th,table td{ border:1px solid #eee} //给表格的标题和单元格的边框设置为1像素颜色是#eee的实线

做个任务求采纳