固定页眉和页脚在菜单打开时移动

时间:2015-06-22 16:29:47

标签: angularjs html5 css3 semantic-ui

我在这个Angular应用中遇到问题,我的页脚和标题(仅限移动设备)在打开侧边栏菜单时跳了105px。该应用已托管here,您可以看到在移动设备上打开时会发生什么。但是,我无法在桌面版Chrome中重现它。

请使用这些凭据并点击任意频道,然后拉出侧边栏菜单以查看问题:

用户名: test@test.com 密码:测试

的index.html:

<div class="ui padded grid">
  <div class="sixteen wide column row button raised" id="header-mobile">
      <div class="ten wide column" id="remove-padding-left">
        <a href="#/home"><img class="ui medium image left floated" id="logo-hash" src="images/logo-hash.svg" alt="slackerchat"></a>
        <div class="item" id="channel-dropdown">
          <div class="ui dropdown">
            <div class="header">
              <h1>{{ messagesCtrl.channelName }} <i class="caret down icon"></i></h1>
            </div>
            <div class="menu">
              <div class="header">
                <p>Search Channels</p>
              </div>
              <div class="ui fluid left icon input">
                <i class="search icon"></i>
                <input type="text" name="search" placeholder="Search...">
              </div>
              <div class="header">
                <p>Available Channels</p>
              </div>
              <div class="item" ng-repeat="channel in channelsCtrl.channels">
                  <a ui-sref="channels.messages({channelId: channel.$id})" ui-sref-active="selected"><img class="ui image left floated" id="hash" src="images/hash.svg" alt="hashtag">{{ channel.name }}</a>
              </div>  
              <div class="item" id="create-channel"><a ui-sref="channels.create"><i class="plus icon"></i>create a new channel</a></div>                       
            </div>
          </div>
        </div>
      </div>
      <div class="six wide column" id="menu-container">
          <div class="ui list">
              <!-- SIDEBAR -->
              <div class="ui large icon toggle button right floated">
                  <i class="content icon big"></i>
              </div>
          </div>
      </div>
  </div>
  </div>




<div class="header" id="messages-channel-active">
  <h1>{{ messagesCtrl.channelName }}</h1>
</div>

<div class="message-wrap" ng-repeat="message in messagesCtrl.messages">
  <img class="user-pic" ng-src="{{ channelsCtrl.getGravatar(message.uid) }}" />
  <div class="message-info">
    <div class="user-name">
      {{ channelsCtrl.getDisplayName(message.uid) }}
      <span class="timestamp">{{ message.timestamp | date:'short' }}</span>
    </div>
    <div class="message">
     {{ message.body }}
    </div>
  </div>
</div>

<div class="ui comments">
  <div class="comment">
    <div class="avatar-container">
      <a class="avatar">
        <img src="/images/avatar/elliot.jpg">
      </a>
    </div>
    <div class="ui card">
    <div class="content">
        <i class="right floated like icon"></i>
        <i class="right floated star icon"></i>
        <a class="author">toddler</a>
        <div class="metadata">
          <div class="date">11:53am</div>
          <div class="right floated rating">
            <i class="star icon"></i>
            5 Faves
          </div>
        </div>
        <div class="text">
          Hey, have you seen my latest video at <a href="https://www.youtube.com/watch?v=kILY0L9oTc0" target="_blank">https://www.youtube.com/watch?v=kILY0L9oTc0?</a>
        </div>
          <a href="https://www.youtube.com/watch?v=kILY0L9oTc0" target="_blank">
            <img src="/images/surfing.jpg">
          </a>
        <div class="content">
          <a class="header" href="https://www.youtube.com/watch?v=kILY0L9oTc0" target="_blank">Surfing in Hawaii</a>
          <div class="meta">
            <a>Last Watched 1 minute ago</a>
          </div>
        </div>
      </div>
    </div>
  </div>

  <div class="comment">
    <div class="avatar-container">
      <a class="avatar">
        <img src="/images/avatar/helen.jpg">
      </a>
    </div>
    <div class="ui card">
    <div class="content">
        <i class="right floated like icon"></i>
        <i class="right floated star icon"></i>
        <a class="author">Miss Priss</a>
        <div class="metadata">
          <div class="date">11:55am</div>
          <div class="right floated rating">
            <i class="star icon"></i>
            2 Faves
          </div>
        </div>
        <div class="text">
          No, actually I haven't.  But I'm checking it out now!
        </div>
      </div>
    </div>
  </div>

  <div class="comment">
    <div class="avatar-container">
      <a class="avatar">
        <img src="/images/avatar/joe.jpg">
      </a>
    </div>
    <div class="ui card">
    <div class="content">
        <i class="right floated like icon"></i>
        <i class="right floated star icon"></i>
        <a class="author">Big Boba</a>
        <div class="metadata">
          <div class="date">11:57am</div>
          <div class="right floated rating">
            <i class="star icon"></i>
            3 Faves
          </div>
        </div>
        <div class="text">
          Wow, it looks like you really bit the dust on that last wave.  I'd love to learn, but I'll stick to the small waves here in Newport Beach.
        </div>
      </div>
    </div>
  </div>

