小编Anu*_*oob的帖子

如何让按钮高度填充网站的垂直空间?

我有一个移动网站,它有 3 个按钮和几行文本。我将文本居中(水平),按钮占据屏幕的整个宽度。但是,我需要缩放按钮的高度以占据整个屏幕。如何使按钮垂直缩放?

<p>PROCRASTINATION TIMER v2.0.0</p>

<span id="current">Currently WAITING</span><br/>
<span>Time to Work: </span><span id="work">Not set.</span><br/>
<span>Time to Derp: </span><span id="derp">Not set.</span><br/>

<button onclick="get_workderp_times();" id="startbutton" style="width:100%;height:33%;">Start</button><br/>
<button onclick="switchstatus('Derp');" id="derpbutton" style="width:100%;height:33%;">Derp</button><br/>
<button onclick="switchstatus('Work');" id="workbutton" style="width:100%;height:33%;">Work</button><br/>

<p>Created by Snake Squared Industries</p>
Run Code Online (Sandbox Code Playgroud)

这是镀铬的,高度设置为 33%:

style="width:100%;height:33%;"
Run Code Online (Sandbox Code Playgroud)

镀铬高度:33%

这是镀铬的,没有设置高度:

style="width:100%;"
Run Code Online (Sandbox Code Playgroud)

镀铬无高度

这是镀铬的,高度设置为 100%:

style="width:100%;height:100%;"
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

(顺便说一下,我查了一下,在IE下结果也是一样的...)

html css

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

在循环中声明时,ArrayList迭代器不起作用

为什么第一个剪辑在无限循环中运行而第二个剪辑有效?

//Initial code
ArrayList<String> myList = new ArrayList<String>();
myList.add("A");
myList.add("B");
myList.add("C");
myList.add("D");
myList.add("E");
while(myList.iterator().hasNext()) {
    System.out.println(myList.iterator().next());
}
System.out.println();



//Correct code
ArrayList<String> myList = new ArrayList<String>();
myList.add("A");
myList.add("B");
myList.add("C");
myList.add("D");
myList.add("E");
Iterator itr = myList.iterator();
while(itr.hasNext()) {
    System.out.println(itr.next());
}
System.out.println();
Run Code Online (Sandbox Code Playgroud)

java

4
推荐指数
2
解决办法
957
查看次数

解决Codility的PermMissingElem测试的正确方法是什么?(JAVA)

我从Codility的代码测试练习中得到以下问题:

给出了由N个不同整数组成的零索引数组A. 该数组包含[1 ..(N + 1)]范围内的整数,这意味着只缺少一个元素.

你的目标是找到缺少的元素.

写一个函数:

class Solution {public int solution(int [] A); }

在给定零索引数组A的情况下,返回缺少元素的值.

例如,给定数组A,使得:

A [0] = 2 A [1] = 3 A [2] = 1 A [3] = 5

函数应该返回4,因为它是缺少的元素.

假使,假设:

N是[0..100,000]范围内的整数; A的元素都是截然不同的; 数组A的每个元素是[1 ..(N + 1)]范围内的整数.

复杂:

预期的最坏情况时间复杂度是O(N); 预期的最坏情况空间复杂度为O(1),超出输入存储(不计算输入参数所需的存储空间).

可以修改输入数组的元素.


我的方法是将给定数组转换为ArrayList,使用ArrayList查找数组中的最低和最高值,并从最低到最高迭代所有可能的值,然后返回缺失值.

这解决了示例问题,但我的问题似乎是在给定数组的以下条件下我无法得到正确的答案:

"空列表和单个元素"

"缺少第一个或最后一个元素"

"单一元素"

"两个要素"

我做错了什么,解决这个问题的正确方法是什么?

java algorithm

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

从类中获取静态字段的值

abstract class A {
    static int i = 5;
}

class B extends A {
    static int i = 6;
}

class C extends A {
    static int i = 7;
}
Run Code Online (Sandbox Code Playgroud)

现在我有一个ArrayList<Class<? extends A>>. 如何从 中获取静态字段的值Class<? extends A>?

java reflection static

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

杰基尔右对齐文字

你如何正确地对齐杰基尔的文字?

我有一个我想要对齐的文本块.

如果它是HTML,我会做类似的事情:

style="text-align:right;"
Run Code Online (Sandbox Code Playgroud)

