我可以替换< table border = 1>'与`< table>`+ css:`table {...}`一起使用? [英] Can I replace <table border=1>' with `<table>` + css: `table{...}`?

查看:87
本文介绍了我可以替换< table border = 1>'与`< table>`+ css:`table {...}`一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

table{border:1px solid #000;}似乎无法工作. 与将<input width=30>更改为input{width:400px;}一样,我想使用<table>并仅在CSS中声明边框.有可能吗?

table{border:1px solid #000;} doesn't seem to work without the border=1 statement. In the same way as changing <input width=30> into input{width:400px;}, I would like to use <table> and declare the border in css only. Is that possible?

更新 我的错误是使用

table{border-width:1px;}

而不是例如

table{border:1px solid #000;} 

-效果很好.

推荐答案

使用此CSS:

table {
    border-collapse: collapse
}
td {
    border: 1px solid #000
}

实时演示

border-collapse: collapse 很重要;没有它,您将获得双边框,像这样.

这篇关于我可以替换&lt; table border = 1&gt;'与`&lt; table&gt;`+ css:`table {...}`一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