html - 不会排队
问题描述
我的搜索按钮不会与我的搜索栏对齐。谁能帮我弄清楚原因。我已经尝试了我知道该怎么做的一切。我也问过其他人,似乎没有人可以帮助我。我确信这是一个简单的修复,只是我是新手,根本无法弄清楚。感谢您的任何帮助..
.tftextinput4 {
background: #ffffff;
border-top: 2px solid #e4e4e4;
border-left: 2px solid #e4e4e4;
border-bottom: 2px solid #e4e4e4;
border-right: 0px solid #e4e4e4;
border-bottom-left-radius: 50px;
border-top-left-radius: 50px;
color: #000000;
float: center;
font-size: 21px;
font-weight: 400;
height: 45px;
margin-top: 40px;
padding: 10px 5px;
text-indent: 10px;
width: 700px;
}
.tfbutton4 {
background: white url(https://www.capebretonstartpage.com/2/images/main/searchbutton.png) left center no-repeat;
background-color: #ffffff;
background-position: 10px;
border-top: 2px solid #e4e4e4;
border-left: 0px solid #e4e4e4;
border-bottom: 2px solid #e4e4e4;
border-right: 2px solid #e4e4e4;
border-bottom-right-radius: 50px;
border-top-right-radius: 50px;
color: #ffffff;
cursor: pointer;
font-weight: 400;
height: 69px;
margin-left: -4px;
text-align: center;
text-decoration: none;
width: 45px;
}
.tfbutton4:hover {
background: white url(https://www.capebretonstartpage.com/2/images/main/searchbutton.png) left center no-repeat;
background-color: #ffffff;
background-position: 10px;
border-top: 2px solid #e4e4e4;
border-left: 0px solid #e4e4e4;
border-bottom: 2px solid #e4e4e4;
border-right: 2px solid #e4e4e4;
border-bottom-right-radius: 50px;
border-top-right-radius: 50px;
color: #ffffff;
cursor: pointer;
font-weight: 400;
height: 69px;
margin-left: -4px;
text-align: center;
text-decoration: none;
width: 45px;
}
.tfclear {
clear:both;
}
<form class="tfnewsearch" action="http://www.amazon.com/s/ref=nb_sb_noss_1?url=search-alias%3Daps&field-keywords=" method="get">
<input type="text" id="tfq" class="tftextinput4" name="q" size="21" maxlength="12000" <?php if(isset($_REQUEST['q'])) echo " value='{$_REQUEST['q']}'"?> autocomplete="off" placeholder="Safe Web Search...">
<input type="submit" value="" class="tfbutton4">
</form>
<div class="tfclear"></div>
解决方案
好吧,有两个原因导致您没有达到预期的效果。
- 您没有
margin-top
像搜索字段那样的提交按钮。 - 因为 both(
inputs
) 是元素的inline-block
类型。display
他们需要vertical-align
像middle
.
因此,这样做将解决您的问题。
片段:
.tftextinput4 {
background: #ffffff;
border-top: 2px solid #e4e4e4;
border-left: 2px solid #e4e4e4;
border-bottom: 2px solid #e4e4e4;
border-right: 0px solid #e4e4e4;
border-bottom-left-radius: 50px;
border-top-left-radius: 50px;
color: #000000;
/*float: center; REMOVED THIS AS IT's INVALID*/
font-size: 21px;
font-weight: 400;
height: 45px;
margin-top: 40px;
padding: 10px 5px;
text-indent: 10px;
width: 700px;
max-width:calc(100% - 57px); /*ADDED THIS so it will never exceed 100%*/
vertical-align: middle; /*ADDED THIS LINE*/
}
.tfbutton4 {
background: white url(https://www.capebretonstartpage.com/2/images/main/searchbutton.png) left center no-repeat;
background-color: #ffffff;
background-position: 10px;
border-top: 2px solid #e4e4e4;
border-left: 0px solid #e4e4e4;
border-bottom: 2px solid #e4e4e4;
border-right: 2px solid #e4e4e4;
border-bottom-right-radius: 50px;
border-top-right-radius: 50px;
color: #ffffff;
cursor: pointer;
font-weight: 400;
height: 69px;
margin-left: -4px;
text-align: center;
text-decoration: none;
width: 45px;
margin-top: 40px; /*ADDED THIS LINE*/
vertical-align: middle; /*ADDED THIS LINE*/
}
.tfbutton4:hover {
background: white url(https://www.capebretonstartpage.com/2/images/main/searchbutton.png) left center no-repeat;
background-color: #ffffff;
background-position: 10px;
border-top: 2px solid #e4e4e4;
border-left: 0px solid #e4e4e4;
border-bottom: 2px solid #e4e4e4;
border-right: 2px solid #e4e4e4;
border-bottom-right-radius: 50px;
border-top-right-radius: 50px;
color: #ffffff;
cursor: pointer;
font-weight: 400;
height: 69px;
margin-left: -4px;
text-align: center;
text-decoration: none;
width: 45px;
}
.tfclear {
clear: both;
}
<form class="tfnewsearch" action="http://www.amazon.com/s/ref=nb_sb_noss_1?url=search-alias%3Daps&field-keywords=" method="get">
<input type="text" id="tfq" class="tftextinput4" name="q" size="21" maxlength="12000" autocomplete="off" placeholder="Safe Web Search...">
<input type="submit" value="" class="tfbutton4">
</form>
<div class="tfclear"></div>
希望这可以帮助你。
干杯!
推荐阅读
- swift - 确定 NSCollectionViewCompositionalLayout 的部分标识符
- sdn - 如何在 cent os 7 中安装 opendaylight 钠
- c++ - 在比较中处理 int 和 std::vector::size_type
- php - koel - 执行 php artisan koel:init 命令时出错
- android - Printooth 不打印图像
- angular - 如何通过单击键盘上的左箭头来调用函数?
- uwp - X:绑定绑定下拉列表到绑定列表
- qt - Qt 安装程序框架:TypeError 无法读取属性名称
- python - 如何修复列表列表索引超出范围
- python - 需要 3 到 5 个位置参数,但给出了 6 个?