我怎么能在Markdown和Jekyll一起做到这一点?

text-alignment jekyll

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

使用 Flask 将 URL 加载到 iFrame

我是 Flask 的新手,我正在尝试创建一个类似 Stumbleupon 的网站,但是在将内容加载到 iFrame 时遇到了问题。我只是不知道如何遍历每个 url 并将它们加载到 iFrame 中,同时单击<a>标签。

这是我所做的:

应用程序

from flask import Flask, render_template
app = Flask(__name__)

@app.route("/")
def index():
    urls = [
        'http://www.w3schools.com',
        'http://techcrunch.com/',
        'https://www.fayerwayer.com/',
    ]
    return render_template('index.html', urls=urls)

if __name__ == "__main__":
    app.run(debug=True)
Run Code Online (Sandbox Code Playgroud)

模板/layout.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" type="text/css" href="/static/css/normalize.css"/>
    <link rel="stylesheet" type="text/css" href="/static/css/foundation.css"/>

</head>
<body>
    <nav class="top-bar">
        <h3 align="center"><a href="?????">Stumble</a></h3>
    </nav>

    {% block content %} 
    {% endblock content %}

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

模板/index.html

{% extends 'layout.html' …
Run Code Online (Sandbox Code Playgroud)

python flask

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

将X小时添加到日期和时间

我目前正在获取时间和日期:

DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
Date date = new Date();
System.out.println(dateFormat.format(date));
Run Code Online (Sandbox Code Playgroud)

这将返回示例'05/14/2014 01:10:00'

现在我想做到这一点,所以我可以增加一个小时,而不必担心新的一天或一个月等.

我将如何继续获得'05/14/2014 01:10:00',然后以相同的格式获得10小时后?

提前致谢.

java time calendar date forward

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

从'void*'转换为指向非'void'的指针需要显式转换(第17行)

我正在阅读"学习硬困难的方法"一书,当我尝试运行此程序时,我收到以下错误消息:

从'void*'转换为指向非'''的指针需要显式转换.

我不知道如何解决这个问题,我是否必须更改结构中的返回变量?

看看无论如何,这里的代码:(在Visual C++ 2010上编译,还没有尝试过GCC).

   //learn c the hardway

  #include <assert.h>
  #include <stdlib.h>
  #include <string.h> 
  #include <stdio.h>

  struct Person {
      char *name;
      int age;
      int height;
      int weight; 
  };

  struct Person *Person_create(char *name, int age, int height, int weight) 
  {
      struct Person *who = malloc(sizeof(struct Person)); 
      assert(who != NULL);

      who->name = strdup(name);
      who->age = age; 
      who->height = height;
      who->weight = weight;

      return who;
  } 

  void Person_destroy(struct Person *who)
  {
      assert(who != NULL);

      free(who->name);
      free(who);
  }

  void Person_print(struct Person *who) …
Run Code Online (Sandbox Code Playgroud)

c c++ visual-studio-2010 visual-c++

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

在无限循环中Thread.sleep()有什么好处吗?

我有一个构造,其中变量根据应用程序打开的时间不断更新.

while (playTime < allowedTime) {
    endTimeSec = (int) (System.currentTimeMillis() / MILLISECONDS);
    playTime = endTimeSec - startTime;
}
Run Code Online (Sandbox Code Playgroud)

此检查始终在与我的实际应用程序所在位置不同的线程上运行.我的问题是,因为我基本上都关注到第二次的准确性,Thread.sleep(1000)每次循环迭代都会有什么好处吗?

java multithreading

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

有方法的班级,我不明白班级的样子

我正在阅读"Learn C the Hard Way"一书,并在那里找到了一个代码片段(下面是我的代码,但程序的结构是相同的):

#include <iostream>
#include <string>

using namespace std;

class Person {
private:
    string name;
    int age;
public:
Person(string name, int age) {;
        this->name = name;
        this->age = age;
    }


~Person() {
    }
};

// When whould I do like this?
class Person *Create_person(string name, int age) {
    class Person *person = new Person(name, age);
    return person;
};    

int main() {
    Person *person = Create_person("John", 30);
}
Run Code Online (Sandbox Code Playgroud)

特别注意

class Person *Create_person(string name, int age) {
        class Person …
Run Code Online (Sandbox Code Playgroud)

c++ struct class

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