官术网_书友最值得收藏!

  • Mastering CSS
  • Rich Finelli
  • 134字
  • 2021-07-08 09:45:54

BEM

One technique for keeping specificity low is avoiding descendant selectors altogether using BEM. BEM stands for Block Element Modifier and is a naming convention for CSS. The idea is to use a specific naming convention to add a class to every element you are eventually going to style. This way every element has a specificity score of 10, thus every element has the same specificity. There's a lot more to it that just that, and I recommend checking it out at http://getbem.com/ to learn more about it. I tend to use the BEM methodology, but that's not to say descendant selectors need to be completely avoided. I think there's a time and place for them. My suggestion is keep your descendant selectors reasonable and avoid longer descendant selectors with more than 3 levels.

主站蜘蛛池模板: 临西县| 长海县| 赤城县| 漠河县| 潢川县| 平塘县| 临高县| 江北区| 策勒县| 当雄县| 惠水县| 紫金县| 华坪县| 合山市| 冷水江市| 大关县| 阿克陶县| 从江县| 长宁县| 乐平市| 肥城市| 乐清市| 莫力| 仙桃市| 大宁县| 济宁市| 雷山县| 卓资县| 竹溪县| 洱源县| 丹凤县| 广东省| 林芝县| 礼泉县| 镇巴县| 临泽县| 怀仁县| 黎城县| 务川| 乌兰察布市| 稻城县|