首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Sass正在重组我的选择器,它破坏了功能

Sass正在重组我的选择器,它破坏了功能
EN

Stack Overflow用户
提问于 2014-04-25 10:40:30
回答 1查看 96关注 0票数 0

以下是编译后的代码:

代码语言:javascript
运行
AI代码解释
复制
/* line 5, ../scss/_layout.scss */
.tile::after, .tile::before {
  content: '';
  display: block;
  position: absolute;
  z-index: -1;
}

/* line 16, ../scss/_layout.scss */
.tile {
  width: 40px;
  width: 2.5rem;
  height: 40px;
  height: 2.5rem;
  margin-top: 8px;
  margin-top: 0.5rem;
  margin-left: 4px;
  margin-left: 0.25rem;
  position: relative;
}

/* line 23, ../scss/_layout.scss */
.tile::after {
  width: 40px;
  width: 2.5rem;
  height: 40px;
  height: 2.5rem;
  top: 4px;
  top: 0.25rem;
}

/* line 30, ../scss/_layout.scss */
.tile::before {
  width: 48px;
  width: 3rem;
  height: 44px;
  height: 2.75rem;
  top: 4px;
  top: 0.25rem;
  left: -4px;
  left: -0.25rem;
}

/* line 40, ../scss/_layout.scss */
.large {
  width: 248px;
  width: 15.5rem;
  height: 248px;
  height: 15.5rem;
}

/* line 46, ../scss/_layout.scss */
.large::after {
  width: 248px;
  width: 15.5rem;
  height: 248px;
  height: 15.5rem;
}

/* line 51, ../scss/_layout.scss */
.large::before {
  width: 256px;
  width: 16rem;
  height: 252px;
  height: 15.75rem;
}

/* line 5, ../scss/_style.scss */
.tile {
  border-radius: 4px;
  border-radius: 0.25rem;
  background: gray;
}

/* line 11, ../scss/_style.scss */
.tile::after {
  border-radius: 4px;
  border-radius: 0.25rem;
  background: red;
}

/* line 17, ../scss/_style.scss */
.tile::before {
  border-radius: 8px;
  border-radius: 0.5rem;
  background: black;
}

/* line 23, ../scss/_style.scss */
.tile:hover {
  background: cyan;
}

/* line 26, ../scss/_style.scss */
.tile:hover::after {
  background: orange;
}

/* line 29, ../scss/_style.scss */
.tile:hover::before {
  background: blue;
}

scss:

代码语言:javascript
运行
AI代码解释
复制
// Layout


// Pseudo
%pseudo{
    content: '';
    display: block;
    position: absolute;
    z-index: -1;
}

// Default
$width: 48;
$height: 48;

.tile{
    @include size($width - 8, $height - 8);
    @include rem-box(margin, 8, x, x, 4);
    position: relative;
}

// Depth
.tile::after{
    @extend %pseudo;
    @include size($width - 8 , $height - 8);
    @include position(4, x, x, x);
}

// Border
.tile::before{
    @extend %pseudo;
    @include size($width, $height - 4);
    @include position(4, x, x, -4);
}

// Large
$width: 256;
$height: 256;

.large{
    @include size($width - 8, $height - 8);
    //@include rem-box(margin, x, x, x, 4);
}

// Depth
.large::after{
    @include size($width - 8 , $height - 8);
}

// Border
.large::before{
    @include size($width, $height - 4);
}

它从“瓷砖”开始,然后转到“大”,然后返回到“瓷砖”。有什么办法阻止它这样编译吗?我试过用不同的方式筑巢,但什么也没有。我不想创建两个完全不同的div,但是如果我不能解决这个问题,我想我必须要做。我打算让这件事变得更复杂。我只想通过添加类来修改现有的div。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-04-25 14:56:04

它看起来不像是在重新排序任何东西。根据编译的CSS,您的问题是,在两个不同的文件中,选择器.tile实际上有两种不同的样式--一个在_layout.scss中,一个在_style.scss中。来自_layout.scss的定义(包括第一个.tile.large样式)首先放置,然后是_style.scss的定义(包括第二组.tile样式)。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23300654

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档