html - 导航栏中的 Google 自定义搜索引擎搜索栏
问题描述
我使用w3schools 的教程制作了一个水平导航栏,最终看起来像这样,但是当我添加搜索栏时,一切都搞砸了。我该如何解决?
这是我的代码:
<ul>
<li><a class="logo" href="index.html"><img src="Logo.png"></a></li>
<li><a class="text" href="gallery.html">Gallery</a></li>
<li><a class="text" href="#">About Us</a></li>
<li>
<script async src="https://cse.google.com/cse.js?cx=006548796792344891984:w08mnitgeri"></script>
<div class="gcse-search"></div>
</li>
<li style="float: right"><a class="text" href="#">Log-in</a></li>
</ul>
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
li {
float: left;
}
li a.text {
display: block;
color: white;
text-align: center;
padding: 92px 25px;
text-decoration: none;
font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
}
li a.logo {
display: block;
padding: 0px 16px;
}
li a:hover {
background-color: #111;
}
解决方案
尝试附加代码它肯定会工作,如果不评论你的问题,我会尽力帮助你。
在下面的代码中,我创建了一个名为的 id gs
,它负责搜索栏的对齐和大小。
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
li {
float: left;
}
li a.text {
display: block;
color: white;
text-align: center;
padding: 92px 25px;
text-decoration: none;
font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
}
li a.logo {
display: block;
padding: 0px 16px;
}
li a:hover {
background-color: #111;
}
#gs{
width: 72vw;
padding-top: 10vh;
display: inline-block;
}
<!DOCTYPE html>
<html>
<head>
<title>Google Search</title>
</head>
<body>
<ul>
<li><a class="logo" href="index.html"><img src="Logo.png"></a></li>
<li><a class="text" href="gallery.html">Gallery</a></li>
<li><a class="text" href="">About Us</a></li>
<li>
<script async src="https://cse.google.com/cse.js?cx=006548796792344891984:w08mnitgeri"></script>
<div class="gcse-search" id="gs"></div>
</li>
<li style="float: right"><a class="text" href="#">Log-in</a></li>
</ul>
</body>
</html>
推荐阅读
- android - Android Kotlin:Groupie Recycler查看添加到同一个可扩展项目的所有项目
- ios - 缺少 SNS Apple 平台交付失败日志
- html - 正文 rtl 或 ltr 时更改跨度图标
- javascript - 我想使用 reactJS 替换段落中的一个单词
- xcode - 尝试更新变量 SwiftUI Instagram 教程时出现线程 1 错误
- mysql - Laravel 模型用户状态统计
- sql - PowerBI / SQL:语法不正确
- amazon-web-services - lambda 如何响应来自私有 VPC 的 lambda?
- vb.net - VB删除AppData文件夹
- flutter - 为什么可拖动的小部件没有放置在正确的位置?