简体   繁体   English

字段 alignment 问题 Css

[英]fields alignment problem Css

Hey this is my problem, i can not align tis input field with these images, they are in a div, i will paste the code below嘿,这是我的问题,我无法将这些输入字段与这些图像对齐,它们在一个 div 中,我将粘贴下面的代码字段图像

So what do you suggest should i do, stuck with this problem, need a quick answer plz那么你建议我应该怎么做,遇到这个问题,需要一个快速的答案plz

<div style="margin-bottom: 5px;"> 

 <input type="text" id="queryInput" value="pizza" style="width: 180px; height:30px;border: 1px solid #d3d6d9;padding: 4px 10px 2px 10px;background-color: white;-moz-border-radius: 5px; -webkit-border-radius: 5px; -khtml-border-radius: 5px;border-radius: 5px;  font-size: 12px;   font-family: Droid Sans, Arial, sans-serif;"/> 
 <a href="javascript:doSearch()"><img src="img/search.png" /></a> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
 <a href="javascript:toggleStreetView()"><img src="img/street.png" /></a>
 <a href="javascript:toggleGoogleView()"><img src="img/google.png" /></a>

</div> 

css: css:

#queryInput {
    margin-top: -10px;
    float: left;
}

Generally, to align boxes vertically, one of the best methods are to make'em all block box (so they can accept width and height), then set the height of all of them to the highest box, then try to vertical-align contents in each box.一般来说,要垂直对齐盒子,最好的方法之一是让它们都成为块状盒子(这样它们可以接受宽度和高度),然后将它们的高度设置为最高的盒子,然后尝试垂直对齐内容在每个盒子里。 In your special case, the height of search box is 30px.在您的特殊情况下,搜索框的高度为 30px。 But as @Jawad said, you should include the CSS of the parent div, with CSS of other elements, so that we can help.但是正如@Jawad所说,您应该包含父div的 CSS 以及其他元素的 CSS ,以便我们提供帮助。

 div input, div a{
    display:inline-block;
    vertical-align:top;
    float:none;
    margin:0px;
    .display:inline;
    .zoom:1;
}
  1. try to avoid inline styles, yes?尽量避免内联 styles,是吗?

  2. vertically center the images, and they will align w the textbox:垂直居中图像,它们将与文本框对齐:

    < style> div img { vertical-align:middle; <样式> div img { 垂直对齐:中间; } < / style> }</style>

http://jsfiddle.net/mSgVg/ http://jsfiddle.net/mSgVg/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM