css – 具有轮廓和伪元素的Firefox中的奇怪行为

前端之家收集整理的这篇文章主要介绍了css – 具有轮廓和伪元素的Firefox中的奇怪行为前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
当您组合大纲和伪元素时,Firefox的行为与Chrome和Safari(我没有测试过其他浏览器)的行为不同.
有没有办法解决它或这是一个错误
  1. .main {
  2. position: relative;
  3. width: 100px;
  4. height: 100px;
  5. margin: 10px auto;
  6. border: 2px solid #f00;
  7. outline: 2px solid #00f;
  8. }
  9. .main:after {
  10. content: 'Hello';
  11. position: absolute;
  12. width: 100px;
  13. text-align: center;
  14. bottom: -50px;
  15. }
  16. .wtf {
  17. width: 400px;
  18. margin: 90px auto;
  19. }
  1. <div class="main"></div>
  2. <div class="wtf">
  3. <p>In Chrome and Safari the 'Hello' is outside of the outline.</p>
  4. <p>In firefox the outline is extended and the 'Hello' is inside the outline. Bug from Firefox or is there a way to fix this?</p>
  5. </div>

演示:http://codepen.io/romainberger/pen/nuxlh

编辑:
在Firefox 20.0,Chrome 28和Safari 5.1中测试过

解决方法

现在习惯了

盒子阴影

像这样

  1. .main {
  2. position: relative;
  3. width: 100px;
  4. z-index:1;
  5. height: 100px;
  6. margin: 10px auto;
  7. border: 2px solid #f00;
  8. Box-shadow:0px 0px 0px 3px #00f;
  9. }
  10. .main:after {
  11. content: 'Hello';
  12. position: absolute;
  13. text-align: center;
  14. bottom: -50px;
  15. left:0;
  16. right:0;
  17. z-index:2;
  18. }
  19.  
  20. .wtf {
  21. width: 400px;
  22. margin: 90px auto;
  23. }

Demo

猜你在找的CSS相关文章