【发布时间】:2017-03-20 18:44:20
【问题描述】:
我正在使用 CSS 在图像上放置叠加颜色。在 IE、Opera、Chrome 和 Firefox 中一切正常。我在 Safari 中遇到的唯一困难是覆盖显示时出现的文本拒绝在 Safari 浏览器(5.1.7 - Windows)中正确居中。下面是 CSS 代码文本部分的代码。如果您需要更多工作,请告诉我。
.text {
width: 100%;
white-space: nowrap;
margin-left:auto;
text-align: center;
text-align: -moz-center;
text-align: -webkit-center;
margin-right:auto;
color: white;
font-family: "Times New Roman", Times, serif;
font-size: 2.0em;
font-weight: bold;
position: absolute;
overflow: visible;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
z-index: 9;
}
【问题讨论】:
-
HTML 的基本视图会很有用。您的 .text 与您的图片有什么关系?是父母/孩子还是兄弟姐妹?
-
如果宽度为 100%,它将如何居中?
标签: css