Weird behavior in Firefox with outlines and pseudo-elements

前端 未结 2 1592
傲寒
傲寒 2020-12-11 20:31

Firefox behaves differently than Chrome and Safari (I haven\'t tested others browsers) when you combine outline and pseudo-elements. Is there a way to fix it or is this a bu

相关标签:
2条回答
  • 2020-12-11 21:01

    Now used to

    box shadow

    as like this

    .main {
      position: relative;
      width: 100px;
      z-index:1;
      height: 100px;
      margin: 10px auto;
      border: 2px solid #f00;
      box-shadow:0px 0px 0px 3px #00f;
    }
    .main:after {
      content: 'Hello';
      position: absolute;
      text-align: center;
      bottom: -50px;
      left:0;
      right:0;
      z-index:2;
    }
    
    .wtf {
      width: 400px;
      margin: 90px auto;
    }
    

    Demo

    0 讨论(0)
  • 2020-12-11 21:01

    No need to use z-index.

    .main { 
      position: relative;
      width: 100px;
      height: 100px;
      margin: 10px auto;
      border: 2px solid #f00;
      box-shadow:0px 0px 0px 3px #00f;
    }
    .main:after {
      content: 'Hello';
      position: absolute;
      text-align: center;
      bottom: -50px;
      left:0;
      right:0;
    }
    
    .wtf {
      width: 400px;
      margin: 90px auto;
    }
    
    0 讨论(0)
提交回复
热议问题