Bootstrap标头没有正确折叠

时间:2017-08-17 13:50:36

标签: twitter-bootstrap jsp header collapse

我正在开发一个网络电台,偶然发现Bootstrap导航栏切换按钮有些麻烦,应该自适应地折叠标题内容。

在页面加载时,按钮最初几次有效。但是,垂直滚动条出现在我的页面一侧,一旦发生,按钮就不会再折叠标题内容。

UPD:我发现我的问题的原因是从Icecast的 playlist.log 中取得的10首最近播放的曲目列表文件并由Tomcat服务器呈现到特殊页面 my.site/titles.jsp 然后使用jQuery函数 $('#tracklist')。html()被追加到索引页面。

每次页面加载后都会发生这种情况,平均延迟时间为2.5秒,这是由于来自Last.fm API的响应时间,我从最近的跟踪列表中获取每个元素的跟踪覆盖。因此,当我按下导航栏切换按钮时,标题会展开,并将其高度添加到页面正文。 getTitles()函数会为最近的tracklist添加10行文本,默认情况下这些文本是不可见的。尽管不可见,但此列表在其附加到页面时也会增加页面主体高度。当它发生时,标题切换按钮不能再折叠标题内容。

我正在使用bootstrap版本3.3.7。

以下是我网站的截图:

Scrollbar appeared and button doesn't work anymore

我的index.jsp页面代码:

protected void onCreate(Bundle savedInstanceState,  @Nullable PersistableBundle persistentState);

CSS:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<html>
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <meta name="_csrf" content="${_csrf.token}" />
    <!-- default header name is X-CSRF-TOKEN -->
    <meta name="_csrf_header" content="${_csrf.headerName}" />
    <title>Web&nbsp;radio&nbsp;&#9899;&nbsp;</title>
    <link type="text/css" href="css/common.css" rel="stylesheet" />
    <link rel="shortcut icon" href="skin/image/favicon.ico?" type="image/x-icon" />
    <link href="https://fonts.googleapis.com/css?family=Arimo" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Oswald:700" rel="stylesheet">
    <link rel="stylesheet" href="skin/font-awesome-4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/bootstrap-theme.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
</head>
<body>
<nav class="navbar-wrapper navbar-default navbar-static-top">
  <div class="container-fluid">
    <div class="navbar-header">
      <button class="navbar-toggle collapsed" data-toggle="collapse" data-target=".headerContent" aria-expanded="false">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="logo navbar-brand" onclick="reload()">
      </a>
    </div>
    <div class="collapse navbar-collapse headerContent">
      <ul class="nav navbar-nav" id="toggles">
        <li class="active"><a tabindex="0" role="button" id="amp" onclick="_setMedia('amp')"><span>D&amp;B channel</span></a></li>
        <li><a tabindex="0" role="button" id="chl" onclick="_setMedia('chl')"><span>Chillout channel</span></a></li>
        <li><a tabindex="0" role="button" id="dsc" onclick="_setMedia('dsc')">                   <span>Disco channel</span></a></li>
      </ul>
      <c:choose>
        <c:when test="${empty loggedInUser}">
          <div class="row navbar-right">
            <div class="auth navbar-text">
              <a tabindex="0" href="login" target="_blank"><span>Login</span> </a>
            </div>
            <div class="auth navbar-text"><a tabindex="0" href="register" target="_blank"><span>Register</span> </a>
            </div>
          </div>
        </c:when>
        <c:otherwise>
          <div class="row navbar-right">
            <div class="auth navbar-text"><a><span>Hello ${loggedInUser}! &nbsp;</span></a></div>
            <div class="auth navbar-text"><a tabindex="0" id="logout" href="logout">Logout</a></div>
           </div>
         </c:otherwise>
      </c:choose>
    </div>
  </div>
</nav>
<div>
        <div class="container" id="canvas">
            <div class="row" id="stations">
                <div class="col-md-3" id="nowPlayingImg">
                    <!--* Now playing image taken from the Last.fm API *-->
                </div>
                <div class="col-md-7">
                    <div class="jp-jplayer" id="jquery_jplayer_1"></div>
                    <div id="jp_container_1" class="jp-audio-stream" role="application" aria-label="media player">
                        <div class="jp-type-single">
                            <div class="jp-gui jp-interface">

                                <div class="subdiv">
                                    <div class="jp-controls">
                                        <a tabindex="0" role="button"><i class="fa fa-play jp-play fa-2x gradient-icon" aria-hidden="true"></i></a>
                                    </div>
                                    <div class="jp-details">
                                        <div class="jp-title">
                                            <p id="track-title">&nbsp;</p>
                                        </div>
                                    </div>

                                </div>

                                <div class="jp-volume-controls">
                                    <a tabindex="0" role="button"><i class="fa fa-volume-off jp-mute gradient-icon" aria-hidden="true"></i></a>
                                    <a tabindex="0" role="button"><i class="fa fa-volume-up jp-volume-max gradient-icon" tabindex="1" role="button" aria-hidden="true"></i></a>
                                    <div class="jp-volume-bar">
                                        <div class="jp-volume-bar-value"></div>
                                    </div>

                                </div>

                                <div tabindex="0" class="onclick-menu" id="recent">
                                    <i role="button" class="fa fa-bars gradient-icon" aria-hidden="true"></i>
                                    <!-- here the list of 10 recently played tracks is being appended -->
                                </div>
                            </div>

                            <div class="jp-no-solution">
                                <span>Update Required</span>
                                To play the media you will need to either update your browser to a recent version or update your <a href="http://get.adobe.com/flashplayer/" target="_blank">Flash plugin</a>.
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
<script src="js/jquery.jplayer.min.js"></script>
<script src="js/player.js"></script>
<script type="text/javascript">
        function reload() {
            window.location.reload(false);
        }

