0

I have the following HTML structure:

<span id="span_pagination_text_input">
     <input type="text" class="form-control" id="pagination_text_input" name="pagination_text_input"/>
     ...
</span>

And Following CSS:

span#span_pagination_text_input{
    position:relative;
}

span#span_pagination_text_input > input#pagination_text_input{
    left: -11px;
    position: absolute;
    top: -35px;
    width: 57px;
    z-index: 10;
    display:none;
    text-align:center
}
span#span_pagination_text_input:hover > input#pagination_text_input{
    display:block;
}

At this time when visitors hover on my span, I will show the input field which is hidden by default.

How I can focus on input children of span when I show that with CSS?

I know about jQuery but at this time I am looking for a CSS solution.

3

2 Answers 2

1

You can achieve that by using tabindex which HTML5 allows in all elements now along with the :focus, to fake the display:none use border:0

input {
  border: 0;
  width: 57px;
  z-index: 10;
  text-align: center
}
span:focus input {
  border: 5px solid red;
  transition: border .1s
}
input:focus {
  border: 5px solid green;
}
<span tabindex="1" id="span_pagination_text_input">
  Click me
  <input type="text" class="form-control" id="pagination_text_input" name="pagination_text_input" />
</span>

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

Comments

0

I don't think that it is possible with only css. You can try javascript

document.getElementById("IdOfInput").focus();

:-)

2 Comments

I am looking for a solution which does not use from jQuery and Javascript
Then i don't think css is the solution

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.