首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >宽度为100%的HTML输入文本框溢出表单元格

宽度为100%的HTML输入文本框溢出表单元格
EN

Stack Overflow用户
提问于 2010-03-03 20:20:34
回答 12查看 211.6K关注 0票数 107

有人知道为什么宽度为100%的输入元素会越过表格的单元格边框吗?

在下面这个简单的例子中,输入框跳过表格的单元格边框,结果很糟糕。这是经过测试的,在火狐、IE7和Safari上也是以同样的方式发生的。

这对你来说有意义吗?我是不是漏掉了什么,你知道可能的解决方案吗?

代码语言:javascript
复制
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">    
<html><head>    
   <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <!-- don't use closing slash in meta tag, it breaks HTML4.01 transitional -->
   <title>Test input text in table</title>
   <style type="text/css">      
      table {border-top: 1px solid #ff0000; border-left: 1px solid #ff0000;}
      table td {border-right: 1px solid #00ff00; border-bottom: 1px solid #00ff00;}
      input[type="text"] {width: 100%;} /* removing this would make input not to go over cells border, but they would be too short, I want them to fit cells size */
   </style>    
</head><body>

<table cellpadding="0" cellspacing="0">
   <tr>
      <td><p>column one hello babe babe babe</p></td>
      <td><p>column two hello babe more</p></td>
      <td><p>column three hello babe more and more</p></td>
   </tr>
   <tr>
      <td><input type="text" value="test"></td>
      <td><input type="text" value="test"></td>
      <td><input type="text" value="test"></td>
   </tr>
</table>

</body></html>
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2371105

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档