html - 尝试并排获取两个 HTML 输入

标签 html css input

所以我花了一些时间试图解决这个问题,但我最终转向 StackOverflow 寻求帮助。我试图让我的搜索栏和转到按钮显示在一行上,但在执行此操作时遇到了问题。

输入的 html 代码是:

  <nav class="sidebar"> 
  <input type="text"  id="search" placeholder="search">
  <input type="button" name="button" value="Go" class="goButton">
  </nav>

两个输入的CSS如下:

#content .sidebar #search {
    width: calc( 100% - 45px );
    border-radius: 0px;
    height: 42px;
    text-align: center;
    color: #333333;
    font-size: 14px;
    margin-bottom: 21px;
}
/* Go button for search*/
#content .sidebar .goButton {
    position: relative;
    top: -48px;
    width: 45px;
    background-color: #BA2022;
    color: #F3EBDE;
    border-style: none;
    text-transform: uppercase;
    margin-top: 8px;
    border-radius: 0px;
    height: 42px;
    text-align: center;
    font-size: 14px;
    margin-bottom: 21px;
}

有人可以建议解决这个问题吗?目前,输入显示如下:

enter image description here

提前致谢。

最佳答案

当文本框变小一点并且按钮的 margin-top 被移除时,它会对齐:

#content .sidebar #search {
    width: calc( 100% - 60px );
    border-radius: 0px;
    height: 42px;
    text-align: center;
    color: #333333;
    font-size: 14px;
    margin-bottom: 21px;
}
/* Go button for search*/
#content .sidebar .goButton {
    position: relative;
    width: 45px;
    background-color: #BA2022;
    color: #F3EBDE;
    border-style: none;
    text-transform: uppercase;
    margin-top: 8px;
    border-radius: 0px;
    height: 42px;
    text-align: center;
    font-size: 14px;
    margin-bottom: 21px;
}

fiddle :http://jsfiddle.net/s0y93L87/

关于html - 尝试并排获取两个 HTML 输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27347425/

相关文章:

css - div覆盖另一个div内容

asp.net - 在 ASP.NET 网站中使用 css 仅显示图像并使其余页面褪色

javascript - 在 div 下传递的链接仍然可以点击吗?

c++ - 在 C++ 的一行中插入多个输入

python - 更改换行符 .readline() 查找

QtWebkit 和 QWebElement - 获取用户输入?

html - python 3 Selenium : can't find element visible on screen

html - 水平和垂直居中 div 并在调整父级大小时保持居中

css - 使用 3d css 转换翻转时,Firefox 不会隐藏卡片的背面

html - 悬停CSS时闪烁的颜色