https://stackoverflow.com/questions/38206868/center-scroll-horizontally-according-to-active-link
https://www.google.com.tw/search?q=horizontal+scroll+navbar+active+class+right+place&oq=horizontal+scroll+navbar+active+class+right+place&aqs=chrome..69i57.22903j0j7&sourceid=chrome&ie=UTF-8
2017年11月23日 星期四
2017年11月19日 星期日
Masonry images overlapping above each other - 圖片重疊問題
JS部分
<script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script>
<!--先放masonjs 再放imgloadjs,才不會黏再一起,此script要放在網頁下面-->
<script src="https://unpkg.com/masonry-layout@4/dist/masonry.pkgd.min.js"></script>
<script src="https://unpkg.com/imagesloaded@4/imagesloaded.pkgd.min.js"></script>
<script>
// 啟動 Masonry
var $grid = $('.grid').masonry({
itemSelector: '.grid-item',
percentPosition: true,
columnWidth: '.grid-sizer'
});
// 當圖片都下載後才開始布局
$grid.imagesLoaded().progress( function() {
$grid.masonry();
});
</script>
HTML部分
<div class="grid-sizer"></div>
<div class="grid row" data-masonry='{ "itemSelector": ".grid-item" }'>
<div class="grid-item col-xs-6 col-sm-4 col-md-4">法語課程</div>
<div class="grid-item col-xs-6 col-sm-4 col-md-4">法語課程2</div>
</div>
2017年9月3日 星期日
jquery 設定螢幕高度
<script>
$(document).ready(function () {
y = $(window).innerHeight() - 463;
$("#viewport, .item").height(y);
$(window).resize(function () {
x = $(window).innerHeight() - 463;
$("#viewport, .item").height(x);
$("#eDay").text(x);
});
});
</script>
$(document).ready(function () {
y = $(window).innerHeight() - 463;
$("#viewport, .item").height(y);
$(window).resize(function () {
x = $(window).innerHeight() - 463;
$("#viewport, .item").height(x);
$("#eDay").text(x);
});
});
</script>
2017年6月29日 星期四
input數量+ -
HTML
<input type='button' value='-' class='qtyminus' field='quantity' />
<input type='text' name='quantity' value='0' class='qty' />
<input type='button' value='+' class='qtyplus' field='quantity' />
<input type='button' value='-' class='qtyminus' field='quantity2' />
<input type='text' name='quantity2' value='0' class='qty' />
<input type='button' value='+' class='qtyplus' field='quantity2' />
JS
//用來做訓練人員數量加減
jQuery(document).ready(function(){
// This button will increment the value
$('.qtyplus').click(function(e){
// Stop acting like a button
e.preventDefault();
// Get the field name
fieldName = $(this).attr('field');
// Get its current value
var currentVal = parseInt($('input[name='+fieldName+']').val());
// If is not undefined
if (!isNaN(currentVal)) {
// Increment
$('input[name='+fieldName+']').val(currentVal + 1);
} else {
// Otherwise put a 0 there
$('input[name='+fieldName+']').val(0);
}
});
// This button will decrement the value till 0
$(".qtyminus").click(function(e) {
// Stop acting like a button
e.preventDefault();
// Get the field name
fieldName = $(this).attr('field');
// Get its current value
var currentVal = parseInt($('input[name='+fieldName+']').val());
// If it isn't undefined or its greater than 0
if (!isNaN(currentVal) && currentVal > 0) {
// Decrement one
$('input[name='+fieldName+']').val(currentVal - 1);
} else {
// Otherwise put a 0 there
$('input[name='+fieldName+']').val(0);
}
});
});
CSS
.qty{
-webkit-appearance: none;
border-radius: 0;
line-height: 2.5;
width: 36px;
height: 25px;
border-left: none;
border-right: none;
border-top: 1px solid #ccc;
border-bottom: 1px solid #ccc;
vertical-align: middle;
text-align: center;
background-color: #fff;
margin: 0;
margin-left: -3px;
margin-right: -3px;
}
.qtyminus, .qtyplus {
-webkit-appearance: none;
border-radius: 0;
display: inline-block;
height: 25px;
width: 20px;
vertical-align: middle;
cursor: pointer;
box-shadow: none;
border: solid 1px #ccc;
padding: 0;
font-size: 20px;
background: #EEEEEE;
}
<input type='button' value='-' class='qtyminus' field='quantity' />
<input type='text' name='quantity' value='0' class='qty' />
<input type='button' value='+' class='qtyplus' field='quantity' />
<input type='button' value='-' class='qtyminus' field='quantity2' />
<input type='text' name='quantity2' value='0' class='qty' />
<input type='button' value='+' class='qtyplus' field='quantity2' />
JS
//用來做訓練人員數量加減
jQuery(document).ready(function(){
// This button will increment the value
$('.qtyplus').click(function(e){
// Stop acting like a button
e.preventDefault();
// Get the field name
fieldName = $(this).attr('field');
// Get its current value
var currentVal = parseInt($('input[name='+fieldName+']').val());
// If is not undefined
if (!isNaN(currentVal)) {
// Increment
$('input[name='+fieldName+']').val(currentVal + 1);
} else {
// Otherwise put a 0 there
$('input[name='+fieldName+']').val(0);
}
});
// This button will decrement the value till 0
$(".qtyminus").click(function(e) {
// Stop acting like a button
e.preventDefault();
// Get the field name
fieldName = $(this).attr('field');
// Get its current value
var currentVal = parseInt($('input[name='+fieldName+']').val());
// If it isn't undefined or its greater than 0
if (!isNaN(currentVal) && currentVal > 0) {
// Decrement one
$('input[name='+fieldName+']').val(currentVal - 1);
} else {
// Otherwise put a 0 there
$('input[name='+fieldName+']').val(0);
}
});
});
CSS
.qty{
-webkit-appearance: none;
border-radius: 0;
line-height: 2.5;
width: 36px;
height: 25px;
border-left: none;
border-right: none;
border-top: 1px solid #ccc;
border-bottom: 1px solid #ccc;
vertical-align: middle;
text-align: center;
background-color: #fff;
margin: 0;
margin-left: -3px;
margin-right: -3px;
}
.qtyminus, .qtyplus {
-webkit-appearance: none;
border-radius: 0;
display: inline-block;
height: 25px;
width: 20px;
vertical-align: middle;
cursor: pointer;
box-shadow: none;
border: solid 1px #ccc;
padding: 0;
font-size: 20px;
background: #EEEEEE;
}
2017年3月1日 星期三
Sticky sidebar 的作法
<main>
<div id="content">文字</div>
<aside id="aside">選單</div>
<main>
#content
#aside
可以更名
參考網站
http://spoiledmilk.com/blog/sticky-sidebar/
另一種做法
http://abgne.tw/jquery/jquery-plugins/sticky-sidebar.html
<div id="content">文字</div>
<aside id="aside">選單</div>
<main>
#content
#aside
可以更名
參考網站
http://spoiledmilk.com/blog/sticky-sidebar/
另一種做法
http://abgne.tw/jquery/jquery-plugins/sticky-sidebar.html
2017年2月2日 星期四
Bootstrap dropdown menu don't work in IE8, 下拉選單在IE8出不來
解決方法:
加上filter:none !important;
.navbar-inverse .nav li.dropdown.open > .dropdown-toggle,
.navbar-inverse .nav li.dropdown.active > .dropdown-toggle,
.navbar-inverse .nav li.dropdown.open.active > .dropdown-toggle,
.nav,
.navbar,
.navbar-inverse .navbar-inner {
filter:none!important;
background-image: none;
}
參考網址:https://github.com/twbs/bootstrap/issues/6548
加上filter:none !important;
.navbar-inverse .nav li.dropdown.open > .dropdown-toggle,
.navbar-inverse .nav li.dropdown.active > .dropdown-toggle,
.navbar-inverse .nav li.dropdown.open.active > .dropdown-toggle,
.nav,
.navbar,
.navbar-inverse .navbar-inner {
filter:none!important;
background-image: none;
}
參考網址:https://github.com/twbs/bootstrap/issues/6548
訂閱:
文章 (Atom)