jquery - 调整方向变化的完整日历

标签 jquery css ipad fullcalendar

我正在使用完整的日历,当我的设备 (iPad) 的方向发生变化时,我无法调整它的大小。

容器重新调整大小,但日历没有。任何帮助、建议或提示将不胜感激!谢谢!

JavaScript

//When the orientation changes
window.addEventListener("orientationchange", function() {
    //Resize the container first
    $("#calendarWrapper").css({
      width: $(document).width() * 0.8
    }); 

    //Resize the calendar
    $("#calendar").fullCalendar("windowResize");
    //$("#calendar").fullCalendar("render"); //Doesn't work either

    //Position the container to be in the middle
    $("#calendarWrapper").css({
      marginLeft: $("#calendar").width() / 2 * -1,
      marginTop:  $("#calendar").height() / 2 * -1
    }); 
}, false);

初始 CSS

#calendarWrapper{
  position:absolute;
  visibility: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  top: 50%;
  left: 50%;
  margin-left: 0px;
  margin-top: 0px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #afafaf;
  background-color: #fff;
  z-index: 1001;
  opacity: 1;
}

最佳答案

找到我的问题了!

我正在手动设置日历的大小

window.addEventListener("orientationchange", function() {
    //Resize container and calendar
    $("#calendarWrapper, #calendar").css({
      width: $(document).width() * 0.8
    }); 
    //Re render calendar so it keeps aspect ratio
    $("#calendar").fullCalendar("render");

    //Move container to center of page 
    $("#calendarWrapper").css({
      marginLeft: $("#calendar").width() / 2 * -1,
      marginTop:  $("#calendar").height() / 2 * -1
    });
}, false);

关于jquery - 调整方向变化的完整日历,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15076382/

相关文章:

css - 我可以合并 :nth-child() or :nth-of-type() with an arbitrary selector?

iphone - 生成调度源计时器事件时发生内存泄漏

javascript - 滑动菜单工作正常但有双重动画

html - “底部”在 Edge 中不起作用

javascript - 如何绑定(bind)Jquery函数来点击?

javascript - 容器外的可选元素溢出 : hidden

ios - 无法通过移动它们来重新排列 UICollectionView 中的单元格?

iphone - iOS 上的原始 H264 NALU 硬件解码

javascript - 添加按钮以切换浏览器

php - 如何显示下拉选择的值