小编luk*_*443的帖子

如何获得相等的输入宽度和选择字段

在表单上,​​我有一个选择和两个输入字段.这些元素垂直对齐.不幸的是,我无法获得这些元素的相等宽度.

这是我的代码:

<select name="name1" style="width:198px">
  <option>value1</option>
  <option>value2</option>
</select><br/>
<input type="text" name="id1" style="width:193px"><br/>
<input type="text" name="id2" style="width:193px">
Run Code Online (Sandbox Code Playgroud)

对于上面的例子,select元素的最佳宽度是198或199 px(当然我尝试了193px,但差别很大).我认为,这取决于各种计算机和浏览器的分辨率,因为这些元素没有相同的宽度(有时我认为差异大约是1或2像素).我试图在div或table行中设置这些元素,但它没有帮助.

问:我如何才能获得这些元素的精确宽度?

html css html-select border-box

107
推荐指数
3
解决办法
10万
查看次数

Window.open并通过post方法传递参数

使用window.open方法我打开带有参数的新站点,我必须通过post方法传递.我找到了解决方案,但不幸的是它不起作用.这是我的代码:

<script  type="text/javascript">    
function openWindowWithPost(url,name,keys,values)
{
    var newWindow = window.open(url, name);

    if (!newWindow) return false;

    var html = "";
    html += "<html><head></head><body><form id='formid' method='post' action='" + url +"'>";

    if (keys && values && (keys.length == values.length))
        for (var i=0; i < keys.length; i++)
            html += "<input type='hidden' name='" + keys[i] + "' value='" + values[i] + "'/>";

    html += "</form><script type='text/javascript'>document.getElementById(\"formid\").submit()</sc"+"ript></body></html>";

    newWindow.document.write(html);
    return newWindow;
}
</script>  
Run Code Online (Sandbox Code Playgroud)

接下来,我创建数组:

<script type="text/javascript">    
var values= new Array("value1", "value2", "value3") 
var keys= new Array("a","b","c") 
</script> …
Run Code Online (Sandbox Code Playgroud)

javascript

84
推荐指数
6
解决办法
31万
查看次数

正则表达式 - 前瞻性断言

我有先行断言(?=)的问题.例如,我有表达式:

/Win(?=2000)/
Run Code Online (Sandbox Code Playgroud)

它匹配Win,如果表达式是Win2000,Win2000fgF.我有下一个表达式:

^(?=.*\d)(?=.*[a-z]).*$
Run Code Online (Sandbox Code Playgroud)

它匹配数字和小写字母,例如:45dF,4Dd.但我不知道,为什么它的工作和匹配所有字符:)我没有字符,这是以前(?=.*\d).我想,只有这个表达式应该有效:

^.\*(?=.*\d)(?=.*[a-z]).*$
Run Code Online (Sandbox Code Playgroud)

(\*在表达之前).

你能解释一下吗?

regex regex-lookarounds

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