我在具有固定“外边距”的 div 内定位可变大小的输入字段和固定大小的发布按钮时遇到问题。
我提供了一个 jfiddle example在哪里可以看到错误的版本。
在这里你可以看到我的问题:
版本错误: Actual website
“应该”版本: This is what it should look like
文字说明:
正如您在第二张图片中看到的,对我来说底部部分始终位于底部很重要...
.submitform {
display: block;
position: fixed;
bottom: 0;
...more on jfiddle...
}
... post 按钮总是在右边。底部的左右间隙应与上部相同。困难的是,输入字段应该具有灵活的大小,但应该占据左侧间隙和后按钮之间的所有空间。
我希望你能帮助我,因为在网络上尝试和搜索的时间并没有给我带来正确的解决方案。
最佳答案
试试这个:http://jsfiddle.net/jgHAA/1/
.submitform {
background: white;
display: block;
position: fixed;
/* Instead of applying margin and width, simply set the bottom, left,
and right properties to 13px */
bottom: 13px;
left: 13px;
right: 13px;
/*box-shadow: 0 2px 7px rgba(0, 0, 0, 0.1);*/
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
padding: 7px;
overflow:hidden;
box-sizing:border-box;
}
要让文本框填充宽度,您可以使用相同的技术:http://jsfiddle.net/jgHAA/2/
.submitform #post_input {
display: block;
font-size: 18px;
border: none;
outline: none;
padding: 3px;
/* set left and right, and z-index to make it appear behind the button.*/
left:7px;
right:7px;
position:absolute;
z-index:-1;
}
关于html - 问题系统的 CSS 输入字段和按钮位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13938445/