css - 居中的表格,其中包含跨越两列文章的链接
问题描述
我一直在尝试column-span:all
在我的 CSS 文件中使用一个跨越两列文章容器的表格。跨越部分有效,但我的问题是我的表格中有几个链接由于某种原因在 Chrome (v 85) 和 Ms Edge 中不起作用。通过不工作,我的意思是我无法单击链接并且将鼠标悬停在它们上方时,没有任何更改生效(a:hover
什么都不做)。使用 Firefox 或 IE 似乎不会出现此问题。
如果我删除margin: 2em auto;
链接再次工作,但我的表格没有居中。
所以,问题是,我怎样才能制作一个跨越两列文章容器的居中表格,在 Chrome、IE、FF、Safari(未测试)等中仍然有效链接?
是否有替代方案?
MWE:
<html>
<head>
<style>
article{column-count:2;}
a{color:green;}
a:visited{color:red;}
a:hover{color:blue;}
a:active{color:yellow;}
table{column-span:all;margin:2em auto;}
</style>
</head>
<body>
<article>
<table>
<tr>
<td><a href="https://www.google.com/">google</a></td>
<td>unimportant text</td>
</tr>
<tr>
<td><a href="https://www.duckduckgo.com/">duckduckgo</a></td>
<td>another unimportant text</td>
</tr>
</table>
</article>
</body>
</html>
解决方案
<html>
<head>
<style>
article{column-count:2;}
a{color:green;}
a:visited{color:red;}
a:hover{color:blue;}
a:active{color:yellow;}
.center{
column-span:all;
margin:2em 0;
display:flex;
justify-content:center;
}
</style>
</head>
<body>
<article>
<div class="center">
<table>
<tr>
<td><a href="https://www.google.com/">google</a></td>
<td>unimportant text</td>
</tr>
<tr>
<td><a href="https://www.duckduckgo.com/">duckduckgo</a></td>
<td>another unimportant text</td>
</tr>
</table>
</div>
</article>
</body>
</html>
推荐阅读
- getstream-io - GetStream.com 问题:发布内容的用户如何删除/编辑他的帖子
- html - 在 % 动画 css 中使用变换:旋转
- if-statement - 在 Google 表格中获取指向此单元格的链接
- c - 为什么 putw on 用 getw 显示正确的输出,而 fprintf 和 printf 只用 scanf 显示正确的输出?
- reactjs - Reactjs 从另一个组件调用函数
- java - 创建与现有实体相关的新实体
- dictionary - 在 Java 中计算 HashMap 中的键数
- javascript - 如何在反应导航 5.x 中隐藏选项卡导航(底部选项卡)的标题?
- android - 通过片段中的单选按钮在回收站视图中显示所选项目
- css - 可变字体的工作原理