border: none;
margin-top: 8px;
margin-right: 16px;
font-size: 17px;
}
/* 当屏幕宽度⼩于 600px 时,垂直堆叠显⽰菜单选项和搜索框 */ @media screen and (max-width: 600px) {
.topnav a, .topnav input[type=text] {
float: none;
display: block;
text-align: left;
width: 100%;
margin: 0;
padding: 14px;
}
.topnav input[type=text] {
border: 1px solid #ccc;
}
}
CSS 带搜索导航栏 - 带提交按钮
菜鸟教程(runoob)
* {box-sizing: border-box;}
body {
margin: 0;
font-family: Arial, Helvetica, sans-serif;
}
.topnav {
overflow: hidden;
background-color: #e9e9e9;
}
.topnav a {
float: left;
display: block;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
.topnav a:hover {
background-color: #ddd;
color: black;
}
.topnav a.active {
background-color: #2196F3;
color: white;
}
.topnav .search-container {
float: right;
}
.topnav input[type=text] {
padding: 8px;
margin-top: 8px;
font-size: 17px;
border: none;
}
.topnav .search-container button { float: right;
padding: 6px;
margin-top: 8px;
margin-right: 16px;
background: #ddd;
font-size: 17px;
border: none;
cursor: pointer;
}
.topnav .search-container button:hover {
background: #ccc;
}
@media screen and (max-width: 600px) {
.topnav .search-container {
float: none;
}
.topnav a, .topnav input[type=text], .topnav .search-container button { float: none;
display: block;
text-align: left;
width: 100%;
margin: 0;
padding: 14px;
}
.
borderboxtopnav input[type=text] {
border: 1px solid #ccc;
}
}
提交
响应式搜索菜单
导航栏⾥⾯有⼀个搜索框。
调整浏览器窗⼝的⼤⼩, 查看效果。
CSS 带搜索导航栏 - 带搜索图标
菜鸟教程(runoob)
* {box-sizing: border-box;}
body {
margin: 0;
font-family: Arial, Helvetica, sans-serif;
}
.topnav {
overflow: hidden;
background-color: #e9e9e9;
}
.topnav a {
float: left;
display: block;
color: black;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
.topnav a:hover {
background-color: #ddd;
color: black;
}
.topnav a.active {
background-color: #2196F3; color: white;
}
.topnav .search-container {
float: right;
}
.topnav input[type=text] { padding: 6px;
margin-top: 8px;
font-size: 17px;
border: none;
}
.topnav .search-container button { float: right;
padding: 6px 10px;
margin-top: 8px;
margin-right: 16px;
background: #ddd;
font-size: 17px;
border: none;
cursor: pointer;
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论