html - 表单中的按钮定位问题

标签 html css

如果你看我的网站http://goo.gl/GchAbB您会注意到“确定”绿色按钮并没有像我希望的那样放置在弹出新闻稿框中输入字段的左侧(另请参见下图)。我不明白的是元素完美地定位在 jsfiddle

所以我想我的代码的其他部分与时事通讯表单冲突,但无法弄清楚是什么以及如何解决这个问题。

谢谢你的帮助

编辑:根据 John C 的发现更新了代码

enter image description here

/******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 *****/

enter image description here

最佳答案

快速浏览显示您的 <form>宽度为 60%。这会将盒子向下推。此外,您的 .newsletter-button margin 不正确。 (它继承了将其向下推的右边距)

[编辑] 我建议设置:

.newsletter-button { margin : 0; }
form.form-newsletter { width: 100%; }

关于html - 表单中的按钮定位问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24590305/

相关文章:

javascript - 如何允许用户动态调整表格的高度?

html - Fieldset 会破坏 Edge、FF、Chrome 中的布局,但不会破坏 IE11 中的布局?

html - 使用 flex 方向列时如何将 div 水平居中对齐

ModalpopupExtender 上的 Jquery 工具提示

javascript - 以 1 秒为间隔计数 1-10 并在 div 类框中打印

HTML 页面背景图像显示在 Node js 服务器中

javascript - 如果滚动到顶部或底部 div,则防止向一个方向滚动

php - Opera 字符集 UTF-8

html - 链接在 IE6 中消失,在它之前添加链接时重新出现

html - CSS3 中的 div 没有阴影