我想为我的网站创建一个导航栏,其中包括一些链接和它上的公司标志.链接应该有定制的间距在他们和意味着一些首先和一些最后的右边.我还想包括一个转换,当链接悬停时,链接的字体大小增加,而不影响或移动附近的链接或内容.我遇到了一个问题,因为字体增加了,邻居链接自己改变了,以保持利润率差距.我应该在代码中更改或添加什么才能做到这一点?
我基本上是try 使用链接‘a’的悬停子类.它起到了作用,但并不完美,它改变了邻国的联系.我使用每个链接的左边距和右边距,并 for each 链接分配唯一的边距.当我将鼠标悬停在一个链接上时,其他每个链接都会自动切换以保持各自的边距.我认为在这种情况下使用边距属性好吗,或者我应该使用浮动如果是,那么如何在特定距离对齐它们.我在结束时提供了我的代码的在线编辑链接.
或者下面是我的部分css代码
body {
font-family: Arial, sans-serif;
line-height: 1.5;
background-color: #f7f7f7;
margin: 0;
}
header {
background-color: black;
}
.navigation-bar {
width: 100%;
height: 76px;
display: flex;
padding: 10px;
align-items: center;
}
.logo img {
position: relative;
left: 20%;
height: 80px;
width: auto;
}
.navigation-links {
display: flex;
list-style: none;
margin: 0;
padding: 0;
}
.navigation-links li {
display: inline-block;
margin-left: 90px;
margin-right: 0px;
}
.navigation-links li a {
font-size: 25px;
color: white;
text-decoration: none;
text-align: center;
}
.navigation-links li a:hover {
font-size: 30px;
}
/* join now class */
.navigation-links li a.special1 {
font-size: 25px;
font-weight: bold;
color: white;
margin-left: 60px;
margin-right: 0px;
text-decoration: none;
border: 2px solid rgb(226, 19, 54);
border-radius: 50px;
padding: 15px 10px;
background-color: rgb(226, 19, 54);
}
/* login class */
.navigation-links li a.special2 {
font-size: 25px;
font-weight: bold;
color: white;
margin-left: 2px;
margin-right: 0px;
text-decoration: none;
border: 2px solid white;
border-radius: 50px;
padding: 15px 40px;
background-color: black;
}
/*resposive nature*/
@media screen and (max-width: 768px) {
.navigation-links {
display: none;
}
}
<!DOCTYPE html>
<html lang="en">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato">
<head>
<title>Navigation Bar Example</title>
<link rel="stylesheet" type="text/css" href="styles2.css">
</head>
<body>
<header>
<div>
<nav class="navigation-bar">
<div class="logo">
<img src="rocket-g9cbacc798_1280.png" alt="Company Logo" >
</div>
<ul class="navigation-links">
<li><a href="#">Home</a></li>
<li><a href="#">Projects</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">About</a></li>
<li ><a class="special1"href="#">JOIN NOW</a></li>
<li ><a class="special2" href="#">LOG IN</a></li>
</ul>
</nav>
</div>
</header>
<!-- Rest of the content -->
</body>
</html>
代码链接-https://codepen.io/Divyansh-Sharma-the-flexboxer/pen/JjmgJVy