在HTML中如何设置边框?

html-css012

在HTML中如何设置边框?,第1张

HTML中设置边框方法:

方法/步骤

1、一个普通的表格如下:

相关设置

2、单元格边距(表格填充)(cellpadding) -- 代表单元格外面距离,用于隔开单元格与单元格之间的空间 单元格间距(表格间距)(cellspacing) -- 代表表格边框与单元格补白的距离。

具体代码如下:

<table border='1'cellspacing="0" cellpadding="0" > <tr> <td width="200">1</td> <td width="200">2</td> <td width="200">3</td> </tr> <tr> <td>a</td> <td>b</td> <td>c</td> </tr> <tr> <td>中国</td> <td>我</td> <td>爱你</td> </tr> </table>

效果如图

文字不居中?

3、设置一下就好了。

代码如下:

<style type="text/css">.onecenter{text-align:centerwidth:200px}</style><table border='1'cellspacing="0" cellpadding="0" > <tr> <td class='onecenter'>1</td> <td class='onecenter'>2</td> <td class='onecenter'>3</td> </tr> <tr> <td class='onecenter'>a</td> <td class='onecenter'> b</td> <td class='onecenter' > c</td> </tr > <tr> <td class='onecenter' >中国</td> <td class='onecenter' >我</td> <td class='onecenter' >爱你</td> </tr> </table>

4、为了方便一点我直接把样式写在上面了。

效果如图:

5、每一个表格都是一个完整的方框,如果想要线条更细。

6、看如下代码:

<style type="text/css">.onecentertext-align:centerwidth:200pxheight:50px}#sebackground-color:#006699 padding:20pxcolor:#FFF}</style><table border='1'cellspacing="0" cellpadding="20" > <tr> <td class='onecenter'>1</td> <td class='onecenter' style='border-left:0pxborder-right:0px'  >2</td> <td class='onecenter'>3</td> </tr> <tr> <td class='onecenter'>a</td> <td class='onecenter' style='border:0px'> b</td> <td class='onecenter' > c</td> </tr > <tr id='se'> <td class='onecenter' >中国</td> <td class='onecenter' >我</td> <td class='onecenter' >爱你</td> </tr> </table>

7、这段代码主要是针对某些表格做了些设置,让某些表格不显示出来。

可以用border属性去除文本框的边框。

1、新建html文档,在body标签中添加一些input标签,这时默认情况下浏览器中的文本框有1px的边框:

2、在head标签中添加style标签,设置input的样式,这里为了演示方便,为文本框设置灰色的背景色:

3、为input标签设置边框“border”属性,属性值为“0”,这时网页中文本框的边框就被去掉了:

用css设置textarea代码如下:

<textarea style="width:200pxheight:100pxborder:solid 1px #f00border-radius:20pxresize:none"></textarea>

border-radius:20px;

resize:none

1.overflow内容溢出时的设置(设定被设定对象是否显示滚动条)

overflow-x水平方向内容溢出时的设置

overflow-y垂直方向内容溢出时的设置

以上三个属性设置的值为visible(默认值)、scroll、hidden、auto。

2.scrollbar-3d-light-color立体滚动条亮边的颜色(设置滚动条的颜色)

scrollbar-arrow-color上下按钮上三角箭头的颜色

scrollbar-base-color滚动条的基本颜色

scrollbar-dark-shadow-color立体滚动条强阴影的颜色

scrollbar-face-color立体滚动条凸出部分的颜色

scrollbar-highlight-color滚动条空白部分的颜色

scrollbar-shadow-color立体滚动条阴影的颜色

我们通过几个实例来讲解上述的样式属性:

1.让浏览器窗口永远都不出现滚动条

没有水平滚动条

<body style= "overflow-x:hidden ">

没有垂直滚动条

<body style= "overflow-y:hidden ">

没有滚动条

<body style= "overflow-x:hiddenoverflow-y:hidden ">或 <body

style= "overflow:hidden ">

2.设定多行文本框的滚动条

没有水平滚动条

<textarea style= "overflow-x:hidden "></textarea>

没有垂直滚动条

<textarea style= "overflow-y:hidden "></textarea>

没有滚动条

<textarea style= "overflow-x:hiddenoverflow-y:hidden "></textarea>

或 <textarea style= "overflow:hidden "></textarea>

3.设定窗口滚动条的颜色

设置窗口滚动条的颜色为红色 <body style= "scrollbar-base-color:red ">

scrollbar-base-color设定的是基本色,一般情况下只需要设置这一个属性就可以达到改变滚动条颜色的目的。

加上一点特别的效果:

<body style= "scrollbar-arrow-color:yellowscrollbar-base-color:lightsalmon ">

4.在样式表文件中定义好一个类,调用样式表。

<style>

.coolscrollbar{scrollbar-arrow-color:yellowscrollbar-base-color:lightsalmon}

</style>

这样调用:

<textarea class= "coolscrollbar "></textarea>