html - block 引用伪元素中的绝对位置

标签 html css sass

我一直在使用 :before 和 :after 尝试一些 block 引用样式,在引用后面插入一些漂亮的引号。然而,伪元素的绝对位置似乎没有得到尊重。非常感谢任何指点。

参见:http://codepen.io/anon/pen/hylEn

这是我使用的 SCSS:

$secondarycolor: #c0392b;
$silver: #bdc3c7;

blockquote {
    font-size: 2.5em;
    border-left: 10px solid $secondarycolor;
    margin-left: 30px;
    padding-left: 15px;
    position: relative;

    &:before {
        content: "\201C ";
        position: absolute;
        top: 0;
        left: 15px;
        font-size: 5em;
        color: $silver;
        z-index: -1;
    }

    &:after {
        content: "\201D";
        position: absolute;
        bottom: 0;
        right: 0;
        font-size: 5em;
        color: $silver;
        z-index: -1;
    }
}

最佳答案

演示中缺少 :before position:absolute。在 :after 上,您只是没有考虑到因增加引号中的字体大小而增加的行高。您需要使用负底值来纠正此问题。

&:after {
    content: "\201D";
    position: absolute;
    bottom: -.65em;
    right: 0;
    font-size: 5em;
    color: $silver;
    z-index: -1;
}

关于html - block 引用伪元素中的绝对位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19552862/

相关文章:

javascript - 在我的代码中创建一个登录窗口

css - url中有参数时express stylesheet 404错误

javascript - React beautiful dnd 与 Material UI 列表中的问题

angularjs - 将 Pug 和 SCSS 与 Angular (ng-model) 一起使用

jquery - 到达 div 时更改 ul 样式(滚动)

javascript - 动画期间布局中断

javascript - jQuery 低估了页面上某些元素的宽度和高度

css - Gulp sass 仅在被 gulp watch 触发时编译到错误的目录

ruby-on-rails - Sass 构建的 app/builds/application.css 没有进入标题

javascript - 如果我单击复选框,则尝试阻止 jQuery 触发 table tr onclick 事件