如何使用角度类型中的css对齐元素

时间:2013-10-24 13:25:19

标签: javascript css angularjs twitter-bootstrap angular-ui

http://plnkr.co/edit/LmMwgy2gig11nQXzCt1I?p=preview

我希望最终结果如下所示: enter image description here

我的css应该如何,以便我的搜索按钮与搜索输入对齐?

3 个答案:

答案 0 :(得分:0)

这样的事情:

<div>
    <div style="width: 300px; float: left; height: 40px;"></div>
    <div style="width: 80px; float: left; height: 40px;"></div>
    <div style="clear: both"></div>
</div>

然后将按钮放在第二个div中,输入放在第一个...

答案 1 :(得分:0)

使周围的element()位置相对。

将输入位置设为绝对位置,然后将其定位。

对于mag图标,只需使用背景图像,确保将显示设置为“阻止”并设置正确的宽度和高度。使用font-size:0;

删除搜索文本

答案 2 :(得分:0)

请参阅 Demo

    <div class="srch">
      <input type="text" ng-model="selected" typeahead="state for state in states | filter:$viewValue | limitTo:8">
      <button>search</button>
    </div>

    .srch button {
      float: right position: absolute;
      margin-left: -56px;
      display: table-cell;
      background: #08c;
      color: #fff;
      height: 30px;
      border: none;
    }
    .srch input {
      float: left;
      padding-right: 60px;
    }