</div>

<div class="form-wrapper">
  <form class="message-form" ng-submit="messagesCtrl.sendMessage()">
    <div class="huge ui fluid left icon input">
      <input type="text" id="input-message" ng-model="messagesCtrl.message" placeholder="Write a message..." class="form-control">
      <button class="huge ui circular icon button" id="search-button-circle" type="submit">
        <i class="white send icon"></i>
      </button>
      <i class="write icon"></i>
    </div>
  </form>
</div>


<!-- SEMANTIC MODAL DROPDOWN -->
  <script>
    $('.dropdown').dropdown({
        // you can use any ui transition
        transition: 'drop'
    });
  </script>

  <script>
    $('.right.sidebar').first()
      .sidebar('setting', 'transition', 'uncover')
      .sidebar('attach events', '.toggle.button')
      .sidebar('attach events', '.menu .item')
    ;
  </script>

messages.html

body {
  padding: 0;
  background: #eef2f5;
}

*:focus {
    outline: 0 !important;
}

a, span, p, h1, h2, h3, h4, h5, body {font-family: 'Roboto', Arial, sans-serif !important;}

.page-wrapper {
  max-width:550px;
  margin-right: auto;
  margin-left: auto;
  padding:15px;
}

.page-wrapper .logo-img {
  margin-top:-10px;
}


.main {
  position:absolute;
  top:0;
  left:0;
  height:100%;
  width:100%;
}

.sidebar {
  display:inline-block;
  width:20%;
  vertical-align: top;
  height:100%;
  background:#393f4d;
  padding-bottom:100px;
  float:left;
  min-height: 1600px;
}

.sidebar .slack-name {
  background:#313743;
  padding:15px 0px 15px 15px;
  border-bottom: 3px solid #2c313c;
}

.sidebar .slack-name h2{
  color:#fff;
  font-size:22px;
  font-weight:bold;
  margin-top:0px;
  margin-bottom:0px;
}

.sidebar .room-list {
  margin-top:20px;
  background:#4d394b;
}

.sidebar .room-list .room a{
  display:block;
  color:rgba(255,255,255,0.6);
  padding:3px 0px 3px 15px;
  width:90%;
  font-weight:300;
  -webkit-border-top-right-radius: 4px;
  -webkit-border-bottom-right-radius: 4px;
  -moz-border-radius-topright: 4px;
  -moz-border-radius-bottomright: 4px;
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
}

.sidebar .room-list .room a:hover{
  text-decoration: none;
  background:#3E313C;
}

.sidebar .room-list .room a.selected{
  background:#4c9689;
  color:#fff;
  text-decoration: none !important;
}

.sidebar .room-list .room.create {
  font-style: italic;
}

.sidebar .room-list .list-head {
  margin-top:10px;
  color: #a5adbe;
  font-weight: bold;
  margin-left: 10px;
  text-transform: uppercase;
}

.sidebar .my-info {
  position:fixed;
  bottom:0;
  padding:20px 15px;
  background:#313743;
  width:20%;
  border-top: 3px solid #2c313c;
}

.sidebar .my-info .user-pic {
  display: inline-block;
  vertical-align: top;
  width:44px;
  height:44px;
  border-radius:4px;
}

.sidebar .my-info .user-info {
  padding-left:5px;
  display: inline-block;
  vertical-align: top;
}

.sidebar .my-info .user-info .user-name {
  color:#fff;
  font-size:16px;
  font-weight:bold;
}

.sidebar .my-info .user-info .options {
  color:#999;
  font-size:12px;
}

.sidebar .my-info .user-info .options a{
  color:#999;
  font-size:12px;
}

.sidebar .presence {
  border-radius: 50%;
  display: inline-block;
  width: 10px;
  height: 10px;
  background: #ab9ba9;
  vertical-align: middle;
}

