Using a background image as a text field

Posted on 2010-08-31
Last Modified: 2012-06-27
I am trying to use a background image as a text field to make it look a bit nicer than the regular one. The problem is that I just can't seem to get the text in the middle. Take a look at the attached image to see what I mean...  text alignment
Question by:jonofat
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
LVL 40

Expert Comment

ID: 33570916
<<I am trying to use a background image as a text field>>
Did you mean that you are trying to put an background image in a text field?
then try
<input type="text" Style="text-align: center;background-image:image-path.jpg;">
LVL 83

Accepted Solution

Dave Baldwin earned 250 total points
ID: 33571217
There are several things you can do.  The easiest is to add some padding or margin to the top of the element.  style="padding-top:12px;" for example.

Author Comment

ID: 33584138
Hi. Thanks for your suggestions. I haven't had a chance to try them out yet but I will definately do it tonight and get back to you. Thanks for your patience.
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 33589141
Hi there. Unfortunately neither of your solutions worked... :(
LVL 40

Expert Comment

ID: 33589173
ok...but please confirm if my understanding of the question is correct as i asked in my first reply.

Author Comment

ID: 33589221
OKay, I don't want us to cross wires here. I am trying to have an nice looking text box with rounded edges as you can see in my screen shot. I have this but the text is too high. I am trying to get it a bit lower but I can't. My CSS looks like this

                     color: #333;
      background-image: url(../images/singleline.png);
      background-color: #701816;
      font-family: Arial, Helvetica, sans-serif;
      background-repeat: no-repeat;
LVL 40

Assisted Solution

gurvinder372 earned 250 total points
ID: 33589253
add this also


you can adjust the pixel value as per requirement

Author Comment

ID: 33589378
I tried that, it doesn't work, all it does is make a gap above the text box.
LVL 40

Expert Comment

ID: 33589477
please try again, this should do. Are you giving these styles to textbox only right?
padding: 10px 10px 10px 10px;

try this also
<input type="text" style="height: 10em; vertical-align:middle;" size="50">

Author Comment

ID: 33589504
Okay, wait. For some reason when I add padding to the bottom as well it fits perfectly. Strange. Anyway, since both of you guys helped, I will have to split the points. Thanks! It looks great now!

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

CSS3 Custom checkboxes This article shows how to style the checkbox form element using only CSS. Works in: Chrome, FF, Safari, Opera, IE9+ Uses modernizr.js to check for :checked pseudo class, falling back to plain old checkboxes (IE8 and bel…
When applying CSS to your HTML, there are many different ways to select which element(s) the CSS applies to.  Some of these selectors are more commonly known and used than others - Here are the more common ones: #X - Matches an ID of X .X - Matche…
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Suggested Courses

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question