javascript - 我正在尝试让 css 和 html 工作
问题描述
我试图在单击搜索按钮时显示搜索栏,尽管该按钮甚至没有出现。我得到的最好的就是完全摆脱按钮,但它只给了我一个搜索栏
<style>
.status-menu-container .search-container #search-button {
display: inline-block;
height: 22px;
margin-top: 15px;
color: #DB1C03;
font-size: 2.6em;
vertical-align: middle;
.status-menu-container .search-container #search-box {
display: inline-block;
width: 0;
height: 22px;
overflow: hidden;
margin-top: 13px;
-webkit-transition: width 0.3s;
-moz-transition: width 0.3s;
transition: width 0.3s;
-webkit-backface-visibility: hidden;
vertical-align: middle;
}
</style>
<div class="search-container">
<div id="search-box" class=""><input type="text" value=""></div>
<a id="search-button" href="javascript: void(0);">
<i class="fa fa-search"></i>
</a>
</div>
解决方案
试试这个,你的 css 代码中有一些错误。
我已经在我编辑你的代码的地方发表了评论。
.search-container #search-button {
display: inline-block;
margin-top: 15px; /* why margin top? */
color: #DB1C03;
font-size: 2.6em;
vertical-align: middle;
width: 25px; /* add width */
height: 25px; /* add height */
background: red; /* remove this - added only for clarity */
} /* closed this tag */
.search-container #search-box {
display: inline-block;
width: auto; /* why set width to 0? */
height: 55px; /* remove or adjust this as the height is not enough to show the element */
overflow: hidden;
margin-top: 13px;
-webkit-transition: width 0.3s;
-moz-transition: width 0.3s;
transition: width 0.3s;
-webkit-backface-visibility: hidden;
vertical-align: middle;
}
<div class="search-container">
<div id="search-box" class=""><input type="text" value=""></div>
<a id="search-button" href="javascript: void(0);">
<i class="fa fa-search"></i>
</a>
</div>
推荐阅读
- javascript - 在 Google Apps Script Web 应用程序中动态添加 Materialize 选择输入时出错
- javascript - 在鼠标移动时发送 Ajaxt 请求
- azure - Azure cosmosDB 中的子查询和 GroupBy
- vue.js - 如何通过使用 vuetify 单击按钮来更改背景颜色?
- python - 使用 beautifulsoup 在 python 中构建 webcrawler 的警告
- ios - 如何分配每个 IBAction(在第二个 ViewController 内)以在 TableView 中的特定选择下执行?
- css - 如何处理scss mixin中的引号
- python - 成功训练 Model.fit 但在 collab 上运行 model.predict 时提示资源错误
- python-3.x - 高斯噪声不会应用于整个图像
- python - 计算不相交集的高度