</script>
</body>
</html>

Javascript

::selection {
  background: var(--player-bg-color); 
}
::-moz-selection {
  background: var(--player-bg-color);
}
html, body {
  height: 100%;
}
body {
  background: url('../image/bg.jpg') no-repeat !important;
  -webkit-background-size: cover !important;
  background-size: cover !important;
}
a {
  outline: none !important;
  cursor: pointer;
}
:root {
  --font-fam: 'Raleway', sans-serif;
  --whitey-color: #fafafa;
  --header-row-h: 110px;
  --header-row-minh: 65px;
  --player-bg-color: #131415;
  --player-bg2-color: #202224;
  --row-background: rgb(24, 24, 24);
  --logo-img: url("../image/logo.png");
  --hover-text-color: #E0B35B;
}

.auth {
  line-height: 70px;
  margin-top: 40px;
  margin-left :0;
  font-family: 'Oswald', sans-serif;
}
.auth a {
  font-size: 20px;
  color: black;
}

.auth a:hover,
.auth a:focus,
.auth a:active {
  color: black;
  text-decoration: none;
}
.navbar {
  border: none !important;
}

.active > a {
  box-shadow: none !important;
}

.active > a > span {
  border-bottom: 3px solid black !important;
  border-top: 3px solid black !important;
}
.active > a:hover > span {
  border-bottom: 3px solid var(--hover-text-color) !important;
  border-top: 3px solid var(--hover-text-color) !important;
}

.container-fluid {
  background: #dea437 !important;
  /*background: linear-gradient(0, var(--hover-text-color), #dea437);*/
  box-shadow: none !important;
}

#toggles a {
  font-size: 30px;
  text-transform: uppercase;
  color: #000;
  background: #dea437 !important;
  /*background: linear-gradient(0, var(--hover-text-color), #dea437);*/
  font-family: 'Oswald', sans-serif;;
  line-height: 80px;
}
#toggles a:hover {
  background: #000 !important;
  font-family: 'Oswald', sans-serif;
  color: var(--hover-text-color);
}
#toggles a:hover span {
  border-bottom: 3px solid transparent;
  border-top: 3px solid transparent;
}
#toggles a span {
  -webkit-transition: all 0.3s;
  -moz-transition: all 0.3s;
  -o-transition: all 0.3s;
  transition: all 0.3s;
  border-bottom: 3px solid transparent;
  border-top: 3px solid transparent;
}
.logo {
  background: var(--logo-img) no-repeat;
  background-size: var(--header-row-h);
  opacity: 1.0;
  height: var(--header-row-h);
  margin-right: 10px;
  width: var(--header-row-h);
  max-height: var(--header-row-h);
  min-height: var(--header-row-h);
  cursor: pointer;
}
.onclick-menu {
    width: 32px;


height: 32px;
  color: #171e2f;
  position: absolute; /*absolute;*/
  top: 50px;
  left: 450px;
  float:right;
  display: inline-block; /*block*/
  padding: 0;
  margin: 0 0 1em 0;
  outline: 0;
  transition: all 0.33s ease-in;
}

.onclick-menu-content {
    font-family: 'Arimo', sans-serif;
    pointer-events: auto;
    position: absolute;
    left: -473px;
    width: 515px;
    text-overflow: ellipsis;
    white-space: nowrap;
    top: 16px;
    z-index: 1;
    opacity: 1;
    visibility: visible;
    margin-top: 19px;
    margin-left: 0;
    padding: 10px;
    border-bottom: 5px;
}

.onclick-menu:focus {
    pointer-events: none;
}

.onclick-menu:focus .onclick-menu-content {
    opacity: 1;
    visibility: visible;
}

.onclick-menu-content li:nth-child(even) {
    background-color: #181818;

}
.onclick-menu-content li:nth-child(odd) {
    background-color: #222222;
}

.onclick-menu-content li {
    list-style-type: none;
    white-space: nowrap;
    -webkit-user-select: none; 
    -moz-user-select: none; 
    -ms-user-select: none;
    user-select: none;
    display: block;
    height: 34px;
    z-index: -5;
    line-height: 34px;
    border: none;
    outline: 0;
    cursor: default;
    transform: translateX(0);
}

.onclick-menu-content li:hover {
    transform: translateX(3px);
}


.onclick-menu-content a {
    text-decoration: none;
    color: var(--whitey-color);
    font-size: 14px;
    height: 32px;
    vertical-align: middle;
    display: inline-block;
    padding-right: 10px;
}
.onclick-menu-content a:hover {
    color: var(--hover-text-color);
    text-decoration: none;
}

.onclick-menu-content li:hover > img {
    filter: none;
}

.onclick-menu-content li > img {
    padding-right: 10px;
    pointer-events: none;
    filter: grayScale(100%);
    vertical-align: middle;
}
  .onclick-menu-content ul:first-child {
    filter:none;
}

0 个答案:

没有答案