0

I've got an input field with one line on the bottom, much like a line of a textbook. I want to be able to display the placeholder text as well as the text the user inputs just a little above the line.

I've made a fiddle over here: http://jsfiddle.net/H7AVP/

This is what my HTML looks like:

<input type="text" placeholder="subscribe for early access" class="form-control email">

And my CSS (not cross-browser optimized for the question):

.email::-webkit-input-placeholder { 
  font-family: 'Open Sans', sans-serif;
  font-size: 25px;
  padding-bottom:45px;
  margin-top:-10px;
}

input {
  background-color: #2980b9;
  outline: 0;
  border-bottom: 2px;
  border-top: 0;
  border-left: 0;
  border-right: 0;
  border-bottom-style: double;
  border-bottom-color: #34495e;
  height: 46px;
  width: 300px;
}

input:focus{
  outline:0;
}
textarea:focus{
  outline:0;
}
2

3 Answers 3

1

Easiest way that comes to my mind would be setting line-height on input to about 40px. As it has a fixed height, this will work just fine to move the text to the bottom.

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

Comments

0

According to my understanding you want your placeholder and input to be in center.

add the following

.email{
    padding-bottom:10px;
}

and in form > div > input css file add {height :30px;}

here is the http://jsfiddle.net/H7AVP/

Comments

0

Here are two variations:

1: http://jsfiddle.net/H7AVP/5/

By default, removing any specific height or padding will keep the text "snug" with it's surrounding border. From there, just add padding to the left/right + padding to the top. I believe this should give you the effect you want.

After that, just move the styles you are using for -webkit-input-placeholder in the generic input itself. Then, if you just want to differentiate on color, then add it specifically to -webkit-input-placeholder.

Also, updated to use shorthand CSS methods wherever possible.

2: http://jsfiddle.net/H7AVP/6/

Now, if you want your text to get friendlier with the bottom border, then just simply apply a set height to the input element. The top padding will make sure your text is "snug" to the bottom.

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.