- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
具有display: block
的表行无法获得父表的 100% 宽度,当它们具有 display: table-row
时它们自然获得 100% 宽度但是那个 CSS 值有一些其他的副作用,我现在尽量避免。
Plunker that demonstrate the problem.
是什么导致表格行的行为像这样而不像普通的 block 级元素?
最佳答案
此行为与表格在浏览器中的处理方式有关。
table
元素设置为 display:table
。 tr
是一个display:table-row
,td
是display:table-cell
。如果您正在创建一个基于 div 的 css 表格,它的工作原理是一样的。
在这个 fiddle 上:http://jsfiddle.net/rv4v2964/1/ ,我创建了相同的基本示例,但使用了 div,并添加了一个嵌套到表中的 block
元素,但位于任何行或单元格之外。
您会注意到它限制在第一个单元格的宽度内。 this article 中陈述了一个原因:
...the table and column widths are set by the widths of table and col elements or by the width of the first row of cells...
意思是当一个元素在表结构中是奇数时,第一个单元格的宽度设置了整个列的值。这实际上是 W3 上指定的 table-layout
行为:
http://www.w3.org/TR/CSS21/tables.html#fixed-table-layout
...a cell in the first row with a value other than 'auto' for the 'width' property determines the width for that column...
另一篇文章提到了每个浏览器在如何威胁表格结构之外的元素方面的不同行为。 http://snook.ca/archives/html_and_css/getting_your_di
结论
浏览器不喜欢您创建表格并在其中放置不应该存在的元素。这对我来说很可能是错误的。它会将第一个单元格的宽度作为其参数。
在这种特定情况下,解决方法可能是将显示设置为 display: table-caption;
以占据表格的整个宽度。然后,将属性caption-side
设置为bottom
,它会停留在表格的底部。
关于html - 为什么不显示:block and 100% width work on table rows?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25626157/
我想避免创建 std::thread 的开销,因此我要实现一个线程池。我正在为一个设计决策而苦苦挣扎: 工作队列中的工作是否应该能够将工作添加到工作队列中?如果是,如何? 问题出现了,因为我想让我添加
color 属性正常工作,但其他两个属性(font-size 和 text-shadow)不起作用。当链接被访问时,它的字体大小应该减小到 20 px 并且应用 text-shadow 属性,但它没有
我已经安装并配置了 supervisor。 ps -ax 显示 10 个进程,例如:php/home/vagrant/Sites/mysite/artisan queue:work --tries=1
我对 php artisan queue::work 命令感到不安。 我的命令不起作用,但我的作业已插入作业表但从未执行。 我正在为队列使用 mongodb 驱动程序。 我做错了什么,请给我建议。 最
为什么我可以找到很多关于“工作窃取”的信息而没有关于“工作耸肩”作为动态负载平衡策略的信息? 通过“工作耸肩”,我的意思是将多余的工作从繁忙的处理器转移到负载较低的邻居上,而不是让空闲的处理器从忙碌的
首先,我正在为 MySQL 使用 DATE_ADD 函数。当试图在 php 中使用 $sqlA 时,由于某种原因它说语法错误(主要是 WHERE 之后的区域)。为什么? $sqlA = "SELECT
a:hover { color: #237ca8 !important; font-weight: bold; } a:active { color: #cccccc !imp
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 7 年前。 Improve this q
我试图让只能使用 Tab 键的用户可以访问我的网站。我遇到的问题是,当我尝试使用 tab 键选择 float 的 div 时,不会触发 :focus in css;我不知道为什么它没有被触发。鼠标悬停
我在尝试将 2 个 div 并排放置时遇到了问题。 display: inline 它会删除我的边框并且不会将两个 div 放在同一行上。 请指教: .gig { outline: 1px s
这是 fiddle :http://jsfiddle.net/j9Gmx/ 我怎样才能得到最小高度:100%;上类? 最佳答案 它正在 工作,但由于 div 的父级(正文)没有高度,100% 基本上是
我正在使用 Flutter WebRTC 来创建 P2P 视频通话。 我遇到了一个与网络相关的问题:我已经完成了应用程序,但它只适用于移动数据。 将网络更改为WiFi时,它不起作用并且连接状态挂起Ch
我是 JavaScript 和 jQuery 的初学者。我的 css 和 JavaScript 代码位于 html 文件外部。这个问题已经有了答案,我尝试了所有代码,但滚动不起作用。我不知道我错过了什
我正在使用 Sprin AMQP 的rabbittemplate 通过 RabbitMQ 发送和接收消息。我能够发送和接收消息,但是,我想优先处理消息。 例如,如果我推送 1000 条消息,假设奇数消
我已经在 WorkManager 中加入了一个PeriodicWork,并希望每次完成时都获取它的 Worker 的输出数据,但以下代码似乎不起作用,因为 Log 消息没有出现在 Logcat 中:
我有一个名为 areaOne 的 AngularJS 指令。当我使用 template 时,会显示模板,但当我在 area1.js 中使用 templateUrl 时,不会呈现模板 HTML。 我在这
“:after”选择器在应用于带有 FF 和 IE 的输入时不起作用 input:after { content: "title"; } 而它正在处理 p、a 等。 这是一个错
下面是适用于 oracle 但不适用于 PostgreSQL 的 Sql 查询。 select count(*) from users where id>1 order by username; 我知
position?:fixed 在 chrome 浏览器上不工作,但在 firefox 中工作正常。 我有一个侧边栏可以停止滚动并固定在顶部。它在 firefox 中运行完美,但在 chrome 中,
我有一段代码无法在 Firefox 中运行。当按钮悬停时,.icon 图像不会改变。它在 Chrome 中完美运行。 button.add-to-cart-button .button-left .i
我是一名优秀的程序员,十分优秀!