1

I have two view in a super view, the code is below:

<view class="search">
<view class="section">
    <input id="input-word" placeholder="请输入您要查询的文本" focus/>
    <navigator id="cancel-button" class="navigator" url="../../index">取消</navigator>
    </view>
</view>

Before asking the question, I searched the SO, find :

'vertical-align: middle' does not work

But I set the line-height equals to super view's heihgt, only one view(cancel-button) work, the other did not work.

The picture is below:

enter image description here

The css code:

#input-word {
  display:inline-block;
  vertical-align: middle;
  float:left;
  text-align:left;
  line-height:90rpx;
}

#cancel-button {
  display:inline-block;
  width:120rpx;
  float:right;
  text-color:#ffffff;
  vertical-align: middle;
  line-height:90rpx;
}

Where is the issue? I think the code is no problem.


Edit - 1

#input-word {
  display:inline-flex;
  vertical-align: middle;
  float:left;
  text-align:left;
  align-items: baseline;
  line-height:90rpx;
}

The input css I tested this, but not work.

Community
  • 1
  • 1
aircraft
  • 25,146
  • 28
  • 91
  • 166

3 Answers3

1

Update:

.section {
    display:flex;
    align-items: center;
    justify-content: space-between;
}

Origin

Just Use following CSS

.section {
    display:flex;
    align-items: center;
}
aircraft
  • 25,146
  • 28
  • 91
  • 166
Super User
  • 9,448
  • 3
  • 31
  • 47
0

Use inline-flex, like in this example:

<div style="display: inline-flex;align-items: baseline;">
    <h4>This is a simple text </h4>
    <h1>Another simple text</h1>
</div>
Alex
  • 9,313
  • 1
  • 39
  • 44
0
Try this

<view class="search">
     <view class="section">
    <navigator id="cancel-button" class="navigator" url="../../index">取消</navigator>
    <input id="input-word" placeholder="请输入您要查询的文本" focus/>
    </view>
</view>

Css

#input-word {
  display:inline-block;
  vertical-align: middle;
  float:right;
  text-align:left;
  line-height:90rpx;
}

#cancel-button {
  display:inline-block;
  width:120rpx;
  float:right;
  text-color:#ffffff;
  vertical-align: middle;
  line-height:90rpx;
}

Click here to see Demo

Klaus Mikaelson
  • 572
  • 6
  • 17