html - 工具提示的最大宽度在 Firefox 38 中不起作用,但在 Chromium 中起作用

标签 html css firefox chromium

我有一个输入的工具提示,我正在尝试设置一个 max-width,或者基本上是

"If the text is smaller than 300px, tooltip width should be the necessary to contain the element. If the text occupies more than 300px, line break and contain it."

在这个 fiddle 中:http://jsfiddle.net/hrfz442d/11/它适用于 Chromium,但在 Firefox 38 中,它没有考虑 max-width,并且似乎有一个它正在使用的固定宽度。

Firefox JSFiddle:

Firefox

CSS:

.tooltip {
    position: relative;
    display: inline;
}
.tooltip span {
    position: absolute;
    /*min-width: 100px;*/
    max-width: 150px;
    color: #FFFFFF;
    background: #327FBA;
    min-height: 32px;
    line-height: 16px;
    text-align: center;
    visibility: hidden;
    border-radius: 5px;
    font-size: 12px;

    display: table;
    padding: 0 10px; /* optional */
}
.tooltip span:after {
    content: '';
    position: absolute;
    top: 50%;
    right: 100%;
    margin-top: -8px;
    width: 0;
    height: 0;
    border-right: 8px solid #327FBA;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
}
.tooltip:hover span {
    visibility: visible;
    opacity: 0.9;
    left: 100%;
    top: 50%;
    margin-top: -16px;
    margin-left: 15px;
    z-index: 999;
}

HTML:

<div class="tooltip">
     <input type="text" placeholder="Nombre/s" name="dp_nombre">
     <span>Nombre completo asd as dasd as dasd</span>
</div>

编辑:事实上,我将工具提示的文字更改为 a a a a 并且 Firefox 使用尽可能小的宽度来包含这些文字,然后在每个文字(字母)之后换行,所以我现在有 4 行。

最佳答案

添加 width: 100%,并删除 display: table(你不需要它)。

关于html - 工具提示的最大宽度在 Firefox 38 中不起作用,但在 Chromium 中起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30378106/

相关文章:

javascript - 使用jquery使图像从左到右显示

css - 我们可以在实践中使用 CSS 2.1 选择器吗?

html - 背景图片不会显示

html - 如何将图像放在文本的右侧?

google-chrome - anchor 内跨度内 anchor , Chrome

javascript - 使用 Javascript 检查 Safari 中的互联网连接时出现奇怪的响应

javascript - 如何在另一个不同样式的div中正确显示选中的属性?

javascript - 对嵌套跨度使用 XRegExp.matchRecursive

html - 使用 HTML <select> 标签时,更改的 'selected' 值未在 Firefox 中显示

javascript - 保存位置的可排序 Div