在小型设备(宽度小于600像素)上显示时,如何将x定位在垂直中间?

<div class="row">
  <div class="col-sm-12">
    <section class="panel panel-default panel-slider"><div class="panel-heading">
      <h1 class="panel-title" style="font-size:18px">
           Test with long description in title panel bla bla<a class="align-middle more pull-right" href="https://example.com" title="" data-toggle="tooltip" data-placement="right" data-original-title="more" ><i>x</i></a>
      </h1>
</div>
 <div class="panel-body">
      <div class="row">
           <div class="col-xs-12 col-sm-12 col-md-8" style="margin-bottom: 10px;">
           ...
      </div>
</div>


当前是:

css - 具有垂直中间字符/图标的引导面板标题-LMLPHP

应该:

css - 具有垂直中间字符/图标的引导面板标题-LMLPHP

https://jsfiddle.net/9dtu4en1/

提前致谢!

亲切的问候
亚历克斯

最佳答案

我会在h1上使用flexbox来调整大小,并从align-middle删除pull-righta(以避免浮动,以免其父级不考虑孩子的身高):

External Fiddle to resize

css - 具有垂直中间字符/图标的引导面板标题-LMLPHP

css - 具有垂直中间字符/图标的引导面板标题-LMLPHP

css - 具有垂直中间字符/图标的引导面板标题-LMLPHP

片段:



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

<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.1/css/bootstrap.min.css" rel="stylesheet" />
<div class="row">
  <div class="col-sm-12">
    <section class="panel panel-default panel-slider">
      <div class="panel-heading">
        <h1 class="panel-title" style="font-size:18px">Test with long description in title panel bla bla
          <a class="more" href="https://example.com" title="" data-toggle="tooltip" data-placement="right" data-original-title="more"><i>x</i></a>
        </h1>
      </div>
      <div class="panel-body">
        <div class="row">
          <div class="col-xs-12 col-sm-12 col-md-8" style="margin-bottom: 10px;">
            ...
          </div>
        </div>

07-28 05:12