可以使用以下内容设置文本输入的占位符样式:
-webkit-input-placeholder {
color: red;
}
Run Code Online (Sandbox Code Playgroud)
我正在网上看一个网站,我想使用与它们相同的占位符颜色.是否有可能弄清楚他们使用的是什么颜色?我想包含任何alpha值,所以我不能只使用图像编辑器对颜色进行采样.
当我使用Chrome Dev Tools检查元素时,我看到:

在检查输入元素时,开发工具不提供有关占位符元素的信息.还有另外一种方法吗?
我目前在我的代码中到处都有这个JS语句:
window.console && console.log("Foo");
Run Code Online (Sandbox Code Playgroud)
我想知道这是否成本高昂,或者在生产中是否有任何负面影响.
我可以自由离开客户端登录,还是应该离开?
编辑:最后,我认为我(以及其他任何人?)能够提出的最佳论点是,通过留下记录消息,在服务器和客户端之间传输的额外数据可能是不可忽略的.如果生产代码将被完全优化,必须删除日志记录以减少发送到客户端的javascript的大小.
我最近重构了我的一些CSS,并且惊喜地发现了一种更简单的方法来水平对齐我绝对定位的元素:
.prompt-panel {
left: 50%;
transform: translateX(-50%);
}
Run Code Online (Sandbox Code Playgroud)
这很棒!即使我元素的宽度是自动的.但是,我不明白是什么让它真正发挥作用.我的假设是,translateX只是一种现代的,更高效的移动元素的方法,但事实并非如此.
这两个值不应该相互抵消吗?此外,为什么呢
.prompt-panel {
left: -50%;
transform: translateX(50%);
}
Run Code Online (Sandbox Code Playgroud)
没有显示与第一个代码段相同的结果?
我正在使用这段JavaScript生成一个UID:
(原版的:)
//If ID has not been defined then generate a new unique ID.
if(!id){
id = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); return v.toString(16); });
}
Run Code Online (Sandbox Code Playgroud)
(格式化,以便可以阅读:)
// If ID has not been defined then generate a new unique ID.
if (!id) {
id = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(
/[xy]/g,
function (c) {
var r = Math.random() * 16 | 0,
v = …Run Code Online (Sandbox Code Playgroud) 我正在将一个对象从客户端传递给服务器.在此过程中,表示为string.empty的对象的属性将转换为null.当对象类型支持string.empty时,我想知道如何防止这种情况.

console.log("DataToPost:", dataToPost);
$.ajax({
type: "POST",
contentType: 'application/json'
url: "../../csweb/Orders/SaveOrderDetails/",
data: dataToPost,
success: function (result) {
console.log(result);
},
error: function (e) {
console.error(e);
}
});
Run Code Online (Sandbox Code Playgroud)

我的模型包含可空的DateTime对象.我不能强制服务器上的所有空值到string.empty.
我正在使用AutoMapper,所以我不想在服务器上单独检查属性.
我正在验证通过VS2010 SP1获得的HTML5.我的印象是这种简化是可能的:
<script type="text/javascript" src="foo.js">...</script>
Run Code Online (Sandbox Code Playgroud)
至
<script src="foo.js">...</script>
Run Code Online (Sandbox Code Playgroud)
在尝试这个时,我发现:
<head id="Head1" runat="server">
<script src="../Scripts/MicrosoftAjax.js"></script>
</head>
Run Code Online (Sandbox Code Playgroud)
得出这个:
警告1验证(HTML5):元素"脚本"缺少必需的属性"类型".
我错过了什么吗?Visual Studio XHTML5验证是否比HTML5 doc更严格要求?
不确定这是否是一个愚蠢的问题,但我只是注意到了这一点:
public interface IActivityDao : IDao<Activity>
{
IList<Activity> GetAllSinceSequence(long sequence, int count);
}
public class ActivityDao : AbstractNHibernateDao<Core.Domain.Activity>, IActivityDao
{
public IList<Activity> GetAllSinceSequence(long sequence, int maxRecords)
{
}
}
Run Code Online (Sandbox Code Playgroud)
在我的实现中,我调用了第二个参数'maxRecords'.然而,在界面中,它被定义为"计数".编译器仍然认为接口已实现,这很好,但可能会导致一些歧义.显然,我应该重命名其中一个参数以匹配另一个参数.
在重命名之前我玩了一下,发现了一些有趣的东西.我不允许将我的界面声明为:
public interface IActivityDao : IDao<Activity>
{
IList<Activity> GetAllSinceSequence(long, int);
}
Run Code Online (Sandbox Code Playgroud)
这只是编译器对C#语义的过度保护吗?除了使代码更具可读性之外,接口方法中的参数名称的用途是什么?在我看来,如果在实现时不强制参数名称,它会引起歧义.
我有一个文件,检入Git.该文件需要持有API密钥,但出于安全原因,我不希望将API密钥提交给Git.我解释了如何为每个开发人员生成API密钥而不是API密钥.
我不希望任何开发人员意外提交他们的API密钥并覆盖基本文件.
我有:
.gitignore文件中,但是,由于它已经提交,因此不执行任何操作.git update-index --assume-unchanged myFile.js但是,我刚搬到我的笔记本电脑,忘了运行命令,并意外地将一把钥匙交给了回购.我正在寻找一种更加自动防故障的方法.本质上,我想将该文件的初始版本提交给GitHub,然后禁止修改该文件.
这可能吗?
作为参考,该文件看起来像:
define(function () {
// The Simple API Access API key is used here.
// Please note that I've specifically omitted this key from GitHub for security.
// Feel free to generate your own in order to use YouTube's API: https://code.google.com/apis/console/
// A valid key will look something like:
// Key for browser apps (with referers)
// API key: -------------------------------
// Referers: Any referer allowed
// …Run Code Online (Sandbox Code Playgroud) 我正在将BackboneJS(v1.2.2)项目转换为ES6 w/BabelJS.
我注意到以下两者之间存在差异:
import Backbone from 'backbone'
Run Code Online (Sandbox Code Playgroud)
和
import * as Backbone from 'backbone'
Run Code Online (Sandbox Code Playgroud)
看完这里我了解到,前者是进口骨干的默认出口那里,因为后者可以让我"导入整个模块,并通过属性的符号是指其命名为出口."
我很难理解这些之间的区别.在两个实例中都返回对象,但前者似乎使用其他属性/方法进行修饰.至少我认为导入"整个模块"将有更多的属性/方法......但我看到相反的情况.
我有两个目录src和compiled.我想,以确保从单向的数据同步src到compiled与步兵关注.作为中间步骤,我想编译*.less文件以及*.js使用ES6语法编写的文件子集.
我已经成功地编写了我需要的任务:
// NOTE: Spawn must be disabled to keep watch running under same context in order to dynamically modify config file.
watch: {
// Compile LESS files to 'compiled' directory.
less: {
options: {
interrupt: true,
spawn: false,
cwd: 'src/less'
},
files: ['**/*.less'],
tasks: ['less']
},
// Copy all non-ES6/LESS files to 'compiled' directory. Include main files because they're not ES6. Exclude LESS because they're …Run Code Online (Sandbox Code Playgroud) javascript ×5
c# ×2
css ×2
asp.net-mvc ×1
css3 ×1
ecmascript-6 ×1
git ×1
gruntjs ×1
html ×1
html5 ×1
import ×1
jquery ×1
jshint ×1
jslint ×1
logging ×1