0

I have a little problem with my css, I can't align an image with a text input field. The site is live at http://jocolina.com/picemon/pokelocator.php

The CSS I have for the text input and image is:

#loginUTC{
  width:30%;
  height: 60px;
  font-family: Verdana;
  font-size: 30px;
  text-align:center;
  font-weight: bold;

  /*margin: 0 auto;*/
  border-color: #336688;
}

#magniIMG{
  display: inline;
  height: 60px;
  cursor: pointer;
}

#locator{
  margin: 0 auto;
  text-align:center;
  height:60px;
}

Where loginUTC is the text input, magniIMG is the image I want to algin with the input, and locator is the div in which both of the elements are.

3 Answers 3

1

You can set both elements to vertical-align: bottom;.

#loginUTC{
  vertical-align: bottom;
}

#magniIMG{
  vertical-align: bottom;
}
Sign up to request clarification or add additional context in comments.

Comments

1

You can use margin-bottom in negative at image that will fix it

#magniIMG {
    display: inline;
    cursor: pointer;
    height: 60px;
    margin-bottom: -18px;
}

2 Comments

Yes I also found that -18 was the solution, it is however very dependent on the screen, and might not work in mobile
@JoColina no it doesnt depend on screen. it depends on code and pixels will work fine till you have same heights setting. you can view by resizing browsers :)
0

You could use floats to align the form elements with images like you are trying to achieve here. You'll also need to add some widths to the containing element and the input to align everything. Try -

#locator {
margin: 0 auto;
text-align: center;
height: 60px;
width: 545px;
}

#loginUTC {
height: 60px;
font-family: Verdana;
font-size: 30px;
text-align: center;
font-weight: bold;
/* margin: 0 auto; */
border-color: #336688;
float: left;
}

#magniIMG {
/* display: inline; */
height: 60px;
cursor: pointer;
float: left;
}

2 Comments

This will break the fluid layout though.
what happens then if it goes to left

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.