6

I am not able to type in the input field. When I remove the first div that has the id="viewport" I am able to type in the input field. How am I able to solve this?

<div id="viewport"></div>
<div class="form">
  <h2 id="h2">Need a project from<br>Google Cloud Storage?</h2>
  <form id="fileDownloadForm" method="GET" action="downloadBlob2" enctype="multipart/form-data">
    <input type="text" id="textBox" name="objectToSearch" placeholder="Type the name of the project here." />
    <button id="downloadBtn" type="submit" class="btn btn_primary">Download</button>
  </form>
</div>

5
  • 2
    Can you post your CSS? Commented Feb 22, 2019 at 20:47
  • 3
    not reproducable. you can test this code by itself and see that it's working. Perhaps you have other contributing factors. Commented Feb 22, 2019 at 20:48
  • 2
    Post CSS specifically what is #viewport Commented Feb 22, 2019 at 20:49
  • 1
    Without the CSS, seems to work fine. jsfiddle.net/eLtc4mgq Commented Feb 22, 2019 at 20:49
  • Thanks for the comments. I was posting my code in jsfiddle but then received the answer below. Commented Feb 22, 2019 at 22:49

5 Answers 5

6

You may solve this by adding css attribute #textBox{ z-index:1000; }. It seems that viewport block is too big and overflowing the input field. z-index makes the input field more "important" - the bigger it is, the more important the element becomes.

Sign up to request clarification or add additional context in comments.

2 Comments

Haha! I tried this already but with z-index: 1. 1000 works! Thank you. Do you know if a higher number for z-index or multiple z indexes demand a longer loading time for the web page in any way?
Glad I could help! :) No, I don't think so. Since it's just an attribute to a css file, it simply adds a little more information to a css file. I use it in my work very often to be honest, still haven't noticed any problems with loading. Everything loads pretty smoothly
3

I faced the same issue. Then I found that I used preventDefault() on keydown event.

document.onkeydown = function (e) {e.preventDefault()}

Comments

1

just in case to others, what works for me is putting in the immediate tag. So in this case I will try to put it in:

<div class="form" style="z-index: 1000 !important;">

Comments

1

In my case, somehow the text color changed to white. I found it by accidentally double-clicking the input field after typing few characters.

Comments

1

In my case i used Reactjs app for using

<input type="text" title="Search for products, brands and more" autocomplete="off" placeholder="Search for products, brands and more" name="" value="" />

You can see i put value="" so it is blank. That's why it was not working.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.