.sidebar .presence.online {
  background: #99d04a;
}

.message-pane {
  display:inline-block;
  vertical-align: top;
  height:100%;
  width:80%;
  padding: 0;
  background: #eef2f5 !important;
  float: right;
  min-height: 1600px;
}

.message-pane .header {
  top: 0;
  width: 100%;
  z-index: 2;
}

.message-pane .header h1 {
  padding: 17px 0 0 0;
  margin-top:0px;
  margin-bottom:0px;
  font-size:24px;
  color:#393f4d;
  font-weight:900;
}

.message-pane .message-form {
  padding: 0;
  width: 100%;
}

.form-wrapper {
  position: fixed;
  display: block;
  width: 80%;
  bottom: 0;
  overflow: hidden;
  background: #eef2f5;
  padding: 17px 0px 7px 20px;
  box-shadow: 0px -2px 5px 0px rgba(0,0,0,.26);
  z-index: 100;
  }

.message-pane .message-wrap {
  margin: 15px 15px 15px 20px;
  transition: box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  transition-delay: 0.2s;
  box-shadow: 0 1.3px 4px 0 rgba(0, 0, 0, 0.26);
  padding: 15px;
  background: #FFF;
  border-radius: .2rem;
}

.message-pane .message-wrap .user-pic {
  width:36px;
  height:36px;
  border-radius:4px;
  display: inline-block;
  vertical-align: top;
}

.message-pane .message-wrap .message-info {
  display: inline-block;
  vertical-align: top;
  padding-left:5px;
}

.message-pane .message-wrap .message-info .user-name {
  color:#555459;
  font-weight:900;
}

.message-pane .message-wrap .message-info .user-name span{
  color:#ccc;
  font-weight: normal;
  font-size:10px;
}
.ui.comments .comment a.author {
  font-size: 1.2em;
}
.avatar-container {
  width: 8%;
}

/*  ------------SEMANTIC FONTS------------ */
@font-face {
 font-family: 'Icons';
 src: url("https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/1.12.2/themes/default/assets/fonts/icons.eot");
 src: url("https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/1.12.2/themes/default/assets/fonts/icons.eot?#iefix") format('embedded-opentype'), url("https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/1.12.2/themes/default/assets/fonts/icons.woff2") format('woff'), url("https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/1.12.2/themes/default/assets/fonts/icons.woff") format('woff'), url("https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/1.12.2/themes/default/assets/fonts/icons.ttf") format('truetype'), url("https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/1.12.2/themes/default/assets/fonts/icons.svg#icons") format('svg');
 font-style: normal;
 font-weight: normal;
 font-variant: normal;
 text-decoration: inherit;
 text-transform: none;
 text-rendering: optimizeLegibility;
}

/* -------------MATERIAL DESIGN CUSTOM STYLES---------------  */
.button.raised {
      transition: box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
      transition-delay: 0.2s;
      box-shadow: 4px 2px 5px 0 rgba(0, 0, 0, 0.26);
    }

/* -----------HEADER-------------- */
#header-desktop {
  position: fixed !important;
  display: inline-block;
  top: 0;
  width: 100%;
  background: #f8f9fb;
  height: 65px;
  z-index: 100;
}
.page-wrapper, .main {
  position: relative;
  top: 65px;
}
#logo-home, #logo-hash {
  padding-top: 0em;
  max-width: 180px;
  max-height: 160px;
}
#logo-hash {
  visibility: hidden;
}
#channel-dropdown {
  visibility: hidden;
}
#logo-column {
  height: 50px;
}

/* ----------SIDEBAR----------- */
.channel {
  padding: 2px 0px;
}
.channel.ng-scope a {
  color: #a5adbe;
  text-decoration: none;
}
.channel.create a {
  color: #a5adbe;
}
.channel-list {
  padding: 15px;
  font-size: 1.1em;
}
.list-head {
  color: #a5adbe;
  text-transform: uppercase;
  font-weight: bold;
  padding-bottom: 8px;
}
a.ng-binding.selected {
  color: #FFF;
  font-weight: bold;
}
.channel.create {
  padding-bottom: 40px;
  padding-top: 5px;
  border-top: 3px solid #2c313c;
  margin-top: 5px;
}
/* --------------MESSAGE---------------- */
input#input-message, input[type="text"] {
  transition: box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  transition-delay: 0.2s;
  box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.15);
  margin-bottom: 7px;
}
#search-button-circle {
  border-radius: 50%;
  color: #fff;
  overflow: hidden;
  transition: box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  transition-delay: 0.2s;
  box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26);
  background-color: #684d5e;
  margin: 0 15px 7px 15px;
  z-index: 998;
  height: 50px;
  width: 50px;
}
.ui.card {
  width: 92%;
  float: left;
  margin-left: 30px;
  margin-right: 20px;
  transition: box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  transition-delay: 0.2s;
  box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.15);
}
.ui.comments .comment .avatar img {
  float: left;
  margin-top: 11px;
  margin-left: 20px;
  margin-right: 10px;
}
.ui.comments {
  margin: 0;
  max-width: 100%;
}
.ui.comments img {
  max-width: 100%;
  max-height: 100%;
  margin: 8px 0 12px 0;
}

