【发布时间】:2014-12-25 01:22:15
【问题描述】:
我有一个问题,我认为这可能很愚蠢,但我想不通。 我有一个表格,我想对齐两边的元素,问题是我不能把它对齐到右边(红线所在的地方),这是一张图片来展示它:
这是我的 SASS(抱歉,如果不是很整洁,我已经在其中工作了一段时间,可能会很乱):
.contact {
margin: 100px auto 0;
max-width: $half-width;
form {
letter-spacing: 2px;
color: $color4;
input, textarea {
border: 3px solid $color5;
padding: 10px;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
font-size: 16px;
background: $color6;
&:focus {
outline: none !important;
border-color: $color3 !important;
}
textarea {
height: 10em;
width: 100%;
overflow: inherit;
}
}
.info-group {
margin-top: 10px;
label {
display: inline-block;
width: 45%;
float: left;
&:nth-child(2) {
float: right !important;
margin: 0 auto;
}
}
}
.tell-group {
width: 100%;
label {
display: inline-block;
margin-top: 10px;
}
textarea {
height: 10em;
width: 100%;
float: left;
}
}
.submit-wrap {
margin-top: 10px;
float: right;
input {
width: 100px;
font-size: 18px;
text-transform: uppercase;
color: $color6;
background-color: $color5;
border: none;
&:hover {
color: $color1;
}
}
}
}
}
谢谢!
【问题讨论】:
-
转到您的控制台/开发人员工具,并定位所需的元素。它会显示任何影响元素的
padding/margin。相应地删除它。您可能正在使用一些具有预定义样式的框架。 -
只是一种快速测试的方法,在样式表的开头使用
*{padding:0 !important; margin:0 !important;}看看有什么变化。 -
如果你有纯 CSS 问题,我们不需要 Sass。您需要提供重现问题所需的最少 量代码(没有标记,CSS 太多)。