2

以下のコードはCSSルールclearfix: afterを適用していません。中央にコロンが付いたCSSルールを使用したことがないので、なぜ機能しないのかわかりません。

SCSSファイルに次のコードがあります

.clearfix { zoom: 1;}
.clearfix:before, .clearfix:after {
  content: "";
  display: table;
}
.clearfix:after { clear: both; }

以下は私のhtmlです:

<div id="sidebar1" class="sidebar fourcol first clearfix:after" role="complementary">

  <?php if ( is_active_sidebar( 'sidebar1' ) ) : ?>

    <?php dynamic_sidebar( 'sidebar1' ); ?>

  <?php else : ?>

    <!-- This content shows up if there are no widgets defined in the backend. -->

    <div class="alert help">
      <p><?php _e("Please activate some Widgets.", "bonestheme");  ?></p>
    </div>

  <?php endif; ?>

</div>
4

1 に答える 1

2

HTMLのクラス属性から削除:afterします。

<div id="sidebar1" class="sidebar fourcol first clearfix" role="complementary">

PSあなたのSCSSは大丈夫ですが、同じことを達成するためのより便利な方法は次のとおりです。

.clearfix {
    zoom: 1;

    &:before, &:after {
        content: "";
        display: table;
    }
    &:after {
        clear: both;
    }
}
于 2013-01-18T04:45:56.917 に答える