td的margin为什么会失效,如下图,请赐教,务必详细,如下图,拜谢_html/css_WEB-ITnose
浏览器显示如下
dreamweavercs5代码编辑如下:
nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
回复讨论(解决方案)
首先,我们需要知道的是:我们可以对表格table设置margin,而不能设置padding;对单元格td设置padding,而不能设置margin。所以说,我们不能对单元格td设置margin属性来调整单元格与单元格之间的距离,但是我们可以使用一下方法来达到同样的效果。
1) 设置padding
就像刚才所说的那样,我们可以对单元格td设置padding属性来调整单元格之间的间隔
td{padding:5px 10px;}
2) 使用标签
我们可以在单元格td内添加标签,然后对标签设置margin属性
p{margin:5px 10px;}
3) 对表格table设置border-spacing(IE不支持)
先让我们简单了解一下border-spacing属性。border-spacing:length;设置单元格td的边在横向和纵向上的间距。当您指定一个length值时,这个值将作用于横向和纵向上的间距;当您指定两个length值时,第一个将作用于横向间距,第二个值将作用于纵向间距。
table{border-spacing:5px 10px;}
首先,感谢您的回答,有一点疑问想请教前辈,在上面,我上传的代码中已经对table设置了padding和margin,而且在浏览器中也都确实显示出来,请您再看一下,你说的table不可以设置padding,是不是有什么特殊性,再次感谢您的解答
哦,豁然开朗啊。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

GiteePages static website deployment failed: 404 error troubleshooting and resolution when using Gitee...
