html - Increase a div with flex when another is hidden not working on safari -
i've got follow code:
angular.module("myapp", []).controller("mycontroller", function($scope) { $scope.toggleblue = false; });
span { cursor: pointer; } .wrapper { display: flex; justify-content: space-between; padding: 10px; background-color: grey; margin-top: 10px; } .row { width: 35%; } .first { flex: 1; background-color: red; } .second { display: flex; } .toggle { width: 80%; background-color: blue; } .decrease { width: 30px; height: 20px; background-color: yellow; } .nowidth { width: 20px; }
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <body ng-app="myapp" ng-controller="mycontroller"> <span ng-click="toggleblue = !toggleblue">toggle blue box</span> <div class="wrapper"> <div class="row first"></div> <div class="row second" ng-class="{nowidth: toggleblue}"> <div class="toggle" ng-if="!toggleblue"></div> <div class="decrease"></div> </div> </div> </body>
when click on text "toggle blue box", should hide blue box ng-if
, increase red box fill flex: 1;
, change width of yellow box ng-class
. should toggle blue box. works fine on chrome. when try on ipad in safari browser, removes blue box, doesn't increase red one. yellow box not in end it's behind red 1 this:
my expected result same here in snippet. how can fix on safari? tried flex: 1 1 auto;
on class .first
in case of flex 1;
, didn't work. ideas?
thanks
okay... i'm bit confused regarding code. define display flex not use on of child elements. i've corrected best can understand let me know if off here.
also, if you're curious why safari freaking out, it's css wasn't following proper standards (not defining flex on children controls).
angular.module("myapp", []).controller("mycontroller", function($scope) { $scope.toggleblue = false; });
span { cursor: pointer; } .wrapper { display: flex; flex-direction: row; justify-content: space-between; background-color: grey; padding: 10px; height: 25px; } .first { flex: 1 1 35px; background-color: red; } .second { flex: 1 1 35px; background-color: blue; } .third{ flex: 0 0 35px; background-color: yellow; } .nowidth { flex: 0 0 0px; }
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <body ng-app="myapp" ng-controller="mycontroller"> <span ng-click="toggleblue = !toggleblue">toggle blue box</span> <div class="wrapper"> <div class="first"></div> <div class="second" ng-class="{nowidth: toggleblue}"></div> <div class="third"></div> </div> </body>
Comments
Post a Comment