Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't Type in <input> tags

Tags:

html

css

position

I'm currently trying to create a form on my website's front page. However, Im having issues being able to type within the input boxes. In absolute positioning, the cursor doesn't show up. When I change the positioning from absolute to relative, I no longer have this issue. Unfortunately, when I do this, it moves all my other elements down. Is there a way around this so the tag doesn't move my other elements down, along with being able to type into this input boxes?

HTML:

<div id="wrapper">
    <div class="header">
        <div id="head_login">
            Login
            <div id="arrow-down"></div>
        </div>
    </div>
    <div id="head_break"></div>
    <div class="content_splash">
        <form>
        **<input type="text" id="firstname" /></form>**
        <div id="vertical_one"></div>
        <div id="vertical_two"></div>
        <p id="OR"> OR </p>
        <div id="facebook_login"><img src="{% static 'home/facebook_login.gif' %}" /></div>
    </div>
    <div id="content_break"></div>
    <div class="content_description">
    <h2> What is the Title? </h2>
    </div>
    <div id="content_description_break"></div>
    <div class="content_howitworks">
    <h2> How it Works.</h2>
    </div>
    <div id="footer_break"></div>
</div>

CSS:

content_splash{
    position: relative;
    margin-top: 30px;
    height: 500px;
    border: 1px solid black;
}
.content_splash input{
    -webkit-border-radius: 10px;
    -moz-border-radius: 10px;
    border-radius: 10px;

}
.content_splash #firstname{
    position: absolute;
    margin-top: 200px;
    width: 170px;
    height: 25px;
}
.content_splash #vertical_one{
    position: absolute;
    width: 1px; 
    height: 60px;
    margin-left: 310px;
    margin-top: 298px;
    background: black;
}
.content_splash #vertical_two{
    position: absolute;
    width: 1px; 
    height: 60px;
    margin-left: 310px;
    margin-top: 380px;
    background: black;
}
.content_splash #OR{
    position: absolute;
    padding-top: 346px;
    padding-left:300px;
    color: black;
}
.content_splash #facebook_login{
    position: absolute;
    padding-top: 350px;
    padding-left: 350px;

}
#content_break {
    margin-top: 20px;
    height: 1px;
    background: black;
    background: -webkit-gradient(linear, 0 0, 100% 0, from(#e2e3e4), to(#e2e3e4), color-stop(50%, black));  
}
.content_description{
    margin-top: 20px;
    height: 400px;
}
.content_description h2{
    font-size: 40px;
    font-family: Trebuchet MS;
    padding-left: 30px;
    color: #a2caf6;
}
#content_description_break {
    margin-top: 20px;
    height: 1px;
    background: black;
    background: -webkit-gradient(linear, 0 0, 100% 0, from(#e2e3e4), to(#e2e3e4), color-stop(50%, black));  
}
.content_howitworks{
    margin-top: 20px;
    height: 400px;
}
.content_howitworks h2{
    font-size: 40px;
    font-family: Trebuchet MS;
    padding-left: 30px;
    color: #a2caf6;
}
like image 973
user2714604 Avatar asked Aug 25 '13 01:08

user2714604


People also ask

Can't type anything in input field?

To solve the issue of being unable to type in an input field in React, make sure to use the defaultValue prop instead of value for uncontrolled input fields. Alternatively, set an onChange prop on the field and handle the change event. Here is an example of how the issue occurs.

How will you get text inside an input tag?

Answer: Use the value Property You can simply use the value property of the DOM input element to get the value of text input field. The following example will display the entered text in the input field on button click using JavaScript.

How do you reset input tag?

The <input type="reset"> defines a reset button which resets all form values to its initial values. Tip: Avoid reset buttons in your forms!

Which of the following is not a supported type for the input tag?

Which of the following is not a type of attribute for input tag? Explanation: Day is not defined in the pre-defined attribute list of input tag.


1 Answers

Add a z-index to the input.

.content_splash #firstname{
    position: absolute;
    margin-top: 200px;
    width: 170px;
    height: 25px;
    z-index: 1;
}

Example

EDIT

As by request of @gaitat, I will explain why this works.

Assume the following HTML:

<div class="parent">
    I am the parent.

    <div class="child red">I am the red child.</div>

    <div class="child blue">I am the blue child.</div>

    <div class="child green">I am the green child.</div>
</div>

Now, also assume the following css:

.parent
{
    position: relative;
}

.child
{
    position: absolute;
    padding: 5px;
}

.red
{
    background-color: red;
}

.blue
{
    background-color: blue;
}

.green
{
    background-color: green;
}

See the JSFiddle here

As you can see, in the DOM, the green child is the last child of parent, thus it's rendered last. The last rendered element, assuming an absolute position and no z-index is used, will be rendered on top.

Now, when we add a z-index to the red child:

.red
{
    background-color: red;
    z-index: 1;
}

You will see that the red child will be rendered on top, because his z-index is higher than the other children, who have a z-index of 0 (default). See the JSFiddle here showing this.

Do keep in mind that this only works with siblings sharing the same direct parent, otherwise it will not.

like image 197
MisterBla Avatar answered Oct 06 '22 05:10

MisterBla