我有一个固定在我的网页侧面的div.我需要将div垂直居中.使用CSS轻松完成:(注意:div的基本高度为300px;)
#sidePanel { margin: -150px 0 0 0; top: 50%; position: fixed;}
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是这个sidePanel div保存我的网站导航.当导航打开以显示子元素时,它会在高度上增长,从而影响居中.我需要一些jQuery来重新计算sidePanel div的高度,并应用适当的负边距以保持div居中.这是我正在玩的jQuery:
$("#sidePanel").css("margin-top", $(this).outerHeight());
Run Code Online (Sandbox Code Playgroud)
我没有进行计算以将负值边距设置为高度的一半,但这并没有给出我正在寻找的高度值.有什么建议??
我遇到了这个php ucfirst(),使大写字母成为字符串中每个单词的第一个字符.
$foo = 'hello world!';
$foo = ucfirst($foo);
Run Code Online (Sandbox Code Playgroud)
但是如何使用正则表达式和preg_match()来检查,然后显示错误信息?
if (preg_match('/\b\p{Ll}/', $mem_titlename))
{
$error = true;
echo '<error elementid="mem_titlename" message="TITLE - please use uppercase for each word."/>';
}
Run Code Online (Sandbox Code Playgroud)
不知道上面的例子中那个表达式意味着什么,但我从某个地方得到它,它与ucfirst()做同样的工作......
我刚刚使用Visual Studio 2010进行单元测试.我想知道是否有一个工作流允许我创建一系列适用于接口的测试,然后将这些接口测试应用于任何和所有实现的类界面.
例如,说我有以下界面.
public interface IAnimal
{
public string Name {get;}
public string Speak();
}
Run Code Online (Sandbox Code Playgroud)
我显然可以有许多实现此接口的类.
public class Dog:IAnimal
{
public string Name {get{return "Dog";}}
public string Speak{return "BARK BARK";}
public bool LickBalls();
}
public class Cat:IAnimal
{
public string Name {get{return "Cat";}}
public string Speak{return "MEOW MEOW";}
public bool Scratch();
}
Run Code Online (Sandbox Code Playgroud)
所以我想定义一系列适用于所有人的测试 IAnimals
public TestAnimalName(IAnimal animal)
{
Assert.IsFalse(string.IsNullorEmpty(animal.Name));
}
public TestAnimalSpeak(IAnimal animal)
{
string sound = animal.Speak();
Assert.IsFalse(string.IsNullOrEmpty(sound));
}
Run Code Online (Sandbox Code Playgroud)
然后我想定义一个TestAnimal()
可用于测试任何方法的主方法IAnimal
.
TestAnimal(IAnimal animal)
{
TestAnimalName(animal); …
Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我创建了我的自定义类,我正在使用KVO观察其属性之一,因此如果其值发生更改,它会立即显示在firstview控制器对象(标签或...)中
示例代码
myCustomClass.h
@interface myCustomClass : NSObject {
NSString * text;
}
@property (nonatomic, retain) NSString * text;
- (void)changetext;
Run Code Online (Sandbox Code Playgroud)
myCustomClass.m
@implementation myCustomClass
@synthesize text;
static myCustomClass * _sharedInstance;
- (id)init
{
if ((self = [super init])) {
text = @ "";
}
return self;
}
+ (myCustomClass *)sharedInstance
{
if (!_sharedInstance) {
_sharedInstance = [[myCustomClass alloc] init];
}
return _sharedInstance;
}
- (void)changetext {
text = @ "changed";
}
Run Code Online (Sandbox Code Playgroud)
firstViewController.h
@interface FirstViewController:UIViewController {
IBOutlet UILabel * label;
}
@property …
Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我试图从DateTime字段拆分日期和时间,以便我可以在日期上放置一个jQuery日期选择器.我找到了Hanselman用于拆分DateTime的代码,但是我遇到了编译错误bindingContext.ValueProvider.TryGetValue(modelName, out valueResult);
.我得到的错误是:
错误3'System.Web.Mvc.IValueProvider'不包含'TryGetValue'的定义,并且没有可以找到接受类型'System.Web.Mvc.IValueProvider'的第一个参数的扩展方法'TryGetValue'(你错过了吗? using指令或程序集引用?)C:\ Documents and Settings\xxx\My Documents\Visual Studio 2008\Projects\MyProject\Project\Helpers\DateAndTimeModelBinder.cs 83 42项目
我错过了什么?我创建了一个新类,并将他的代码放在我项目的Helpers文件夹中.
我编写了一个淡入淡出的表单,显示了一段时间,然后淡出.衰落是通过计时器实现的,该计时器也关闭表格.它工作正常.
我以模态方式显示表单,但我怀疑主表单在开始表单关闭之后才开始构建和显示.
然后我想,如果我以非模态方式显示表单并使用fsStayOnTop(即SplashForm.Show而不是SplashForm.ShowModal),那么只要显示启动表单,主表单就可以在启动表单后面初始化,这意味着应用程序已准备就绪当飞溅形式关闭时去.
然而,我发现计时器事件不再发生.也没有TApplication.OnIdle事件.是什么赋予了?
研究以下片段:
public class ExampleA {
static class Pair<F,S> { }
static <F,S> Pair<F,S> anyPair() { return null; }
static <F,S> void process(Pair<F,S> p1, Pair<F,S> p2) { return; }
public static void main(String[] args) {
Pair<String,Integer> p = anyPair();
process(p, anyPair()); // doesn't compile
}
}
Run Code Online (Sandbox Code Playgroud)
有人可以解释为什么类型推断适用于局部变量的赋值p
但不适用于第二个实际参数process
吗?
这可能更容易理解:
public class ExampleB {
public static <E> void process(Set<E> s1, Set<E> s2) { return; }
public static void main(String[] args) {
process(new HashSet<String>(), Collections.emptySet()); // doesn't compile …
Run Code Online (Sandbox Code Playgroud) 我曾经尝试过几次在linux上使用Eclipse,但经常发现它会崩溃,随机消失等等.
最近我开始在Windows上使用它 - 特别是Helios PDT版本,因为我是一个php开发人员.
一般情况下这很好,但是当我在FTP网站上使用RSE"直接"进行编辑时,我发现当我尝试保存文件时,我会得到空指针错误和所有排序,而且它经常会失败.我知道FTP非常蹩脚,但在许多客户运行自己的服务器的情况下,我都能访问它.
所以这真的是两个问题:1.有一种明显的方式以稳定的方式运行eclipse吗?也许我应该为JVM提供一些设置?等等.我确保我没有下载任何测试版或预发行版.我得到的印象是Eclipse非常糟糕.有什么类似的吗?我是一个emacs用户,所以无论如何 - 它都需要emacs密钥绑定功能.
我是一名5年的Python程序员,但很快我也将使用PHP.考虑到我的Python技能,您能否向我推荐一些与该语言联系的读物?
php ×3
c# ×2
iphone ×2
java ×2
.net ×1
asp.net-mvc ×1
datetime ×1
delphi ×1
eclipse ×1
eclipse-pdt ×1
generics ×1
ios4 ×1
jquery ×1
linux ×1
modelbinders ×1
non-modal ×1
objective-c ×1
preg-match ×1
python ×1
regex ×1
timer ×1
unit-testing ×1