Advertisement
Guest User

Untitled

a guest
Jan 5th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.57 KB | None | 0 0
  1. ///
  2. /// 註:此程式碼混合了 ASP.NET MVC 5 + Angular 1.5 + Bootstrap 3 + HTML5 + CSS3 ,所以不要太計較語法。
  3. ///
  4. @{
  5. //** 僅用於初始化 web page.
  6. Layout = "~/Views/Shared/_NgLayout.cshtml";
  7. ViewBag.Title = "CSS3 @media Lab";
  8. const Boolean DEBUG_MODE = true;
  9. }
  10.  
  11. @section css_style {
  12.  
  13. <style type="text/css">
  14. /* screen-xs: 480px */
  15. /* screen-sm: 768px */
  16. /* screen-md: 992px */
  17. /* screen-lg: 1200px */
  18.  
  19. /* 寬螢幕模式:寬螢寬度 1200px 以上。 */
  20. @@media screen and (min-width:1200px) {
  21. .myclass
  22. {
  23. background-color: yellow;
  24. }
  25. .myclass::after
  26. {
  27. content: "寬螢幕"
  28. }
  29. }
  30.  
  31. /* 膝上型模式:寬螢寬度 992px 以上,小於 1200px。 */
  32. @@media screen and (min-width: 992px) and (max-width: 1199px) {
  33. .myclass
  34. {
  35. background-color: green;
  36. }
  37. .myclass::after
  38. {
  39. content: "膝上型"
  40. }
  41. }
  42.  
  43. /* 平板模式:寬螢寬度 768px 以上,小於 992px。 */
  44. @@media screen and (min-width: 768px) and (max-width: 991px) {
  45. .myclass
  46. {
  47. color: white;
  48. background-color: blue;
  49. }
  50. .myclass::after
  51. {
  52. content: "平板"
  53. }
  54. }
  55.  
  56. /* 手機模式:寬螢寬度小於 768px。 */
  57. @@media screen and (max-width: 767px) {
  58. .myclass
  59. {
  60. background-color: red;
  61. }
  62. .myclass::after
  63. {
  64. content: "手機"
  65. }
  66. }
  67.  
  68. </style>
  69.  
  70. }
  71.  
  72. <div ng-controller="appController" ng-cloak>
  73. <h2>@ViewBag.Title</h2>
  74. <p>說明:CSS @@media 指令練習。<br/>請將畫面縮放於 Bootstrap 四個寬度級數之間。</p>
  75. <hr />
  76.  
  77. <h1 class="myclass" >寬度級數:</h1>
  78.  
  79. <div ng-controller="mainCtrl" ng-init="init()">
  80.  
  81. <div class="container">
  82. <div class="row">
  83. <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3" style="background-color:red;"><h1>THIS</h1></div>
  84. <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3" style="background-color:blue;"><h1>IS</h1></div>
  85. <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3" style="background-color:green;"><h1>A</h1></div>
  86. <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3" style="background-color:yellow;"><h1>BOOK</h1></div>
  87. </div>
  88. </div>
  89.  
  90. <div class="affix" style="background-color: InfoBackground; right: 20px; ">
  91. <dl>
  92. <dt>width</dt>
  93. <dd>{{wndWidth}}</dd>
  94. <dt>height</dt>
  95. <dd>{{wndHeight}}</dd>
  96. <dt>scrollX</dt>
  97. <dd>{{scrollX}}</dd>
  98. <dt>scrollY</dt>
  99. <dd>{{scrollY}}</dd>
  100. </dl>
  101. </div>
  102.  
  103. </div>
  104.  
  105.  
  106. @* Script *@
  107. <script src="~/Scripts/NgApp/appMain.js"></script>
  108. <script type="text/javascript">
  109.  
  110. /// ng-controller
  111. app.controller('mainCtrl', function ($scope, $log, appValue, $filter) {
  112.  
  113. // ctor
  114. $scope.appValue = appValue;
  115. $scope.wndWidth = 0; // window width
  116. $scope.wndHeight = 0; // window height
  117. $scope.scrollX = 0; // window scroll X
  118. $scope.scrollY = 0; // window scroll Y
  119.  
  120. //# methods
  121. $scope.getData = function () {
  122.  
  123. };
  124.  
  125. //# evnet of window
  126. $(window).resize(function () {
  127. $scope.$apply(function () {
  128. $scope.wndWidth = $(window).innerWidth(); // window.innerWidth;
  129. $scope.wndHeight = $(window).innerHeight(); // window.innerHeight;
  130. });
  131. });
  132.  
  133. //# evnet of window
  134. $(window).scroll(function () {
  135. $scope.$apply(function (e) {
  136. $scope.scrollX = window.scrollX;
  137. $scope.scrollY = window.scrollY;
  138. });
  139. });
  140.  
  141. //# init.
  142. $scope.init = function () {
  143. $log.log('on: init...');
  144. $scope.wndWidth = $(window).innerWidth(); // window.innerWidth;
  145. $scope.wndHeight = $(window).innerHeight(); // window.innerHeight;
  146. $scope.scrollX = window.scrollX;
  147. $scope.scrollY = window.scrollY;
  148. };
  149.  
  150. });
  151.  
  152. </script>
  153. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement