由于某些原因,我的CSS的填充和边距不起作用
.optinfield {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
display: inline-block;
}

<div class="row clearfix" data-mode="optin">
<div class="column full" >
<div class="margin-20" style="text-align: center;">
<form accept-charset="UTF-8" id="optin-form" action="http://localhost:3000/landing_pages/optin" method="post">
<input id="optin-external-id" name="optin_external_id" type="hidden" value="{optin_external_id}">
<input id="optin-tags" class="optinfield" name="tags" type="hidden" value="">
<input id="optin-redirect-url" name="redirect_url" type="hidden" value="http://">
<input id="optin-from-url" name="from_url" type="hidden">
<input id="optin-first-name" class="optinfield" name="contact[first_name]" placeholder="First Name" required="required" type="text" >
<br>
<input id="optin-last-name" class="optinfield" name="contact[last_name]" placeholder="Last Name" required="required" type="text">
<br>
<input id="optin-email" class="optinfield" name="contact[email]" placeholder="Email" required="required" type="email" >
<br>
<div style="margin:1em 0 2.5em;">
<input class="btn btn-primary full-width" id="optin-submit" name="commit" title="Add me to the list." type="submit" value="Submit">
<br>
</div>
</form>
<script type="text/javascript">
document.getElementById("optin-submit").addEventListener("click", function(clickEvent) {
document.getElementById("optin-from-url").value = window.location.href
});
</script>
</div>
</div>
</div>
&#13;
我已经读过一些问题,如果我设置display: inline-block;
它应该有用,但对我来说它仍然不起作用。
我错过了什么吗?
答案 0 :(得分:1)
似乎工作正常。你期待什么?
document.getElementById("optin-submit").addEventListener("click", function(clickEvent) {
document.getElementById("optin-from-url").value = window.location.href
});
&#13;
.optinfield {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
display: inline-block;
}
&#13;
<div class="row clearfix" data-mode="optin">
<div class="column full">
<div class="margin-20" style="text-align: center;">
<form accept-charset="UTF-8" id="optin-form" action="http://localhost:3000/landing_pages/optin" method="post">
<input id="optin-external-id" name="optin_external_id" type="hidden" value="{optin_external_id}">
<input id="optin-tags" class="optinfield" name="tags" type="hidden" value="">
<input id="optin-redirect-url" name="redirect_url" type="hidden" value="http://">
<input id="optin-from-url" name="from_url" type="hidden">
<input id="optin-first-name" class="optinfield" name="contact[first_name]" placeholder="First Name" required="required" type="text">
<br>
<input id="optin-last-name" class="optinfield" name="contact[last_name]" placeholder="Last Name" required="required" type="text">
<br>
<input id="optin-email" class="optinfield" name="contact[email]" placeholder="Email" required="required" type="email">
<br>
<div style="margin:1em 0 2.5em;">
<input class="btn btn-primary full-width" id="optin-submit" name="commit" title="Add me to the list." type="submit" value="Submit">
<br>
</div>
</form>
</div>
</div>
</div>
&#13;
答案 1 :(得分:1)
答案 2 :(得分:1)
&#34; optinfield&#34; 20px填充正在输入字段内而不是外部移动文本。 如果你想移动所有块 - 带有图像和文本的表单 - 所有这些都在右边,你应该改变容器div的宽度,现在设置为&#34;列满#34;或者给它你需要的空间。 你也有一些课程&#34; margin-20&#34;我不知道它是什么, 您已经上传了表单,表单没有问题:)
答案 3 :(得分:0)
我最终添加了!在填充和边距结束时非常重要而且效果很好