"https://jsfiddle.net/q4eotzb0/1/"
<body>
<script type="text/javascript">
var app = angular.module('MyApp', [])
app.controller('MyController', function($scope) {
//This will hide the DIV by default.
$scope.IsVisible = true;
$scope.ShowHide = function() {
//If DIV is visible it will be hidden and vice versa.
$scope.IsVisible = !$scope.IsVisible;
}
});
</script>
<div ng-app="MyApp" ng-controller="MyController">
<input type="button" value="SHOW/HIDE" ng-click="ShowHide()" />
<br />
<br />
<div class="container-fluid col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="test col-lg-4 col-md-4 col-sm-12 col-xs-12" ng-class="
{'divOpen': IsVisible}">
</div>
<div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
<div class="testtest"></div>
</div>
</div>
.test {
background: red;
width: 250px;
height: 100px;
-webkit-transition: width 2s;-moz-transition: width 2s ease-in-out;-ms-
transition: width 2s ease-in-out;
-o-transition: width 2s ease-in-out;transition: width 2s;
}
.divOpen{
width: 100px;
}
.testtest{
background: green;
height: 100px;
width: auto;
}
答案 0 :(得分:1)
将此css
与您一起添加
.divOpen + div{
width: calc(100% - 100px);
}
答案 1 :(得分:0)
这是使用flex
$(function() {
$('[type=button]').on('click', function() {
$('.red').toggleClass('divOpen');
});
});
* { margin: 0; padding: 0; box-sizing: border-box; }
.expender {
display: flex;
align-content: stretch;
}
.red {
background: red;
height: 100px;
flex: 1 1 250px;
-webkit-transition: flex-basis 2s;
-moz-transition: flex-basis 2s ease-in-out;
-ms-transition: flex-basis 2s ease-in-out;
-o-transition: flex-basis 2s ease-in-out;
transition: flex-basis 2s;
}
.red.divOpen {
flex-basis: 100px;
}
.green {
flex: 1 1 100%;
background: green;
height: 100px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="button" value="SHOW/HIDE" />
<div class="expender">
<div class="red"></div>
<div class="green"></div>
</div>