Html 表单中的按钮定位问题
如果你看我的网站,你会注意到OK绿色按钮没有放在弹出式新闻通讯框中输入字段的左侧,因为我希望它也能看到下面的图片。我不明白的是,元素完全位于 因此,我猜我的代码中还有其他部分与时事通讯表单冲突,但无法找出解决方法 谢谢你的帮助 编辑:根据John C的发现更新代码Html 表单中的按钮定位问题,html,css,Html,Css,如果你看我的网站,你会注意到OK绿色按钮没有放在弹出式新闻通讯框中输入字段的左侧,因为我希望它也能看到下面的图片。我不明白的是,元素完全位于 因此,我猜我的代码中还有其他部分与时事通讯表单冲突,但无法找出解决方法 谢谢你的帮助 编辑:根据John C的发现更新代码 /******NEWSLETTER *****/ #newsletterpopup { display: none; width: 400px; padding:10px; line-height:1
/******NEWSLETTER *****/
#newsletterpopup {
display: none;
width: 400px;
padding:10px;
line-height:14px;
}
#newsletterpopup h1{
font-size: 16px;
padding-bottom: 20px;
font-weight:600;
text-transform: uppercase;
}
#newsletterpopup p{
font-size: 14px;
font-weight:300;
padding-bottom: 20px;
}
.non-merci {
padding-top: 20px;
position: absolute;
text-align: center;
bottom: 5px;
right: 5px;
font-size: 12px;
color: white;
padding: 8px 18px;
margin: 18px 0 0 0px;
text-decoration: none;
background: rgba(71, 186, 255, 0.8);
-webkit-transition: background 0.3s ease;
-moz-transition: background 0.3s ease;
-ms-transition: background 0.3s ease;
-o-transition: background 0.3s ease;
transition: background 0.3s ease;
cursor: pointer;
}
.non-merci:hover {
background: rgba(71, 186, 255, 1);
}
.newsletter-field {
display: block;
width: 240px;
height: 30px;
float:left;
padding-right: 10px;
margin-bottom: 20px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-color: #d9d9d9;
border-right-color: #d9d9d9;
border-bottom-color: #d9d9d9;
border-left-color: #d9d9d9;
border-top-style: dotted;
border-right-style: dotted;
border-bottom-style: dotted;
border-left-style: dotted;
background-color: #efefef;
line-height: 1.38;
color: #444444;
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
animation-direction: alternate;
-moz-animation-direction: alternate;
-webkit-animation-direction: alternate;
-o-animation-direction: alternate;
}
.newsletter-button {
display: block;
width: 40px;
height: 32px;
margin-left: 10px;
background-color: rgb(202, 224, 84);
font-size: 14px;
font-weight: 400;
text-align: center;
color: #fff;
}
/****** END NEWSLETTER *****/
在.newsletter按钮中,您有剩余的边距:10px;。如果您将其更改为0,它将与字段左对齐。快速浏览显示您的宽度为60%。这会将盒子向下推。此外,.newsletter按钮上的边距不正确。它继承了将其向下推的右边距 [编辑] 我建议设置:
.newsletter-button { margin : 0; }
form.form-newsletter { width: 100%; }
谢谢我已经根据你的建议更新了代码,你可以检查链接,但这并不能解决问题。我把边距放在左边10px,以便在输入字段和按钮之间留出一些空间。css,第207行,我仍然看到10px。当我通过开发工具更改它时,它会左对齐。按钮上的margin-right也会移动它,迫使它向下移动到输入字段的自然流下方。谢谢。我已经解决了这个问题,按钮用于其他东西是造成冲突谢谢。事实上,这是因为我有两份表格,一份需要60%,但通讯没有。我是否应该将新闻稿表单命名为form2或其他什么,并将宽度设置为100%?还是保持形式,为时事通讯添加宽度为100%的类?我刚刚尝试添加一个类,但现在OK按钮位于x non merci按钮的后面,仍然位于输入字段的下方,但级别不同:-/