/* -------------DROPDOWN--------------- */
.item a {
  color: #684d5e;
  line-height: 1.2em;
  font-size: 1.1em;
}
.item a:hover {
  color: #684d5e;
  line-height: 1.2em;
}
.item a.selected {
  color: #684d5e;
  font-weight: bold;
  font-size: 1.1em;
  line-height: 1.2em;
}
#hash {
  max-width: 18px;
  max-height: 18px;
  margin-right: 3px;
}
.menu {
  width: 110%;
}
i.small.chevron.down.icon {
  vertical-align: middle;
  padding-bottom: 1.3em;
}
i.white.send.icon:before {
  margin-left: -5px;
}
.ui.circular.button > .icon {
  width: 1em;
  vertical-align: baseline;
  height: 1em;
}
#create-channel {
  background: #F3F3F3;
}
#create-channel:hover {
  background: #393f4d;
}
#create-channel a {
  color: #684d5e;
}
#create-channel a:hover {
  color: #FFF;
}
body.pushable > .pusher {
  /*background: #393f4d !important;*/
}
#header-mobile {display: none;}
#messages-channel-active {margin-left: 18px;}


/* --------------SIDE POPOUT MENU------------------- */
.ui.icon.toggle.button.right.floated {
    background: none;
    padding-top: .1em;
    color: #684d5e !important;
  }
  .ui.icon.toggle.button.right.floated:hover, .ui.icon.toggle.button.right.floated:active {
    color: #393f4d !important;
    outline: 0 !important;
    box-shadow: none !important;
  }
  .pushable > .pusher {
    overflow: visible;
  }

/* --------------MEDIA QUERIES------------- */
@media only screen and (min-width: 1000px) and (max-width: 1370px) {
  .ui.card {
    width: 90%;
    margin-right: 10px;
  }
}
@media only screen and (max-width: 999px) {
  .ui.card {
    width: 89%;
    margin-right: 10px;
  }
  #header-desktop, #logo-column {
    display: none;
  }
  .sidebar {
    display: none;
  }
  .message-pane, .form-wrapper {
    width: 100%;
  }
  .message-pane .message-wrap {
    margin: 15px 20px 15px 20px;
  }
  #logo-hash {
      visibility: visible;
      max-width: 45px;
      max-height: 45px;
      padding-top: 3px;
  }
  #logo-home {
    display: none;
  }
  #channel-dropdown {
    visibility: visible;
  }
  #header-mobile {
      position: fixed !important;
      display: inline-block;
      padding: 6px 0 0 0;
      height: 60px;
      top: 0;
      width: 100%;
      background: #f8f9fb;
      z-index: 100;
  }
  .button.raised {
      transition: box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
      transition-delay: 0.2s;
      box-shadow: 0px 2px 5px 0 rgba(0, 0, 0, 0.2);
  }
  #messages-channel-active {display: none;}
  .main {
    top: 60px;
  }
  .ui.dropdown > .menu {
    width: 145%;
  }
  .header p {margin-left: 5px;}
  .ui.icon.toggle.button.right.floated {
    padding-top: .5em;
  }
  .message-pane .header h1 {
    padding: 7px 0 0 0;
  }
}
@media only screen and (max-width: 768px) {
  .ui.card {
    width: 80%;
    margin-right: 0px;
  }
}

的main.css

{{1}}

1 个答案:

答案 0 :(得分:1)

您应将主要可滚动内容放在<md-content></md-content>内,并可能添加md-scroll-y作为属性以防止x滚动。对于您的应用,您希望在此处围绕您的聊天区域,以便仅滚动而不是整个页面滚动。

以下是使用md-content的演示 https://material.angularjs.org/latest/#/demo/material.components.content