td宽度设置问题

lalaguan 2009-10-21 02:34:50
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Test</title>
</head>

<body>
<table style="width:500px;" border="1px">
<tr>
<td style="width:100px;"></td>
<td>the</td>
<td>the beautiful</td>
<td>the beautiful girl</td>
<td></td>
</tr>
</table>
</body>
</html>

我通过怎样设置CSS而不设置td的宽度,使“the”、“the beautiful”、“the beautiful girl”右边的border都靠近字体本身呢(跟左边边框一样)?
(由于字数不确定,所以精确确定宽度不好处理,希望能有别的方法。)
...全文
199 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
jiangdongyixia 2009-10-21
  • 打赏
  • 举报
回复
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Test</title>
<style type="text/css">
#table1 td {float:left; border:2px solid; margin-right:-2px;}
</style>
</head>

<body>
<table style="width:500px;" border="1" id="table1">
<tr>
<td style="width:100px;"> </td>
<td>the</td>
<td>the beautiful</td>
<td>the beautiful girl</td>
<td> </td>
</tr>
</table>
</body>
</html>

你可以把table中的border=“1”改为0 ;不知这样是否符合你的要求?
f231358 2009-10-21
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 lalaguan 的回复:]
不去掉table宽度可以么?貌似那东西还得留着。。。。
[/Quote]

既然要自动调整就去掉宽度,设置了宽度,就不会自动调整,除非里面的内容过多,把table撑开了
lalaguan 2009-10-21
  • 打赏
  • 举报
回复
哎,么得其他的办法呀?
junyi2003 2009-10-21
  • 打赏
  • 举报
回复
IE7可以通过MaxWidth和MinWidth来控制。
BeenZ 2009-10-21
  • 打赏
  • 举报
回复
那貌似只能通过控制td的宽度来设置了
lalaguan 2009-10-21
  • 打赏
  • 举报
回复
不去掉table宽度可以么?貌似那东西还得留着。。。。
[Quote=引用 1 楼 beenz 的回复:]
去掉table宽度就自动调整的
[/Quote]
BeenZ 2009-10-21
  • 打赏
  • 举报
回复
去掉table宽度就自动调整的

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Test</title>
</head>

<body>
<table border="1px">
<tr>
<td style="width:100px;"></td>
<td>the</td>
<td>the beautiful</td>
<td>the beautiful girl</td>
<td></td>
</tr>
</table>
</body>
</html>

61,112

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