我试图获得第一个a:在div中悬停以获得不同的右边距,但我在此论坛上找到的解决方案似乎都没有被浏览器识别(我使用的是Chrome版本45.0. 2454.93米).
html:
<div id="example">
<a href="something1.html">Link 1</a>
<a href="something2.html">Link 2</a>
<a href="something3.html">Link 3</a>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
a:hover {
margin: 0px -1px;
}
#example:first-child:hover {
margin-left: 0px;
}
Run Code Online (Sandbox Code Playgroud)
这完全被忽略了,只是在悬停时使用a:hover margin.
完整源代码如下:
HTML:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>removed</title>
<link href="css/main.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="container">
<div id="heading">
<h2>HOME</h2>
<hr>
<h3>removed</h3>
</div>
<img src="images/css_dev_smaller.png" alt="" width="5472" height="3648" id="image_main" />
</div>
<div id="nagivation">
<a href="index.html">Home</a> | <a href="removed.html">removed</a> | <a href="removed.html">removed</a>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
CSS:
@charset "utf-8";
html,body {
margin: 0px; …Run Code Online (Sandbox Code Playgroud) 我有一个搜索栏,当用户点击Enter(这是有效的)时使用javascript函数提交表单,因为它没有提交按钮,但我需要使用php来处理文本框中的数据.表单正在提交,但在帖子上它无法抓取搜索文本框中的内容.
这是代码:
<form id="siteWideSearch" name="siteSearch" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
<input id="homeSearch" type="text" maxlength="100" onkeypress="startSiteSearch(event);" />
</form>
Run Code Online (Sandbox Code Playgroud)
使用Javascript:
if (event.keyCode == 13) {
document.getElementById("siteWideSearch").submit();
}
Run Code Online (Sandbox Code Playgroud)
PHP:
if($_SERVER["REQUEST_METHOD"] == "POST") {
echo "<script type=\"text/javascript\">window.alert(\"Post reached. Yay!!\");</script>";
echo "<script type=\"text/javascript\">window.alert(\"Search Criteria: ".trim($_POST['homeSearch'])."\");</script>";
}
Run Code Online (Sandbox Code Playgroud)
我得到弹出窗口说帖子已经到达,但第二个弹出窗口只输出"搜索标准:"而没有别的.