小编use*_*295的帖子

选择一个没有特定类的子元素的元素

我的 HTML 的结构是这样的

<div>
    <div>
        <h1>Something</h1>
    </div>
    <div>
        <h1 class='Handle'>Something</h1>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

在事件中div > div没有与类的“把手”我想要的孩子div > div有风格cursor:move;。我将如何在纯 CSS 中执行此操作,甚至可能吗?

css css-selectors

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

乒乓球拍碰撞速度和回弹角度

好吧,我对此进行了很多搜索,但我所能找到的只是人们说像 do pi * 方向,方向是我假设的球进入的角度。但我的问题是,我不知道如何获得球进入的角度,所以我不能这样做。如果有人能解释我如何计算球击中桨帽的角度、反弹后球应给出的速度以及届时应增加的角度,那就太棒了。

感谢您的所有回复!

我的代码的工作原理如下(因此您可以了解我想如何做到这一点):

/* General Paddle Properties */
double PaddleLength = 80;  //Down-wards length of the paddle
double PaddleWidth = 8;  //How thick the paddle is

/* Positioning of user control paddle */
double UserPaddleTop = 0;  //How far away from the top of the screen the paddle is
double UserPaddleLeft = 10;  //How far left from the side of the client rectangle it is

/* Positioning of ai controled paddle */
double AIPaddleTop …
Run Code Online (Sandbox Code Playgroud)

c# pong

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

PHP最强的单向加密/散列方法

我有一个人们可以注册的网站,我需要加密他们的密码.我研究了它,但我发现任何方法都不会受到现代GPU的强大影响.

所以我来向StackOverflow的优秀人士询问,最强大的加密方法是什么,我已尽力阻止人们掌握数据库,但我希望尽可能确保他们的数据是如果数据库以某种方式被盗,那很好.

我想知道的其他事情是,以某种方式随机化密码中的字符会更安全,但是你可以将它们再次随机化以便登录吗?

编辑: 我已经使用了Andrew Moore的bcrypt实现(如何在PHP中使用bcrypt进行散列密码?)并想出这个:

public static function Encrypt($Str,$Salt)
{
    $bcrypt = new \bcrypt();
    return $bcrypt->hash(SERVER_SALT . md5($Str) . $Salt);
}
Run Code Online (Sandbox Code Playgroud)

如果有人发现任何错误或任何弱点,请告诉我.

php passwords password-hash

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

Jquery li点击事件未触发

我一直在使用JQuery,我在JFiddle上尝试了我的代码并且它运行良好但是当我在我的网站上执行它根本不起作用时,基本上我需要在我的用户列表中的列表项被点击时发送事件.

HTML

<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" href="https://dl.dropbox.com/s/r5pzakk4ikvck3t/style.css?dl=1">
        <script src="https://www.dropbox.com/s/2hdvqa4ma51m0pw/jquery-1.9.0.min.js?dl=1"></script>
        <title>Chat</title>
    </head>
    <body>
        <div id="userlist-container">
            <div id="userlist-title">User List</div><br />
        </div>

        <div id="main-container">
            <div id="messages">
            </div>
        </div>

        <div id="control-container">
            <input type="text" id="TxtMessage" placeholder="Message" onKeyPress="SendMsg(event)" style="text-align:center;" >
        </div>

        <div id="alert-container" hidden="hidden">
            <div id="alert-main">
                <span id="alert-content"></span>
            </div>
        </div>
     </body>
</html>
Run Code Online (Sandbox Code Playgroud)

使用Javascript

$("#userlist-container > li").click(function(e) {
    alert("TEST");
    var username = "@" + this.html + " ";
    $("TxtMessage").value(username);
    $("TxtMessage").focus();
});
Run Code Online (Sandbox Code Playgroud)

编辑:

页面加载后,它连接到服务器并添加<li>lalala</li>到内部userlist-container.

javascript jquery click

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

显示内联块,将最终元素推送到其他元素下方

HTML:

