本文将为您提供关于css–Sass:选择具有多个嵌套选择器的父元素的详细介绍,我们还将为您解释css类选择器如何嵌套的相关知识,同时,我们还将为您提供关于Cannotdownloadhttps//gi
本文将为您提供关于css – Sass:选择具有多个嵌套选择器的父元素的详细介绍,我们还将为您解释css类选择器如何嵌套的相关知识,同时,我们还将为您提供关于Cannot download https//github.com/sass/node-sass/releases/download/v4.13.0/win32-x64-72_binding.node、CSS calc()函数中的 Sass 变量 - Sass Variable in CSS calc () function、Dart Sass 失败并出现以下错误:未定义变量 SASS、Dart sass 的 Bootstrap 5 sass的实用信息。
本文目录一览:- css – Sass:选择具有多个嵌套选择器的父元素(css类选择器如何嵌套)
- Cannot download https//github.com/sass/node-sass/releases/download/v4.13.0/win32-x64-72_binding.node
- CSS calc()函数中的 Sass 变量 - Sass Variable in CSS calc () function
- Dart Sass 失败并出现以下错误:未定义变量 SASS
- Dart sass 的 Bootstrap 5 sass
css – Sass:选择具有多个嵌套选择器的父元素(css类选择器如何嵌套)
.books,.dvds,.magazines { article &.books { /* Wanting the selector to only be ".books article" */ } article { /* Can apply to any of the `article` tags under .books,.dvds and .magazines */ } }
我有一些嵌套的选择器,而不是打破一个新的.books文章选择器,我想保持嵌套,但仍然只针对.books下的文章元素.
我确实尝试了这个,但它的确有效,但是输出的是.books.books文章,这篇文章是多余的,让我感到畏缩:
.books,.magazines { &.books article { /* Outputs ".books.books article,.dvds.books article,.magazines.books article"...boooo,hisssss */ } }
解决方法
article { .books &,.dvds &,.magazines & { /* book,dvd,magazine shared stuff */ } .books & { /* book stuff */ } }
编译为:
.books article,.dvds article,.magazines article { /* book,magazine shared stuff */ } .books article { /* book stuff */ }
Cannot download https//github.com/sass/node-sass/releases/download/v4.13.0/win32-x64-72_binding.node
最近在对一个开源的项目前端代码进行打包。结果老是 出现了上面的问题,导致打包失败
# Cannot download https//github.com/sass/node-sass/releases/download/v4.13.0/win32-x64-72_binding.node
确保网络不能太慢
昨晚WIFI太慢了。。。
确保以管理员身份执行命名
特别是 win10 ,执行 前端命名如果不以超级管理员身份执行。那么 可能会导致执行失败
配置npm 淘宝镜像
npm config set registry https://registry.npm.taobao.org
参考 参考网友的
提高下载速度
通过 npm 安装 node-sass
npm uninstall node-sass && npm install node-sass
很多网页都说 通过git 去下载然后手动安装 node-sass , 试过了,并没有用。就这样直接安装就可以了。
安装好直接就可以进入项目目录下面 去执行 npm install 等操作了
可以指定 node-sass 版本安装
node-sass 5 不兼容 node-sass 4 的。如果npm install 报错,可以根据提示信息 指定版本配置
npm uninstall node-sass && npm install node-sass@4.14.1 --save
参考资料
node-sass 安装
sass git下载
指定node-sass 安装
最终还是不行。那么就 使用 npm yarn 来构建了
前端说 yarn 构建更好。 更稳
CSS calc()函数中的 Sass 变量 - Sass Variable in CSS calc () function
问题:
I''m trying to use the calc()
function in a Sass stylesheet, but I''m having some issues. 我正在尝试在 Sass 样式表中使用 calc()
函数,但是遇到了一些问题。 Here''s my code: 这是我的代码:
$body_padding: 50px
body
padding-top: $body_padding
height: calc(100% - $body_padding)
If I use the literal 50px
instead of my body_padding
variable, I get exactly what I want. 如果我使用文字 50px
而不是我的 body_padding
变量,那么我得到的正是我想要的。 However, when I switch to the variable, this is the output: 但是,当我切换到变量时,这是输出:
body {
padding-top: 50px;
height: calc(100% - $body_padding); }
How can I get Sass to recognize that it needs to replace the variable within the calc
function? 如何让 Sass 认识到它需要替换 calc
函数中的变量?
解决方案:
参考一: https://stackoom.com/question/1DRy3/CSS-calc - 函数中的 Sass 变量参考二: https://oldbug.net/q/1DRy3/Sass-Variable-in-CSS-calc-function
Dart Sass 失败并出现以下错误:未定义变量 SASS
如何解决Dart Sass 失败并出现以下错误:未定义变量 SASS
我不明白这个编译错误描述的是什么,因为我确实定义了 SASS 变量:
Dart Sass 失败并出现以下错误:未定义变量。 ╷ 64│颜色:$sc-blue-light; │ ^^^^^^^^^^^^^^^ ╵ _partials/navigation/_search.scss 64:12 @use style.scss 65:1 根样式表
_utilities.scss
$sc-blue-light: #5BC2E7;
_search.scss
.search {
color: $sc-blue-light;
}
_style.scss(主样式表)
@use ''_partials/base/_utilities'';
@use ''_partials/navigation/_search'';
首先加载实用程序,这是我在其他答案中阅读的内容,但不适用于此处。文件路径正确。
我所有的其他样式都可以编译。就在我开始使用变量时,出现此错误。
有什么想法吗?
解决方法
TL;DR
也在 @use
中的文件顶部添加 _search.scss
规则。
带命名空间
@use ''_partials/base/_utilities'';
.search {
color: utilities.$sc-blue-light;
}
或没有命名空间
@use ''_partials/base/_utilities'' as *;
.search {
color: $sc-blue-light;
}
引自官方 sass
使用@use 加载的成员(变量、函数和mixin)只是 在加载它们的样式表中可见。其他样式表将需要 如果他们也想访问它们,请编写自己的@use 规则。
和
最简单的@use规则写成@use "",加载模块 在给定的 URL。以这种方式加载的任何样式都将被准确包含 一次在编译的 CSS 输出中,无论这些样式有多少次 已加载。
了解sass @use members
阅读sass @use namespace
Dart sass 的 Bootstrap 5 sass
如何解决Dart sass 的 Bootstrap 5 sass
我正在尝试在 Django 项目中通过 Dart-sass 设置 Bootstrap 5 sass。
当我开始编译时,我收到了这条消息 “弃用警告:不推荐使用 / 进行除法,并将在 Dart Sass 2.0.0 中删除。”
我开始按照建议将所有文件中的 / 替换为,以解决问题。
直到我遇到问题,我都无法在供应商 >> _rfs.scss 文件中修复它
Error: $number: 1rem,16rem is not a number.
╷
211 │ @if abs($value) <= $rfs-base-value or not $enable-rfs {
│ ^^^^^^^^^^^
╵
这是_rfs.scss
// stylelint-disable property-blacklist,scss/dollar-variable-default
// SCSS RFS mixin
//
// Automated responsive values for font sizes,paddings,margins and much more
//
// Licensed under MIT (https://github.com/twbs/rfs/blob/master/LICENSE)
// Configuration
// Base value
$rfs-base-value: 1.25rem !default;
$rfs-unit: rem !default;
@if $rfs-unit != rem and $rfs-unit != px {
@error "`#{$rfs-unit}` is not a valid unit for $rfs-unit. Use `px` or `rem`.";
}
// Breakpoint at where values start decreasing if screen width is smaller
$rfs-breakpoint: 1200px !default;
$rfs-breakpoint-unit: px !default;
@if $rfs-breakpoint-unit != px and $rfs-breakpoint-unit != em and $rfs-breakpoint-unit != rem {
@error "`#{$rfs-breakpoint-unit}` is not a valid unit for $rfs-breakpoint-unit. Use `px`,`em` or `rem`.";
}
// Resize values based on screen height and width
$rfs-two-dimensional: false !default;
// Factor of decrease
$rfs-factor: 10 !default;
@if type-of($rfs-factor) != number or $rfs-factor <= 1 {
@error "`#{$rfs-factor}` is not a valid $rfs-factor,it must be greater than 1.";
}
// Mode. Possibilities: "min-media-query","max-media-query"
$rfs-mode: min-media-query !default;
// Generate enable or disable classes. Possibilities: false,"enable" or "disable"
$rfs-class: false !default;
// 1 rem = $rfs-rem-value px
$rfs-rem-value: 16 !default;
// Safari iframe resize bug: https://github.com/twbs/rfs/issues/14
$rfs-safari-iframe-resize-bug-fix: false !default;
// disable RFS by setting $enable-rfs to false
$enable-rfs: true !default;
// Cache $rfs-base-value unit
$rfs-base-value-unit: unit($rfs-base-value);
// Remove px-unit from $rfs-base-value for calculations
@if $rfs-base-value-unit == px {
$rfs-base-value: $rfs-base-value,($rfs-base-value * 0 + 1);
}
@else if $rfs-base-value-unit == rem {
$rfs-base-value: $rfs-base-value,($rfs-base-value * 0 + 1,$rfs-rem-value);
}
// Cache $rfs-breakpoint unit to prevent multiple calls
$rfs-breakpoint-unit-cache: unit($rfs-breakpoint);
// Remove unit from $rfs-breakpoint for calculations
@if $rfs-breakpoint-unit-cache == px {
$rfs-breakpoint: $rfs-breakpoint,($rfs-breakpoint * 0 + 1);
}
@else if $rfs-breakpoint-unit-cache == rem or $rfs-breakpoint-unit-cache == "em" {
$rfs-breakpoint: $rfs-breakpoint,($rfs-breakpoint * 0 + 1,$rfs-rem-value);
}
// Calculate the media query value
$rfs-mq-value: if($rfs-breakpoint-unit == px,#{$rfs-breakpoint}px,#{$rfs-breakpoint,$rfs-rem-value}#{$rfs-breakpoint-unit});
$rfs-mq-property-width: if($rfs-mode == max-media-query,max-width,min-width);
$rfs-mq-property-height: if($rfs-mode == max-media-query,max-height,min-height);
// Internal mixin used to determine which media query needs to be used
@mixin _rfs-media-query {
@if $rfs-two-dimensional {
@if $rfs-mode == max-media-query {
@media (#{$rfs-mq-property-width}: #{$rfs-mq-value}),(#{$rfs-mq-property-height}: #{$rfs-mq-value}) {
@content;
}
}
@else {
@media (#{$rfs-mq-property-width}: #{$rfs-mq-value}) and (#{$rfs-mq-property-height}: #{$rfs-mq-value}) {
@content;
}
}
}
@else {
@media (#{$rfs-mq-property-width}: #{$rfs-mq-value}) {
@content;
}
}
}
// Internal mixin that adds disable classes to the selector if needed.
@mixin _rfs-rule {
@if $rfs-class == disable and $rfs-mode == max-media-query {
// Adding an extra class increases specificity,which prevents the media query to override the property
&,.disable-rfs &,&.disable-rfs {
@content;
}
}
@else if $rfs-class == enable and $rfs-mode == min-media-query {
.enable-rfs &,&.enable-rfs {
@content;
}
}
@else {
@content;
}
}
// Internal mixin that adds enable classes to the selector if needed.
@mixin _rfs-media-query-rule {
@if $rfs-class == enable {
@if $rfs-mode == min-media-query {
@content;
}
@include _rfs-media-query {
.enable-rfs &,&.enable-rfs {
@content;
}
}
}
@else {
@if $rfs-class == disable and $rfs-mode == min-media-query {
.disable-rfs &,&.disable-rfs {
@content;
}
}
@include _rfs-media-query {
@content;
}
}
}
// Helper function to get the formatted non-responsive value
@function rfs-value($values) {
// Convert to list
$values: if(type-of($values) != list,($values,),$values);
$val: '''';
// Loop over each value and calculate value
@each $value in $values {
@if $value == 0 {
$val: $val + '' 0'';
}
@else {
// Cache $value unit
$unit: if(type-of($value) == "number",unit($value),false);
@if $unit == px {
// Convert to rem if needed
$val: $val + '' '' + if($rfs-unit == rem,#{$value,($value * 0 + $rfs-rem-value)}rem,$value);
}
@else if $unit == rem {
// Convert to px if needed
$val: $val + '' '' + if($rfs-unit == px,($value * 0 + 1) * $rfs-rem-value}px,$value);
}
@else {
// If $value isn''t a number (like inherit) or $value has a unit (not px or rem,like 1.5em) or $ is 0,just print the value
$val: $val + '' '' + $value;
}
}
}
// Remove first space
@return unquote(str-slice($val,2));
}
// Helper function to get the responsive value calculated by RFS
@function rfs-fluid-value($values) {
// Convert to list
$values: if(type-of($values) != list,$values);
$val: '''';
// Loop over each value and calculate value
@each $value in $values {
@if $value == 0 {
$val: $val + '' 0'';
}
@else {
// Cache $value unit
$unit: if(type-of($value) == "number",false);
// If $value isn''t a number (like inherit) or $value has a unit (not px or rem,just print the value
@if not $unit or $unit != px and $unit != rem {
$val: $val + '' '' + $value;
}
@else {
// Remove unit from $value for calculations
$value: $value,$value * 0 + if($unit == px,1,($rfs-rem-value));
// Only add the media query if the value is greater than the minimum value
@if abs($value) <= $rfs-base-value or not $enable-rfs {
$val: $val + '' '' + if($rfs-unit == rem,$rfs-rem-value}rem,#{$value}px);
}
@else {
// Calculate the minimum value
$value-min: $rfs-base-value + (abs($value) - $rfs-base-value),$rfs-factor;
// Calculate difference between $value and the minimum value
$value-diff: abs($value) - $value-min;
// Base value formatting
$min-width: if($rfs-unit == rem,#{$value-min,#{$value-min}px);
// Use negative value if needed
$min-width: if($value < 0,-$min-width,$min-width);
// Use `vmin` if two-dimensional is enabled
$variable-unit: if($rfs-two-dimensional,vmin,vw);
// Calculate the variable width between 0 and $rfs-breakpoint
$variable-width: #{$value-diff * 100,$rfs-breakpoint}#{$variable-unit};
// Return the calculated value
$val: $val + '' calc('' + $min-width + if($value < 0,'' - '','' + '') + $variable-width + '')'';
}
}
}
}
// Remove first space
@return unquote(str-slice($val,2));
}
// RFS mixin
@mixin rfs($values,$property: font-size) {
@if $values != null {
$val: rfs-value($values);
$fluidVal: rfs-fluid-value($values);
// Do not print the media query if responsive & non-responsive values are the same
@if $val == $fluidVal {
#{$property}: $val;
}
@else {
@include _rfs-rule {
#{$property}: if($rfs-mode == max-media-query,$val,$fluidVal);
// Include safari iframe resize fix if needed
min-width: if($rfs-safari-iframe-resize-bug-fix,(0 * 1vw),null);
}
@include _rfs-media-query-rule {
#{$property}: if($rfs-mode == max-media-query,$fluidVal,$val);
}
}
}
}
// Shorthand helper mixins
@mixin font-size($value) {
@include rfs($value);
}
@mixin padding($value) {
@include rfs($value,padding);
}
@mixin padding-top($value) {
@include rfs($value,padding-top);
}
@mixin padding-right($value) {
@include rfs($value,padding-right);
}
@mixin padding-bottom($value) {
@include rfs($value,padding-bottom);
}
@mixin padding-left($value) {
@include rfs($value,padding-left);
}
@mixin margin($value) {
@include rfs($value,margin);
}
@mixin margin-top($value) {
@include rfs($value,margin-top);
}
@mixin margin-right($value) {
@include rfs($value,margin-right);
}
@mixin margin-bottom($value) {
@include rfs($value,margin-bottom);
}
@mixin margin-left($value) {
@include rfs($value,margin-left);
}
我希望您能帮助我解决这些弃用问题。 谢谢
解决方法
这是 Dart SASS > 1.32.0 版本的一个已知问题
见:https://github.com/twbs/bootstrap/issues/34051
解决方法 #1 = 使用 Dart SASS =
解决方法 #2 = 将
--quiet-deps
添加到命令sass
行。 (您仍然会收到警告,但仅限于 5 条。忽略它们。--quiet
删除所有消息。)
今天关于css – Sass:选择具有多个嵌套选择器的父元素和css类选择器如何嵌套的分享就到这里,希望大家有所收获,若想了解更多关于Cannot download https//github.com/sass/node-sass/releases/download/v4.13.0/win32-x64-72_binding.node、CSS calc()函数中的 Sass 变量 - Sass Variable in CSS calc () function、Dart Sass 失败并出现以下错误:未定义变量 SASS、Dart sass 的 Bootstrap 5 sass等相关知识,可以在本站进行查询。
本文标签: