_Bg.cshtml 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. @using WeApp.Helpers
  2. @model bool
  3. <style>
  4. body {
  5. background-image: url('/Content/Image/ExerciseV2/bg.jpg');
  6. background-repeat: no-repeat;
  7. background-size: 100% 100%;
  8. overflow: hidden;
  9. width: 100vw;
  10. height: 100vh;
  11. }
  12. .box #bg_title {
  13. display: flex;
  14. justify-content: center;
  15. align-items: flex-end;
  16. width: 100%;
  17. font-weight: 600;
  18. font-size: 38px;
  19. color: #fff;
  20. }
  21. </style>
  22. <img id="bg_header" src="/Content/Image/ExerciseV2/bg_header_ruler.png" style="position: absolute; top: 0; width: 100%; height: auto; opacity: 0; visibility: hidden;" />
  23. @using (Html.BeginScripts())
  24. {
  25. <script>
  26. @if (Model)
  27. {
  28. <text>
  29. $(function () {
  30. resizeHeight();
  31. window.addEventListener('resize', resizeHeight);
  32. });
  33. </text>
  34. }
  35. function resizeHeight(fun) {
  36. var w_h = $(window).height();
  37. var h = 126,
  38. txt = w_h > 850 ? 66 : 76,
  39. fs = w_h > 850 ? 38:45;
  40. var bh = Math.floor($('#bg_header').height());
  41. var newFs = Math.floor(fs * bh / h),
  42. newTxt = Math.floor(txt * bh / h),
  43. mb = bh - newTxt
  44. $(".box #bg_title").height(newTxt).css({ "fontSize": newFs + "px", "marginBottom": mb + "px" });
  45. fun && fun(bh,w_h,h)
  46. }
  47. </script>
  48. }