我想添加一个输入元素,在我的表单中键入文本,但通过这样做,我的表单与页面的页脚重叠。我尝试添加溢出属性,但这不起作用。我对网络开发很陌生,我无法找到解决方案。
这是我的CSS:
* {
margin: 0;
padding: 0;
}
html, body {
height: 99%;
}
.wrapper {
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -100px; /* the bottom margin is the negative value of the footer's height */
}
.footer, .push {
height: 110px; /* .push must be the same height as .footer */
}
.footer {
width: 100%;
/* Set the fixed height of the footer here */
height: 110px;
background-color: #f5f5f5;
}
*
这是我的HTML:
<body>
<div class="wrapper">
<div class="container">
<div class="text-xs-center">
<form id="questionForm" method="post" autocomplete="off">
<label>Question</label></br>
<textarea name="Question" cols="40" rows="4"></textarea></br>
<label>Answers:</label></br>
<input id="1" name="Answer1" type="text"/></br></br>
<input id="2" name="Answer2" type="text"/></br></br>
<button id="addAnswerButton" type="button" class="btn btn-sm btn-primary" onclick="addAnswerField()">Add Answer Field</button></br></br>
<noscript>
<p>Please enable Java-Script to add more answers</p>
</noscript>
<script type="text/javascript">
function addAnswerField(){
var form = document.getElementById("questionForm");
var thisButton = document.getElementById("addAnswerButton");
// find last Index
var lastIndex = 1;
var lastElement = document.getElementById(lastIndex.toString());
while (lastElement != null) {
lastIndex++;
console.log(lastIndex.toString());
lastElement = document.getElementById(lastIndex.toString());
}
var input = document.createElement("input");
input.type = "text";
input.name = "Answer" + lastIndex;
input.id = lastIndex.toString();
form.insertBefore(input, thisButton);
form.insertBefore(document.createElement("br"), thisButton);
form.insertBefore(document.createElement("br"), thisButton);
}
</script>
<input type="submit" class="btn btn-lg btn-success"/>
</form>
</div>
</div>
</div> <!-- Content -->
<footer class="footer">
<div class="container small">
<p class="text-muted small">I don't have any rights on the Harry Potter Universe. All rights belong to their rightful owners.
This site is using cookies to identify you for the next month. <br/>
Credits - Idea: Laura Weasley Kletschko - Implementation: Niko Percival Wulfric Brian Tzioras <br/>
<a href="impressum.html">Impressumg & Datenschutz</a>
</p>
</div>
</footer>
</body>
答案 0 :(得分:1)
在页脚上添加一个元素,如。
<div class="push">
</div>
<footer class="footer">
答案 1 :(得分:1)
[在此查找解决方案] [1] 或者只是删除包装器边距的负值
[1]: https://jsfiddle.net/437jtp3j/1
答案 2 :(得分:1)
您好检查https://plnkr.co/edit/4PuGswOMqpuKMDktkVqA
html, body {
height: 99%;
}
.wrapper {
height: 82%;
overflow:auto;
}
.footer {
width: 100%;
height: 18%;
overflow:hidden;
}