微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

asp.net – HTML属性bgcolor已被弃用:使用什么?

VStudio ASP.NET提供以下消息:
Attribute 'bgcolor' is considered outdated. A newer construct is recommended.

推荐的结构是什么?

bgcolor在< td>内元件.
一个相关的消息是:

Attribute 'bordercolor' is not a valid attribute of element 'table'.

有谁知道我可能会找到更新的替代品?

解决方法

W3C HTML 4.0规范中已经废除了 BGColor.

较新的网站和Web应用程序使用CSS(级联样式表)呈现相同的事情,如下所示:

body {
  background-color : #ffffff;
}

对于表,请执行以下操作:

<table>

<tr id="row1">
   <th>Header 1</th>      <td>Cell 1</td>        <td>Cell 2</td>
</tr>
<tr id="row2">
   <th>Header 2</th>      <td>Cell 3</td>        <td>Cell 4</td>
</tr>
<tr id="row3">
   <th>Header 3</th>      <td>Cell 5</td>        <td>Cell 6</td>
</tr>
</table>

在你的CSS中:

th { text-align: center; font-weight: bold; vertical-align: baseline }

td { vertical-align: middle  }

table  { border-collapse: collapse; background-color: #ffffff }
tr#row1 { border-top: 3px solid blue }
tr#row2 { border-top: 1px solid black }
tr#row3 { border-top: 1px solid black }

这样做会使表格具有背景颜色,并与表数据/表格行的其余部分做不同的内容.

简单地说,在您的样式表中,并将其引用到您的网页上,如下所示:

<link rel="stylesheet" href="style.css" TYPE="text/css" media="screen">

你可以把CSS中的任何你喜欢的内容,更多关于CSS herehere的信息.

原文地址:https://www.jb51.cc/aspnet/246460.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