gpt4 book ai didi

html - 如何使导航上方的绿色条在 CSS 中 float

转载 作者:行者123 更新时间:2023-11-28 03:20:02 25 4
gpt4 key购买 nike

当我在浏览器中加载它时,当我将鼠标悬停在导航链接上时会出现绿色条,但我希望它像 http//adworkmedia.com 这样的网站,并且悬停时绿色条 float 到顶部地址栏正下方。我的正好悬停在文本上。这是我的 HTML 和 CSS 代码。另外,如果你能帮我提高我的登录表单几个像素,那也会有帮助的!

HTML:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<meta name="description" content="Site Description">
<meta name="keywords" content="Site Keywords">
<title>AffAttraction | Performance Based Marketing Network</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<header>
<div class="container">
<div id="branding">
<h1>AffAttraction</h1>
</div>
<nav>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="advertisers.html">Advertisers</a></li>
<li><a href="publishers.html">Publishers</a></li>
<li><a href="about.html">About Us</a></li>
<li><a href="contact.html">Contact Us</a></li>
</ul>
</nav>
<div id="header-login">
<form action="publishers/login.php" method="post">
<input type="email" name="email" placeholder="Email">
<input type="password" name="password" placeholder="Password">
<button type="submit" class="btn_1">Login</button>
</form>
</div>
</div>
</header>

</body>
</html>

CSS:

body {
font-family: Arial, Helvetica, sans-serif;
font-size: 15px;
line-height: : 1.5;
margin: 0;
padding: 0;
background-color: #F4F4F4;
}

/* Global */
.container {
width: 80%;
margin: auto;
overflow: hidden;

}

ul {
margin: 0;
padding: 0;
}

/* Header */
header {
color: #FFFFFF;
background-color: #418DD9;
padding-top: 15px;
min-height: 50px;
}

header a {
color: #FFFFFF;
text-decoration: none;
font-size: 16px;
}

header li {
float: left;
display: inline;
padding-right: 20px;
padding-left: 20px;
}

header #branding {
float: left;
}

header #branding h1 {
margin: 0;
}

header nav {
float: center;
margin-top: 10px;
}

header a:hover {
border-top: #00FF1E 3px solid;
}

#header-login {
float: right;
}

#header-login input {
height: 25px;
width: 112px;
float: none;
}

谢谢你能帮我解决这个问题 :D 我是 CSS 的新手 :P

最佳答案

这个效果可以通过在菜单的包含元素上使用边框来实现。基本上,在悬停时,您可以使用指定的 border-width、border-style 和 border-color 创建 border-top,或者使用缩短的 border: border-width border-style 指定所有这些东西边框颜色.

这是工作 fiddle :https://jsfiddle.net/5av9mhrk/

关于html - 如何使导航上方的绿色条在 CSS 中 float ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45258594/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com