14
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Vueで::before、::afterなどの疑似要素を動的に変更する

Last updated at Posted at 2019-08-09

before,afterの疑似要素はDOMではないらしいのでjsからは直接はいじれないらしく、
HTML内にstyleを直書きして、そこを変更する。

<template>
  <div>
    <component is="style">
      .test::after {
        content: '';
        height: {{ lineHeight }}px;
      }
    </component>
    <div class="test"></div>
  </div>
</template>

参考

https://forum.vuejs.org/t/about-using-style-tags-inside-templates/7275/3
https://stackoverflow.com/questions/49516424/use-style-tags-inside-vuejs-template-and-update-from-data-model
2つ目のリンクはrender関数を使用した方法:rolling_eyes:

14
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?