html - CSS 搜索栏无响应
问题描述
在继续使用 JS 之前,我正在使用 HTML 和 CSS 制作响应式 GitHub 主页克隆 ( https://github.com/ )。我目前正在研究搜索栏。但是,当我从左侧缩小屏幕时,搜索栏宽度保持不变,导致搜索栏离开整个左侧导航栏。任何帮助将不胜感激:) PS请查看完整页面视图的代码片段
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
background-color: #f6f8fa;
font-family: Helvetica, sans-serif;
}
#left-menu {
background-color: white;
width: 25%;
display: flex;
flex-direction: column;
}
#left-menu-items {
margin: 40px 15px 300px 25px;
width: 85%;
}
#left-menu input {
background-color: transparent;
border: solid 1px #e1e4e8;
border-radius: 5px;
outline: none;
margin-bottom: 20px;
padding: 8px 113px 8px 10px;
}
#left-menu input::placeholder {
color: #d2d5d8;
font-size: 15px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://kit.fontawesome.com/735c9ee1fa.js" crossorigin="anonymous"></script>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<title>GitHub Homepage</title>
</head>
<body>
<section id="left-menu">
<div id="left-menu-items">
<input type="search" placeholder="Find a repository...">
</div>
</section>
</body>
</html>
解决方案
我正在处理的元素是显示“查找存储库...”的搜索栏为了让框向右伸展,我添加了大量的填充。
嗨,约书亚。
在这种情况下,提出一个包含这么多部分的问题很难回答。如果您可以创建一个较小的示例 - 它可能会有所帮助。
<aside class="sidebar">
<input type="search" placeholder="Find a repository">
</aside>
.
.sidebar {
border: 1px solid blue;
padding: 10px;
}
input[type='search'] {
padding: 5px 10px;
font-style: innherit;
}
https://jsfiddle.net/sheriffderek/smnovwqj/
从那里 - 我们可以帮助你。您也可以随时在CSS Discord中提问。
推荐阅读
- php - 如何在 laravel 集合中只取包含值的键?
- python - 收到的 AttributeError:“str”对象在使用 raster_geometry_mask 时没有属性“get”
- flutter - Flutter:使用 CircleBorder 填充背景的 IconButton - 如何设置大小
- sql - 在 Oracle SQL 中选择列表作为列
- python - Jupyter 在 Ubuntu 16.04 中不执行代码
- powershell - ps1 脚本如何在运行多个工具后设置 $LASTEXITCODE?
- python - 在 pyopencl 中添加复杂的 3D 数组
- javascript - 是否可以创建一个可以使用 JavaScript 从 safari 访问火炬的网络应用程序?
- angular - 角材料从桶进口转向单独进口有什么好处 9
- asp.net - 连接/检查会话无限循环身份服务器 4 v4 asp.net 核心与反应应用程序