<div id='Content'>
<div>
    <div>
        <pre>SOME TEXT</pre>
        <div id='map1' style='width:450px;height:350px;'></div>
    </div>
    <div>
        <pre>SOME TEXT</pre>
        <div id='map2' style='width:450px;height:350px;margin-left:-17px;'></div>
    </div>
</div>
<div style='width:300px;'>
    <h1>Contact Us</h1><br>
    <form action="/Account/Contact" onsubmit="return SubmitMessageForm(this,event,this.childNodes[1]);" method="post">
        <pre style="display:none;"></pre>
        <label>
            <span>Person To Email</span>
            <select name='ToContact' id='ToContact'>
                <option value='0'>Mark</option>
                <option value='1'>Paul</option>
            </select>
        </label>
        <label>
            <span>Name</span>
            <input type="text" id="Name" name="Name"/>
        </label><br>
        <label>
            <span>Your Email</span>
            <input type="email" id="Email" name="Email"/>
        </label><br>
        <label>
            <span>Message</span>
            <textarea name="Message" rows="8" id="Message"></textarea>
        </label><br>
        <label><input style='width:50px;' type="submit" value="Send"/></label>
    </form>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS:

body > div#Content {
    text-align:center;
    white-space:nowrap;
} …
Run Code Online (Sandbox Code Playgroud)

html css

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

如何处理if语句?

我正在尝试尽可能地优化我的代码,对我而言,这意味着最大限度地减少执行的计算量.我有:

for (int i = 0; i < this.Entities.Count; i++) 
{
    if (this.Entities[i].Type == 2)
    {
        if (this.Entities[i].X > this.Bounds.Width + this.SideOffset || this.Entities[i].X < -this.SideOffset)
        {
            this.Entities.Remove(this.Entities[i]);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

并且为了优化它,我在类型检查中嵌套了越界检查,因此它仅在运行检查时运行.我的问题是,如何在C#中处理if语句?是否检查了每个条件,或者我是否可以将两个if语句放在一个中并使其有效地运行相同(如果this.Entities [i] .Type不等于2则不会运行if语句的其余部分)

c#

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

Chrome无法正确识别函数参数

我已经写了一些用于添加事件监听器的跨浏览器代码,然后chrome开始变得时髦,任何人都知道为什么会发生这种情况?

添加事件侦听器代码:

function addEventListener(Elm,Type,Func)
{
    if(Elm.attachEvent)
        Elm.attachEvent((Type.substr(0,2) == 'on' ? Type : 'on'+Type),Func);
    else
        Elm.addEventListener(Type,Func);
}
Run Code Online (Sandbox Code Playgroud)

代码调用方法:

addEventListener(window,'load',SetSize);
addEventListener(window,'resize',SetSize);
Run Code Online (Sandbox Code Playgroud)

错误:

Uncaught TypeError: Object load has no method 'addEventListener' 
Run Code Online (Sandbox Code Playgroud)

您可以非常清楚地看到我已按正确的顺序传递了参数,但它们并未按所述顺序进行解释.

javascript events

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

Type.GetProperties不返回任何属性

我正在尝试遍历类中的每个属性,输出属性的名称和值.但是我的代码没有返回任何属性.

通过以下方式循环:

public class GameOptions
{
    public ushort Fps;
    public ushort Height;
    public ushort Width;
    public bool FreezeOnFocusLost;
    public bool ShowCursor;
    public bool StaysOnTop;
    public bool EscClose;
    public string Title;
    public bool Debug;
    public int DebugInterval = 500;
}
Run Code Online (Sandbox Code Playgroud)

用于遍历所有代码的代码:

foreach (PropertyInfo property in this.Options.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
{
    debugItems.Add("Setting Name: " + property.Name);
    debugItems.Add("Setting Value: " + property.GetValue(this,null));
}
Run Code Online (Sandbox Code Playgroud)

然而,当我改变public ushort Fps;public ushort Fps { get; set; }它会找到它.

c# properties

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