.information-btn{ width: 130px; height: 40px; background-color: #1122FF; font-size:20px; font-weight: bold; color: #fff; border-radius: 10px; }<script > var newBtn = document.getElementById("new-btn"); newBtn.addEventListener("click", function() { window.localhost.href = "insert.html"; }); </script> <div style="width:100%;"> <button class="information-btn" type="submit" id="all-btn">全部员工</button> <button class="information-btn" type="submit" id="new-btn">添加员工</button> <button class="information-btn1" type="submit" id="chaxun-btn">查询</button> <input type="text" id="chaxun-text" name="chaxuntext" placeholder="请输入要查询的员工信息" value=""> </div>为什么跳转不了,没有反应
时间: 2023-07-19 15:43:30 浏览: 57
您的 JavaScript 代码中有一个小错误,应该使用 `window.location.href` 而不是 `window.localhost.href`。以下是正确的代码:
```javascript
var newBtn = document.getElementById("new-btn");
newBtn.addEventListener("click", function() {
window.location.href = "insert.html";
});
```
请注意,如果您的 "insert.html" 文件不在当前目录下,您需要提供正确的相对路径或绝对路径。如果代码中仍然存在问题,请检查浏览器的控制台是否有错误消息。
相关问题
.login-btn, .register-btn { display: inline-block; padding: 10px 20px; border: 1px solid #ccc; background-color: #fff; color: #333; text-align: center; text-decoration: none; cursor: pointer; font-size: 16px; font-weight: bold; }改成分开的两个
可以将 `.login-btn` 和 `.register-btn` 分别设置样式,如下:
```css
.login-btn {
display: inline-block;
padding: 10px 20px;
border: 1px solid #ccc;
background-color: #fff;
color: #333;
text-align: center;
text-decoration: none;
cursor: pointer;
font-size: 16px;
font-weight: bold;
}
.register-btn {
display: inline-block;
padding: 10px 20px;
border: 1px solid #ccc;
background-color: #fff;
color: #333;
text-align: center;
text-decoration: none;
cursor: pointer;
font-size: 16px;
font-weight: bold;
}
```
在上面的样式中,`.login-btn` 和 `.register-btn` 分别设置了相同的样式,这两个样式在属性上是一样的。只是通过分别设置 `.login-btn` 和 `.register-btn` 来实现不同的样式细节,可以根据实际需要进行调整。
.login-btn { width: 250px; height: 20px; background-color: #B0E0E6; color: #fff; padding: 30px 25px; border-radius: 4px; cursor: pointer; float: right; }什么意思
这段代码定义了一个CSS样式类名为`login-btn`的样式规则,该规则将应用于页面中所有使用该类名的元素。
以下是该样式规则中各属性的解释:
- `width: 250px;`:设置元素的宽度为250像素。
- `height: 20px;`:设置元素的高度为20像素。
- `background-color: #B0E0E6;`:设置元素的背景颜色为浅蓝色。
- `color: #fff;`:设置元素内部文字的颜色为白色。
- `padding: 30px 25px;`:设置元素内边距为30像素(上下)和25像素(左右)。
- `border-radius: 4px;`:设置元素边框的圆角半径为4像素。
- `cursor: pointer;`:设置鼠标移动到元素上时的光标形状为手型。
- `float: right;`:将元素向右浮动。
这些属性组合起来,定义了一个宽度为250像素、高度为20像素、背景颜色为浅蓝色、白色文字、圆角边框、可点击的按钮。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)