【问题标题】:Scalable layout transition可扩展的布局过渡
【发布时间】:2016-07-18 23:12:16
【问题描述】:

当屏幕变小时,如何制作像 那样进行过渡的布局。 bootstrap、flex box、angular material或原始css中是否有解决方案?

【问题讨论】:

标签: twitter-bootstrap css flexbox angular-material


【解决方案1】:

这是我认为你想要的 Angular Material 的尝试 - CodePen

对于较小的屏幕,我能想到在“2”和“3”之间放置“1”的唯一方法是为“1”创建一个指令,该指令根据屏幕尺寸打开和关闭。

标记

<div ng-controller="AppCtrl" ng-cloak="" ng-app="MyApp">
  <div layout="row">
    <div flex="30" hide-xs layout="column">
      <one class="aDiv"></one>
    </div>
    <div layout="column" flex>
      <div class="aDiv" style="background:pink; height:50px">2</div>
      <div class="aDiv" hide-gt-xs show-xs layout="row" layout-align="center">
        <one flex="50"></one>
      </div>
      <div class="aDiv" style="background:orange; height:700px">3</div>
    </div>
  </div>
</div>

CSS

.aDiv {
  margin: 10px
}

JS

angular.module('MyApp',['ngMaterial', 'ngMessages'])

.controller('AppCtrl', function() {
})

.directive("one", function () {
  return  {
    template: '<div style="background:yellow; height:500px">1</div>'
  }
});

【讨论】:

    【解决方案2】:

    您可以使用下面的 flexbox 来完成。

    .wrapperDiv { display: -webkit-flex;
       display: flex;
       -webkit-flex-direction: column; 
       flex-direction: column; }
    .first, .second, .third {
      border: 1px solid red;
      flex: 1 100%;
      }
      .first { order: 2; }
        .second { order: 1; }
        .third { order: 3; }
      @media only screen and (min-width : 768px) {
        .first, .second, .third {
          -webkit-flex-direction: row; 
       flex-direction: row;
        }
      .first { order: 1; }
        .second { order: 2; }
        .third { order: 3; }
    }
        
    <div class="wrapperDiv">
    <div class="first">
    1st div
    </div>
    <div class="second">
    2nd div
    </div>
    <div class="third">
    3rd div
    </div>
    </div>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-24
      • 1970-01-01
      • 2016-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多