首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >需要帮助中心我的肚脐链接,因为添加搜索栏在右侧。有没有人?

需要帮助中心我的肚脐链接,因为添加搜索栏在右侧。有没有人?
EN

Stack Overflow用户
提问于 2019-12-20 01:26:52
回答 1查看 28关注 0票数 0

我有我的链接很好地在我的标志下,现在我添加了一个搜索栏,并在右边打开它,因为我想要它,我现在唯一的问题是,我不能使我的链接中心:-/任何人知道一个解决方案,这样我仍然可以集中我的肚脐链接?

代码语言:javascript
复制
                           /*Topnav*/
.topnav { 
    width: 100%; 
    opacity: 1;
    background-color: rgba(255,255,255,0.6);
    margin-bottom: 10px; 
    padding: 5px 0px 5px 0; 
	border-bottom: dotted #66A761;
	border-top: dotted #66A761;
}

.topnav ul {
    text-align: center;
}

.topnav ul li {
    display: inline; 
    margin-left: 15px;	
}

.topnav a {
    font-size: 20px; 
    font-weight: bold; 
    text-decoration: none;
}

.topnav a:visited {
    color: #FFF;
}

.topnav a:link {
    color :#9F257D;
}

.topnav a:hover {
    color: #66A761;
}

.topnav input {
	float: right;
	padding: 3px;
	margin: 0 5px;
}
代码语言:javascript
复制
                           <!--Topnav-->
<div class="topnav">
	<nav>
	<ul>
		<li><a href="aboutblank.html">recepten</a></li>
        <li><a href="aboutblank.html">varianten</a></li>
		<li><a href="aboutblank.html">contact</a></li>
		<li><a href="aboutblank.html">over ons</a></li>
        <input type="text" placeholder="Search..">
	</ul>
	</nav>
</div>

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-12-20 02:06:23

在css上执行以下更改

代码语言:javascript
复制
    .topnav input {
      float: right;
      padding: 3px;
      margin: 0 5px;
      position: absolute; //input will hover on the navbar
      right: 20px; //this gives a bit of padding to the right
    }
    .topnav {
      width: 100%;
      opacity: 1;
      background-color: rgba(255, 255, 255, 0.6);
      margin-bottom: 10px;
      padding: 5px 0px 5px 0;
      border-bottom: dotted #66A761;
      border-top: dotted #66A761;
      position:relative; //this allows the navbar to be the anchor to child elements with position absolute
    }

由于搜索栏的位置是静态的,因此如果将其设置为绝对,则导航按钮不是居中的,它将漂浮在肚脐上。请注意,您必须将导航条更改为相对位置,因为您希望将搜索栏锚定到该元素。

HTML:

代码语言:javascript
复制
<div class="topnav">
    <nav>
    <ul>
        <li><a href="aboutblank.html">recepten</a></li>
        <li><a href="aboutblank.html">varianten</a></li>
        <li><a href="aboutblank.html">contact</a></li>
        <li><a href="aboutblank.html">over ons</a></li>
        <input type="text" style="right:0" placeholder="Search..">
    </ul>
    </nav>
</div>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59418851

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档