【问题标题】:pseudo-selector :before not positioning correctly in IE9,10伪选择器:在 IE9,10 中未正确定位之前
【发布时间】:2014-06-25 09:58:47
【问题描述】:

我遇到了一个无法解决的问题。我在一个相对定位的容器内有一个绝对定位的伪选择器:before,该容器在除 IE9 和 10 之外的所有内容中都正确定位。

我花了一些时间研究这个问题并尝试实现thirtydot's solution mentioned here

这是代码示例:http://jsfiddle.net/66d25/20/

在所有其他浏览器中,引号正确显示在包含块引用段落的左上角。在 IE9/10 中,引号不正确地位于引号气泡的中间顶部。

我尝试将overflow:visible 添加到包含的 p 标记中,但这并没有解决问题。我还在下面包含了我的 scss。对此问题的任何见解将不胜感激。

    blockquote {
        border-left: none;
        padding: 0;
        margin: 2em 0 1em 0;
        position: relative;
        &:after, &:before {
            top: 100%;
            border: solid transparent;
            content: '';
            height: 0;
            width: 0;
            position: absolute;
            pointer-events: none;
            display:block;
        }
        p {
            color: shade($charcoal, 20%);
            margin: 0;
            background: #fff;
            @include border-radius(5px);
            @include box-shadow(inset 0 2px 0 rgba(70, 130, 180, 0.7), -5px -4px 25px rgba(0, 0, 0, 0.3));
            font-size: emCalc(17px);
            color: adjust-lightness($charcoal, 20%);
            font-weight: 400;
            line-height: 1.5em;
            font-style: italic;
            text-indent: 2em;
            position: relative;
            padding: 1em;
            overflow:visible;
            &:before {
                content: "\201C";
                font-family: serif;
                font-style: normal;
                font-weight: 700;
                position: absolute;
                font-size: 5.5em;
                top: 15px;
                left: -50px;
                color: $blue;
                text-shadow: 7px 14px 10px rgba(0, 0, 0, 0.1);
                display: block;
                height: 25px;
                width: 25px;
            }
        }

        footer {
            padding-top: 1em;
            cite {
                text-align: right;
                text-transform: uppercase;
                font-weight: 700;
                font-size: 1.25em;
                font-style: normal;
                color: $vblue;
                text-shadow: 0 1px 1px rgba(255,255,255,0.7);
                &:before {
                    content: '';
                }
            }
            &:before {
                content: '';
                position: absolute;
                border-style: solid;
                border-width: 15px 15px 0;
                border-color: #FFFFFF transparent;
                display: block;
                width: 0;
                z-index: 1;
                margin-left: -15px;
                bottom: 33px;
                left: 80%;
            }   

        }
    }

【问题讨论】:

    标签: css internet-explorer position internet-explorer-9 internet-explorer-10


    【解决方案1】:

    删除:

    p {
        text-indent: 2em;
    }
    

    解决了 IE11 上的问题:http://jsfiddle.net/66d25/22/

    将报价放回您打算放置的位置可以通过以下方式实现:

    p {
        text-indent: 34px; /* font-size is 17px so 2em=34px*/
    }
    

    演示:http://jsfiddle.net/66d25/23/

    所以问题出在em 单元上,像素很好。去弄清楚为什么 IE 会这样做......

    【讨论】:

    • 感谢您解决这个问题。我实施了这个建议,它似乎解决了水平定位的问题,认为垂直定位仍然关闭。我将尝试用填充像素和任何其他适当的选择器替换 em 单位,看看它是否有所作为。
    猜你喜欢
    • 1970-01-01
    • 2014-08-06
    • 1970-01-01
    • 1970-01-01
    • 2017-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-29
    相关资源
    最近更新 更多