Search code examples
htmlcssgoogle-chromepseudo-elementclearfix

Tabbing between links causes issues with pseudo-elements in Chrome


In Chrome, click in the results pane and hit tab to focus on the first link here:

http://jsfiddle.net/2q6c7c36/2/

notice how the contents of .box "jump up" outside of its border? It appears to be caused by the clearfix class I'm using. Is this a bug in Chrome or something I'm doing wrong? I've noticed it when using pseudo elements for icon fonts as well.

Thanks.

.clearfix:after{
    content: ".";
    visibility: hidden;
    display: block;
    height: 0;
    clear: both;
}

Solution

  • demo - http://jsfiddle.net/victor_007/2q6c7c36/3/

    set the content:"." to content:""

    .box {
      border: 2px solid black;
      border-radius: 10px;
      position: absolute;
      float: left;
      width: 318px;
      overflow: hidden;
    }
    .clearfix:after {
      content: "";
      visibility: hidden;
      display: block;
      height: 0;
      clear: both;
    }
    a {
      display: inline-block;
      background-color: #555;
      color: white;
      text-decoration: none;
      font-family: helvetica;
      padding: 3px;
    }
    <div class="box clearfix">
      <a href="#" class="button">Button</a>
      <a href="#" class="button">Button</a>
      <a href="#" class="button">Button</a>
    </div>