小编Max*_*sey的帖子

HTML 5文件加载图像作为背景图像

是否可以通过HTML 5 File API加载图像并使用javascript/jquery使其成为css背景图像?如果有可能,它是如何完成的?

jquery html5 image file background-image

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

如何阻止Firefox在localhost上缓存textarea的内容?

我在本地工作,有很多<textarea>元素.

但是,每次我重新加载网站时,内容<textarea>仍然存在.这只有在我点击重装/ F5时才会发生.

如果不使用任何浏览器内的功能,我该怎么做才能阻止网站被缓存.

我正在寻找网站内的解决方案,所以当我办公室的其他用户打开它时,他们不会遇到同样的问题.

html javascript firefox caching

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

测试数组是否为空或包含某个对象

我想测试数组是否为空或包含特定结构的对象。在伪代码中,它可能是这样的:

expect([])
  .toHaveLength(0)
  .or
  .arrayContaining(
    expect.toMatchObject(
     { foo: expect.any(String) }
    )
  ) => true

expect([{foo: 'bar'}])
  .toHaveLength(0)
  .or
  .arrayContaining(
    expect.toMatchObject(
     { foo: expect.any(String) }
    )
  ) => true

expect([1])
  .toHaveLength(0)
  .or
  .arrayContaining(
    expect.toMatchObject(
      { foo: expect.any(String) }
    )
  ) => false
Run Code Online (Sandbox Code Playgroud)

也许我对 Jest 中的工作方式的理解是错误的,但对我来说,我的问题看起来像是一个或问题。

javascript testing jestjs

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

在 Windows 10 中无法访问 Docker 容器中的 Hugo 服务器

几天前,我开始了一个小项目:在我的 Windows 10 机器上对我的 Hugo 构建进行 Dockerizing。作为 Linux 容器运行的 Hugo 容器本身是简单的部分并且似乎可以工作(至少通过查看控制台输出

$ docker run --rm -it -p 1313:1313/tcp hugo:latest
Building sites … 
  Replace Autoprefixer browsers option to Browserslist config.
  Use browserslist key in package.json or .browserslistrc file.

  Using browsers option cause some error. Browserslist config 
  can be used for Babel, Autoprefixer, postcss-normalize and other tools.

  If you really need to use option, rename it to overrideBrowserslist.   

  Learn more at:
  https://github.com/browserslist/browserslist#readme
  https://twitter.com/browserslist


WARN 2019/11/23 14:05:35 found no layout file for "HTML" …
Run Code Online (Sandbox Code Playgroud)

docker hugo windows-10

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

HTML 5文件上传事件

我正在尝试使用HTML文件Api上传文件,但我似乎真的不知道怎么做.我必须给getImg()函数什么事件?

HTML

<input id='img' type='file' onchange='getImg(event)'/>
Run Code Online (Sandbox Code Playgroud)

JS

function getImg(evt){
 var files = evt.dataTransfer.files;
 var file = files[0];
console.log(file.name)
Run Code Online (Sandbox Code Playgroud)

javascript html5 file-upload fileapi

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

Flexbox 布局模式:3 个正方形有序(1 个大的左侧,2 个小的右侧堆叠)

我正在尝试使用 Flexbox 实现以下有序布局:

有序的弹性盒布局

HTML:

<ul class="box-wrapper">
    <li class="box boxa">BOX A</li>
    <li class="box boxb">BOX B</li>
    <li class="box boxc">BOX C</li>
</ul>
Run Code Online (Sandbox Code Playgroud)

CSS:

.box-wrapper{
    display:flex;
}
.boxa{
    order: 1;
    // should be: width: 50%;
    // should be: height: 100%;
}
.boxb{
    order: 3;
    // should be: width: 50%;
    // should be: height: 100%;
}
.boxc{
    order: 2;
    // should be: width: 50%;
    // should be: height: 100%;
}
Run Code Online (Sandbox Code Playgroud)

浮动 box-b 和 box-c 似乎不起作用。更改 HTML 布局不是此选项的一种选择。

html css layout flexbox

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