javascript - 如何居中 gridster.js?

标签 javascript jquery html css gridster

我一直在玩 Gridster.js,但就我的生活而言,我似乎无法使网格居中,它总是左对齐,我已经尝试了很多次,但也许我遗漏了一些东西..

我制作了一个包含我的网格基础的 jsfiddle,我希望有人能解决它并帮助我将它居中,拜托:)

.gridster {
    background: #004756;
       margin: 0 auto;
    opacity: .8;
    -webkit-transition: opacity .6s;
    -moz-transition: opacity .6s;
    -o-transition: opacity .6s;
    -ms-transition: opacity .6s;
    transition: opacity .6s;
    text-align: center;
}
.gridster > * {
    margin: 0 auto;
    -webkit-transition: height .4s;
    -moz-transition: height .4s;
    -o-transition: height .4s;
    -ms-transition: height .4s;
    transition: height .4s;
}

.gridster .gs_w{
    z-index: 2;
    position: absolute;
        background: #FFF;
    cursor: pointer;
    -webkit-box-shadow: 0 0 5px rgba(0,0,0,0.3);
    box-shadow: 0 0 5px rgba(0,0,0,0.3);
}

.ready .gs_w:not(.preview-holder) {
    -webkit-transition: opacity .3s, left .3s, top .3s;
    -moz-transition: opacity .3s, left .3s, top .3s;
    -o-transition: opacity .3s, left .3s, top .3s;
    transition: opacity .3s, left .3s, top .3s;
}

.ready .gs_w:not(.preview-holder) {
    -webkit-transition: opacity .3s, left .3s, top .3s, width .3s, height .3s;
    -moz-transition: opacity .3s, left .3s, top .3s, width .3s, height .3s;
    -o-transition: opacity .3s, left .3s, top .3s, width .3s, height .3s;
    transition: opacity .3s, left .3s, top .3s, width .3s, height .3s;
}

.gridster .preview-holder {
    z-index: 1;
    position: absolute;
    background-color: #fff;
    border-color: #fff;
    opacity: 0.3;
}

.gridster .player-revert {
    z-index: 10!important;
    -webkit-transition: left .3s, top .3s!important;
    -moz-transition: left .3s, top .3s!important;
    -o-transition: left .3s, top .3s!important;
    transition:  left .3s, top .3s!important;
}

.gridster .dragging {
    z-index: 10!important;
    -webkit-transition: all 0s !important;
    -moz-transition: all 0s !important;
    -o-transition: all 0s !important;
    transition: all 0s !important;
}

.gridWrapper {
   width: 100%;

    overflow-x: scroll;
    overflow-y: hidden;
}

.gridAlignerWrapper {
    display: table;
    width: 100%;
    height: 100%;
}

.gridAligner {
    width: 100%;
    display: table-cell;
        }

body {
    background-color: #EEEEEE;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    font-size: x-small;
    color: #666666;
    text-align: center;
      vertical-align: middle;
}

ul, ol {
    list-style: none;
    margin:0 auto;
      text-align: center;
      vertical-align: middle;


}

h1 {
  margin-bottom: 12px;
  text-align: center;
  font-size: 30px;
  font-weight: 400; 
}

h3 {
  font-size: 25px;
  font-weight: 600;
  color: white; 
}

/* Uncomment this if you set helper : "clone" in draggable options */
/*.gridster .player {
  opacity:0;
}*/

https://jsfiddle.net/036qutd9/4/

谢谢

最佳答案

感谢 Paulie_D,我设法解决了它并使其居中 :)

.gridster {
    width: 730px;
    background: #004756;
    margin-left:auto;
    margin-right:auto;
    opacity: .8;
    -webkit-transition: opacity .6s;
    -moz-transition: opacity .6s;
    -o-transition: opacity .6s;
    -ms-transition: opacity .6s;
    transition: opacity .6s;
    text-align: center;
}
.gridster > * {
    margin: 0 auto;
    -webkit-transition: height .4s;
    -moz-transition: height .4s;
    -o-transition: height .4s;
    -ms-transition: height .4s;
    transition: height .4s;
}

关于javascript - 如何居中 gridster.js?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35222377/

相关文章:

javascript - 页面加载后提醒

javascript - 如果js函数都包含在另一个函数中,我是否必须在另一个函数使用它之前定义它?

javascript - 将 2 个按钮合并为 1 个

javascript - Highcharts MVC 无法获取属性值 'series' : object is null or undefined

javascript - 在 Javascript 中比较表单中的两个字段 - 不起作用

javascript - 由于回调结构中可能存在错误,无法实现超时工作

html - 如何构建我自己的嵌入式音频播放器//不是纯闪存

javascript - history.back 后 Chrome 重新加载页面

php - 使用 jQuery 检测包含动态按钮的动态表的按钮单击

html - iOS 9 中屏幕导航的设备位置路径错误