小编ZYi*_*nMD的帖子

为什么具有z-index值的元素不能覆盖其子级?

今天,经过四个小时的调试,我很难学到了这个规则:

如果父级的z-index值为任何值,则无论您如何更改子级的CSS,父级元素都永远无法覆盖(堆叠在其子级元素之上)

我如何通过逻辑理解这种行为?规范在哪里覆盖?

代码(也在CodePen中):

.container {
  width: 600px;
  height: 600px;
  background-color: salmon;
  position: relative;
  z-index: 99;
  margin-top: 20px;
  padding-top: 10px;
}

h1 {
  background-color: pink;
  position: relative;
  z-index: -1;
  font-family: monospace;
}
Run Code Online (Sandbox Code Playgroud)
<div class="container">
  <h1>1. I can never be covered by parent if my z-index is positive.</h1>
  <h1>2. Even when my z-index is nagative, I still can never be covered if my parent has any z-index at all.</h1>
</div>
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

css z-index css-position

11
推荐指数
1
解决办法
1007
查看次数

在Git for Windows的安装路径中,./git-bash.exe和bin/bash.exe和bin/sh.exe有什么区别?

在 git for windows 的安装路径中,我发现了这 3 个 exe:

./git-bash.exe,

./bin/bash.exe,

./bin/sh.exe,

启动它们中的任何一个都会给我一个可用的终端。

第一个是安装创建的开始菜单中的默认快捷方式,第二个在VSCode doc中用于在VSCode中设置集成终端,第三个在ConEmu doc中提到。

它们之间有什么区别,我应该使用哪个?

git git-bash

10
推荐指数
1
解决办法
1310
查看次数

是否可以在普通页面中嵌入跨域隔离的 iframe?

(对于某些人来说,这个问题可能等于“如果我不能sharedArrayBuffer在我的主站点中使用,我可以打开一个 iframe 并sharedArrayBuffer在 iframe 内部使用吗?”)

所以我想在我的站点中使用一些带有sharedArrayBuffer的wasm,但是使站点跨域隔离是不切实际的,所以我创建了另一个站点https://my-wasm-function.app,它跨域隔离的。我希望将它用作 iframe,并通过 与我的主站点进行通信postMessage

然而,我发现一旦它作为 iframe 嵌入,它就失去了隔离状态。

2021 年 3 月曾有人提出过类似的问题,当时接受的答案是“否”。然而,最近的一篇谷歌博客文章似乎暗示不然,所以我想再问一遍。

该博文有一些关于如何隔离 iframe 的模糊说明,其中之一是添加标题Cross-Origin-Resource-Policy: cross-origin(我认为在COOP和 的顶部COEP),我尝试过,但没有成功。还有一个就是这样打开iframe:<iframe allow="cross-origin-isolated">,我也尝试了,也没用。

webassembly sharedarraybuffer cross-origin-embedder-policy cross-origin-opener-policy cross-origin-resource-policy

6
推荐指数
1
解决办法
3744
查看次数

fs.opendir() 创建的 fs.Dir 上的异步迭代器后 dir.close() 出错

2021 年更新:已在2021 年 4 月提交的Nodejs文档中修复了歧义


编辑:这本质上是节点文档的问题。请参阅此处的讨论。


我正在尝试自节点 v12.12 以来添加的fs.Dir类:

// hello-world.js
const fs = require('fs');

(async function () {
  const dir = await fs.promises.opendir(__dirname);
  for await (const dirent of dir) {
    console.log('name:', dirent.name, 'isDir:', dirent.isDirectory());
  }
  return dir.close();
})();

Run Code Online (Sandbox Code Playgroud)
$ node hello-world.js
Run Code Online (Sandbox Code Playgroud)

它似乎按预期工作,记录了目录中每个文件的信息(没有丢失任何一个),但最终它抛出(node:3218) UnhandledPromiseRejectionWarning: Error [ERR_DIR_CLOSED]: Directory handle was closed at Dir.close (internal/fs/dir.js:161:13). 我究竟做错了什么?

node.js

5
推荐指数
1
解决办法
488
查看次数

溢出换行:任何地方和溢出换行:断字之间的区别?

关于新的 css 规范overflow-wrap

MDN所说的与exceptbreak-word相同anywhere

在计算最小内容固有大小时,不考虑分词引入的软换行机会。

这是什么意思?

css

5
推荐指数
1
解决办法
1214
查看次数

在React组件中,foo(){}和bar =()=> {}之间的区别是什么?我何时应该使用哪个?

巴贝尔正在发挥其魔力,这使我对正在发生的事情感到非常困惑.

这个反应组件中foo和bar之间有什么区别?什么时候应该使用哪个?

class MyComponent extends Component {
  foo() {
    //...
  }
  bar = () => {
   //... 
  }
}
Run Code Online (Sandbox Code Playgroud)

(我自己的猜测是foo在原型中,bar在构造函数中?反正我不知道我在说什么)

javascript reactjs

3
推荐指数
1
解决办法
141
查看次数

运行“npm version”脚本时,如何防止进行新提交

当我运行时npm version patch,将进行新的提交。我不想要它。

文档相当模糊。我认为相关的标志是commit-hooks,但我不确定如何使用它。没有例子。

我尝试过不同的模式,例如:

npm version patch --commit-hooks=false

npm version patch --commit-hooks false
Run Code Online (Sandbox Code Playgroud)

但这似乎不起作用。

npm npm-scripts

3
推荐指数
1
解决办法
5341
查看次数

如何从 WSL 中获取 Windows 用户主目录 (/mnt/c/Users/username) 的路径?

我需要/mnt/c/Users/username从 WSL 中获取 Windows 用户主目录的路径,它是否存储在某处?

如果没有,是否username存储在某处?我只是假设这/mnt/c/Users部分没有改变。

谢谢!

windows-subsystem-for-linux

2
推荐指数
1
解决办法
1323
查看次数

如何解决打字稿对 Array.includes() 过于严格的问题

什么是修复以下代码且对可读性影响最小的干净方法?

操场

type Fruit = "apple" | "orange";
type Food = Fruit | "potato";

const fruits: Fruit[] = ["apple", "orange"];

function isFruit(thing: Food) {
  return fruits.includes(thing); // "potato" is not assignable to type 'Fruit'.
}
Run Code Online (Sandbox Code Playgroud)

typescript

1
推荐指数
1
解决办法
61
查看次数