小编Sin*_*ein的帖子

滚动超出顶部或底部时操纵浏览器窗​​口的颜色

当我使用触控板滚动时,工具栏和主窗口之间有一个白色间隙(在“这是顶部”标题之上)。您可以在我所附的图片中看到它。仅当我使用触控板(而不是鼠标)滚动超出窗口底部的顶部或底部时,才会出现此间隙。如何设置该背景的颜色超出“正常”窗口?

在此输入图像描述

// 当我不滚动时:

在此输入图像描述

    @import url("960_12_col.css");
    
    #header{
    background-color: blue;
    height: 400px;
    margin-top: 80px;
    margin-bottom: 30px;
    color: white;
    padding-left: 50px;
    padding-top: 40px;
    box-sizing: border-box;
    }
    .grid_4{
    /* 
    text-align: center;
    background-color: red;
    margin-top: 30px;
    height: 250px;
    border: 20px solid black;
    box-sizing: border-box;
     */
    
    }
    .grid_3{
    padding:10px;
    border: 5px solid black;
    margin: 10px;
    height: 140px;
    box-sizing: border-box;
    }
    #comment1{
    text-align: left;
    }
    #comment2{
    text-align: center;
    }
    #comment3{
    text-align: center;
    }
    #comment4{
    text-align: right;
    }
    
    #leftImage{
    }
    
    #centerImage{
    }
    #rightImage{
    }
    .image{
    text-align: center;
    background-color: …
Run Code Online (Sandbox Code Playgroud)

html css colors

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

WebMock 存根请求不工作

在我的 Rails 项目中,其中一个初始化器请求并从S3.

S3.buckets[CONFIG['aws']['cdn_bucket']].objects['object_name'].read
Run Code Online (Sandbox Code Playgroud)

webmock这破坏了使用gem 的rspec 测试套件

WebMock.allow_net_connect!(:net_http_connect_on_start => true)
Run Code Online (Sandbox Code Playgroud)



当我尝试运行测试套件时出现以下错误

WebMock::NetConnectNotAllowedError

You can stub this request with the following snippet:

stub_request(:get, "https://bucket.s3.amazonaws.com/object_name").with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'', 'Authorization'=>'AWS AKxxxxxx:Hyxxxxxxxxxx', 'Content-Type'=>'', 'Date'=>'Thu, 14 Apr 2016 15:10:18 GMT', 'User-Agent'=>'aws-sdk-ruby/1.60.2 ruby/1.8.7 i686-darwin15.3.0'}).to_return(:status => 200, :body => "", :headers => {})
Run Code Online (Sandbox Code Playgroud)

添加此存根并不能修复错误。事实上,添加以下任何内容似乎都不会产生任何改变:

WebMock.stub_request(:any, /.*amazonaws.*/).with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'', 'Authorization'=>'AWS AKIxxxxxxxxxx:MSxxxxxxxx'}).to_return(:status => 200, :body => "stubbed response", :headers => {})
Run Code Online (Sandbox Code Playgroud)


WebMock.stub_request(:any, /.*amazonaws.*/).to_return(:status => 200, :body => "stubbed response", :headers => {})
Run Code Online (Sandbox Code Playgroud)

我在这里缺少什么?错误消息中的详细标头在这里似乎没有意义,允许各种请求S3

编辑: …

ruby rspec ruby-on-rails webmock

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

为什么不允许"空属性块"?

这可能是今天提出的最愚蠢的问题,但无论如何我都要按下:

以下带有重载运算符的派生类,其重载运算符+=的基类[]给出以下编译器错误:

不允许使用空属性块

我当然会写v[0]v[1]操作员+=,但是我很好奇它是否会编译,如果没有,为什么不.

什么是属性块?为什么编译器不解析[0][]运算符,从基类返回引用?只是语法问题或更深层次的问题?

#include <array>

template<class T, int C>
struct Vec
{
    typedef T value_type;
    typedef unsigned index_type;
    typedef unsigned size_type;

    std::array<T, C> v;

    template<typename ...Args>
    explicit Vec(Args&&... args) : v({{args...}}) {}
    Vec(std::array<T, C> const & o) : v(o) {}

    value_type & operator [] (index_type i)
    {           
        return v[i];
    }

    value_type const & operator [] (index_type i) const
    {
        return v[i];
    }
}; 

template<class …
Run Code Online (Sandbox Code Playgroud)

c++ syntax

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

Go 什么时候分配一个新的后备数组来切片?

在阅读 Go 切片时,我在append方法的上下文中遇到了这种行为

如果 s 的后备数组太小而无法容纳所有给定的值,则会分配一个更大的数组。返回的切片将指向新分配的数组。
来源 - Golang Tour

为了理解这一点,我编写了以下代码:

去游乐场试试

func makeSlices() {
    var a []int;

    a = append(a, 0)

    b := append(a, 1)
    printSlice("b", b)

    c := append(a, 2)
    printSlice("b", b)
    printSlice("c", c)

}

func printSlice(name string, s []int) {
    fmt.Printf("var=%v len=%d cap=%d first_address=%v %v\n", name, len(s), cap(s), &s[0], s)
}
Run Code Online (Sandbox Code Playgroud)

输出:

var=b len=2 cap=2 first_address=0x414020 [0 1]
var=b len=2 cap=2 first_address=0x414020 [0 2]
var=c len=2 cap=2 first_address=0x414020 [0 2]
Run Code Online (Sandbox Code Playgroud)

我希望bc指向相同的底层数组,因为它们都是相同长度的切片 …

go slice

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

通过jquery追加添加的元素不会在屏幕上保留

我正在尝试制作待办事项列表应用程序.我使用该append()函数将列表元素附加到我的任务列表中

HTML

<!DOCTYPE HTML>
<html>
  <title>ToDo</title>

  <head>
    <meta charset="UTF-8">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script type="text/javascript" src="script.js"></script>

    <h2>TO DO LIST</h2>
  </head>

  <form name = "taskForm">
    Task: <input type = "text" name = "task" >
          <input type = "submit" id = "submit" value = "ADD">
  </form>

  <ul class = "list">
    <li class = "item"></li>
  </ul>

</html>
Run Code Online (Sandbox Code Playgroud)

脚本

$(document).ready(function(){
  $('input#submit').click(function(){
      var newTask = $('input[name=task]').val();
      $('.list').append('<li class = "item"' + newTask + '</li>');
  });
});
Run Code Online (Sandbox Code Playgroud)

当我点击提交按钮时,我看到新项目在屏幕上闪烁一秒钟,然后自行消失.

为什么我目睹了这种行为?

javascript jquery

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

标签 统计

c++ ×1

colors ×1

css ×1

go ×1

html ×1

javascript ×1

jquery ×1

rspec ×1

ruby ×1

ruby-on-rails ×1

slice ×1

syntax ×1

webmock ×1