LESS - multiple different classes with the same st

2019-09-10 21:59发布

How would you write this style below in LESS?

nav a:hover,
nav a:focus,
footer a:hover,
footer a:focus,
.fullscreen-container a:hover,
.fullscreen-container a:focus {
    text-decoration: none;
}

My attempt:

.text-decoration-none () {
    text-decoration: none;
}

nav a {
    &:focus,
    &:focus {
        .text-decoration-none ();
    }
}

footer a {
    &:focus,
    &:focus {
        .text-decoration-none ();
    }
}

.fullscreen-container a {
    &:focus,
    &:focus {
        .text-decoration-none ();
    }
}

Result:

nav a:focus,
nav a:focus {
  text-decoration: none;
}
footer a:focus,
footer a:focus {
  text-decoration: none;
}
.fullscreen-container a:focus,
.fullscreen-container a:focus {
  text-decoration: none;
}

Ideal result:

nav a:hover,
nav a:focus,
footer a:hover,
footer a:focus,
.fullscreen-container a:hover,
.fullscreen-container a:focus {
    text-decoration: none;
}

Any ideas?

标签: css less
2条回答
聊天终结者
2楼-- · 2019-09-10 22:39
.text-decoration-none () {
    text-decoration: none;
}

nav a, footer a, .fullscreen-container a {
    &:hover,
    &:focus {
        .text-decoration-none ();
    }
}
查看更多
Summer. ? 凉城
3楼-- · 2019-09-10 22:49
nav, footer, .fullscreen-container {
  a {
    &:hover, &:focus {
      text-decoration: none;
    }
  }
}
查看更多
登录 后发表回答