課程
/前端開發
/Bootstrap
/認識響應式布局
代碼和老師的一樣,為什么右邊列表擠下去了
2016-12-02
源自:認識響應式布局 3-3
正在回答
我查看了例子中的源碼,有個offcanvas.css和offcanvas.js需要加載。
建議使用chrome瀏覽器,使用開發者工具查看網頁源碼學習
offcanvas.css的源碼:
/*
?* Style tweaks
?* --------------------------------------------------
?*/
/*html,
body {
? overflow-x: hidden; ?Prevent scroll on narrow devices?
}
? padding-top: 70px;
footer {
? padding: 30px 0;
}*/
?* Off Canvas
@media screen and (max-width: 767px) {
? .row-offcanvas {
? ? position: relative;
? ? -webkit-transition: all .25s ease-out;
? ? ? ? ?-o-transition: all .25s ease-out;
? ? ? ? ? ? transition: all .25s ease-out;
? }
? .row-offcanvas-right {
? ? right: 0;
? .row-offcanvas-left {
? ? left: 0;
? .row-offcanvas-right
? .sidebar-offcanvas {
? ? right: -50%; /* 6 columns */
? .row-offcanvas-left
? ? left: -50%; /* 6 columns */
? .row-offcanvas-right.active {
? ? right: 50%; /* 6 columns */
? .row-offcanvas-left.active {
? ? left: 50%; /* 6 columns */
? ? position: absolute;
? ? top: 0;
? ? width: 50%; /* 6 columns */
offcanvas.js的源碼:
$(document).ready(function () {
? $('[data-toggle="offcanvas"]').click(function () {
? ? $('.row-offcanvas').toggleClass('active')
? });
});
在 .html代碼中加載這兩個文件,樣式和行為才能起效。
貼兩個代碼片段,你可以根據這個代碼片段定位到你的代碼,做相應修改:
這里調用了樣式,button調用了data-toggle方法
<div class="container-fluid">
? <div class="row row-offcanvas row-offcanvas-right">
? ? <div class="col-sm-9">
? ? ? <p class="pull-right visible-xs">
? ? ? ? <button class="btn-xs btn btn-primary" data-toggle="offcanvas">Toggle</button>
? ? ? </p>
下面是list-group需要加載的樣式
<div class="col-sm-3 sidebar-offcanvas" id="sidebar">
? ? ? <ul class="list-group">
慕婉清1576819
老師的代碼不全 ? 還沒 設置 按鈕功能 所以是垂直排序
舉報
使用Bootstrap前端框架,本教程讓網站兼容不同終端不再是夢
1 回答右面的列表跑到下面去了
2 回答右邊列表沒出現了
1 回答如何寫一個下拉列表?
1 回答沒講完啊,點擊TOGGLE出現右邊列表
1 回答新的風暴已經出現,右側列表點擊出現不會弄啊,已經引用了官方的offcanvas的文件了,但是為啥就是不成功呢?如下
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2017-03-19
我查看了例子中的源碼,有個offcanvas.css和offcanvas.js需要加載。
建議使用chrome瀏覽器,使用開發者工具查看網頁源碼學習
offcanvas.css的源碼:
/*
?* Style tweaks
?* --------------------------------------------------
?*/
/*html,
body {
? overflow-x: hidden; ?Prevent scroll on narrow devices?
}
body {
? padding-top: 70px;
}
footer {
? padding: 30px 0;
}*/
/*
?* Off Canvas
?* --------------------------------------------------
?*/
@media screen and (max-width: 767px) {
? .row-offcanvas {
? ? position: relative;
? ? -webkit-transition: all .25s ease-out;
? ? ? ? ?-o-transition: all .25s ease-out;
? ? ? ? ? ? transition: all .25s ease-out;
? }
? .row-offcanvas-right {
? ? right: 0;
? }
? .row-offcanvas-left {
? ? left: 0;
? }
? .row-offcanvas-right
? .sidebar-offcanvas {
? ? right: -50%; /* 6 columns */
? }
? .row-offcanvas-left
? .sidebar-offcanvas {
? ? left: -50%; /* 6 columns */
? }
? .row-offcanvas-right.active {
? ? right: 50%; /* 6 columns */
? }
? .row-offcanvas-left.active {
? ? left: 50%; /* 6 columns */
? }
? .sidebar-offcanvas {
? ? position: absolute;
? ? top: 0;
? ? width: 50%; /* 6 columns */
? }
}
offcanvas.js的源碼:
$(document).ready(function () {
? $('[data-toggle="offcanvas"]').click(function () {
? ? $('.row-offcanvas').toggleClass('active')
? });
});
在 .html代碼中加載這兩個文件,樣式和行為才能起效。
貼兩個代碼片段,你可以根據這個代碼片段定位到你的代碼,做相應修改:
這里調用了樣式,button調用了data-toggle方法
<div class="container-fluid">
? <div class="row row-offcanvas row-offcanvas-right">
? ? <div class="col-sm-9">
? ? ? <p class="pull-right visible-xs">
? ? ? ? <button class="btn-xs btn btn-primary" data-toggle="offcanvas">Toggle</button>
? ? ? </p>
下面是list-group需要加載的樣式
<div class="col-sm-3 sidebar-offcanvas" id="sidebar">
? ? ? <ul class="list-group">
2016-12-04
老師的代碼不全 ? 還沒 設置 按鈕功能 所以是垂直排序