2016-12-26 2 views
1

入力要素を追加して、フォームにテキストを入力したいのですが、フォームを使用してページのフッターに重なってしまいます。私はオーバーフロー属性を追加しようとしましたが、うまくいきませんでした。私はWeb開発にはまったく新しいので、解決策を見つけることはできません。javascriptで要素を追加した後、ラッパーの高さが更新されない

これは私の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> 
+2

表示するHTMLを確認してください。 –

+0

@ atulquest93ここに行きます – greece57

答えて

1

は次のようにフッター上の一つの要素を追加します。

<div class="push"> 

</div> 
<footer class="footer"> 
+0

これはなぜ私にとって完璧に機能するのか説明できますか?ありがとうございました! – greece57

1

[ここに解決策を探す] [1] または単なるラッパーの余裕

[1]: https://jsfiddle.net/437jtp3j/1 
関連する問題