简体   繁体   English

表格单元格iOS野生动物园中的100%高度按钮/标签/输入

[英]100% height button/label/input in a table cell iOS safari

I can't find a way to do this 我找不到办法

There seems to be padding placed above and below the element, although I have set it zero 尽管我将其设置为零,但似乎在元素的上方和下方放置了填充

https://plnkr.co/edit/WvEqNCxEcLY5yS1IT738?p=preview https://plnkr.co/edit/WvEqNCxEcLY5yS1IT738?p=preview

<div>
   <button>hello</button>
</div>

<table><tr><td>
   <button>hiya</button>
</td></tr></table>

td,
div{
  padding: 0;
  height: 10em;
  border: solid;
}

button {
  height: 100%;
  width:100%;
  border:solid 10px #f00;
}

I don't want to use absolute position as the contents vary, and JS would be an overhead I couldn't live with! 我不想使用绝对位置,因为内容会有所不同,而JS将是我无法忍受的开销!

Is there a known bug here? 这里有一个已知的错误吗? Would anyone have a link to it so I can watch it not get fixed for years and drives me to a stress related end 有人会链接到它吗,这样我就可以看着它多年来没有固定下来,并把我逼到压力相关的终点

Thanks in advance 提前致谢

ios pic ios图片

在此处输入图片说明

chrome on win 10 (desired result) chrome 10胜(期望的结果)

在此处输入图片说明

The button, input, textarea, img, video, audio etc. are REPLACED ELEMENTS. button, input, textarea, img, video, audio等均已替换。 The positioning rules for them are other than for standard elements. 它们的定位规则不同于标准元素。 You can try to enclose replaced elements into a span or div. 您可以尝试将替换的元素包含在span或div中。

Add <div/> inside <td/> and put <button/> into <div/> it will work properly. <td/> <div/>内添加<div/>并将<button/>放入<div/>正常工作。 Add styles to new <div/> element and use: 将样式添加到新的<div/>元素并使用:

button 
{
  height: 100%;
  width:100%;
  padding:0;
  margin:0;
}

<table><tr><td><div class="replaced-element-container"><button>hiya</button></div></td></tr></table>

Well, this is embarrassing but it meets W3C requirements. 好吧,这很尴尬,但符合W3C要求。

For one table cell in the row: 对于该行中的一个表格单元格:

td,  div
{
   padding: 0;
   height: 10em;
   border: solid;
   display:block;
}

button 
{
   height: 100%;
   width:100%;
   border:solid 10px #f00;
}

But it doesn't resolve problem that button is replaced element. 但是按钮替换元素并不能解决问题。 It is still in container made from <td/> element. 它仍在由<td/>元素制成的容器中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM