- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我仍然不能 100% 确定这是否是使用 BEM 时的正确思维方式,以及通常使用组件样式样式的方式。
假设我们有一个简单的按钮。
.btn {
//wicked styling
}
里面没有间距CSS-Attribute。该按钮位于组件 (.comp1) 内。所以恕我直言,BEM-Mix 来了:
HTML
<div class="comp1">
<a href="comp1__btn btn">Please press me</a>
</div>
CSS
// _comp1.scss
.comp1__btn {
margin-bottom: 20px;
}
第一个问题:如果 .btn 在大多数情况下具有相同的 margin-bottom: 20px 怎么办?我必须每次都使用 BEM-Mix 吗?
//_comp1.scss
.comp1__btn {
margin-bottom: 20px;
}
// _comp2.scss
.comp2__btn {
margin-bottom: 20px;
}
当然我可以在 .btn(margin-bottom:20px)中做一个通用规则,然后在 _comp1.scss 等中覆盖它。但是 scss 的顺序很重要我认为你搞砸了一切?
最佳实践是什么? SASS 扩展?
第二个问题(类似):对于“更大”的组件,比如内部有其他组件的面板,我有一个 _verticalrhythm.scss:
//_verticalrhythm.scss
.comp1,
.comp2,
.comp3 {
margin-bottom: 40px;
}
我最近的元素效果很好 - 但我想知道你们是如何管理这些利润的。
感谢您的回答!
最佳答案
What if the .btn has in most cases the same margin-bottom: 20px? Do I have to everytime a BEM-Mix?
您不应在常规 block 中包含几何或定位样式。参见 https://en.bem.info/methodology/css/#external-geometry-and-positioning了解更多信息。
But then the order of the scss matters I think you mess up everthing?
您可以使用一些 BEM 工具来保证顺序。参见 https://en.bem.info/methodology/build/有关理论信息,请考虑 https://github.com/gulp-bem/gulp-bem-bundle-builder作为现成的实现。
至于垂直节奏,您可以创建特殊 block 以将样式保持在同一位置并在每次需要时混合它。
关于html - BEM 方法论 : Component thinking and spacing,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43063984/
我不明白 RSCSS 和 BEM 之间的区别。有人说 RSCSS,有人说 BEM。 请告诉我两者的区别 最佳答案 RSCSS 只是 BEM 的扩展,加上创建它的团队的一些额外想法和经验。 例如 RSC
在 grunt 文件中 stylelint: { all: ['app/styles/**/*.scss'] }, .stylelintrc { "plugins": [
我正在尝试使用 stylelint 对 BEM 样式进行 lint和 stylelint-selector-bem-pattern plugin但无法让它工作。 我的配置如下: 节点:5.11.0 g
我正在学习 HTML BEM (CSS) 架构,即使在观看了一些 youtube 视频后也不太了解。你们中的任何人都可以查看我的一段代码以查看我的类命名是否正确吗?
我正在尝试使用 BEM 命名约定,并且在决定在何处包含特定页面的修饰符时遇到了一些困难。 例如,假设我有一个橙色按钮: Button A 我的元素有 3 个不同的页面: - pageA.html -
我正在尝试返回到 Web 的前端编码。上一次写 CSS 是在 10 年前,那时候有一种病叫 分类炎 .我对 classitis 的理解可能是错误的,但我认为不要在您的 HTML 文档中放置过多的 CS
在使用 BEM 时,我曾被简单的场景搞糊涂过。示例中有一个基本按钮: .button { // styles for button } 及其具有更具体样式的修饰符: .button.butto
Closed. This question is opinion-based。它当前不接受答案。
所以我试图理解 BEM 命名结构。所以假设我有以下 html {{team.name}} {{team.score}}
在整个站点中定义通用非 block 特定样式的最佳方法是什么? 例如: html foo bar 萨斯/CSS .intro__text { } .profile__text
这是一个理论问题,但它现在困扰了我几个小时。 我正在学习 BEM,到目前为止它很棒,但我遇到了问题。假设我有这段代码: Blah Generated from the CMS 如何定位 p
使用 CSS BEM 方法... 假设我有一些 HTML,像这样(这只是为这个问题编写的示例 HTML): Text. Text. Text. Text.
不知道哪个是官方网站,我找到了getbem.com和 en.bem.info . 有人建议使用 -- 作为修饰符(Naming): CSS class is formed as block’s or
我有一个关于 BEM 中通用 block (例如 .button)与媒体查询样式的问题。 BEM 中的 block (如文档所述)应该具有适用于网站上所有元素的通用样式,假设我有一个 block :
我最近开始使用 BEM 来编写可重用的 CSS 组件。在BEM documentation和其他网站,我发现由于显而易见的原因,不鼓励对标签元素进行全局重置。 但是,当我查看基于 BEM 的网站(包括
最近我开始在我的元素中使用 BEM 来组织 CSS,但现在我已经到了这样的 html: TITLE SUBTITLE 由于我对 SMACSS
... 例如,我将它放在 header 中,它不依赖于 header block 。为了使其对 BEM 友好,我倾向于这样做: ... 这是处理 BEM 的
HTML 布局 social icon here social icon here social icon here social icon
我正在尝试遵循 BEM 命名约定,但我不确定如何实现以下内容:我有一个“工具提示” block ,应该使用不同的主题设置样式。假设我应用了一个“默认”主题。 工具提示可以放置在不同位置的元素周围,这
我是 BEM 的新手,正在处理示例模板: HTML Site branding link link
我是一名优秀的程序员,十分优秀!