css配合jquery美化 select
更新時(shí)間:2013年11月29日 16:59:19 作者:
select的美化在之前的文章中也有介紹過(guò),在本文將為大家介紹下使用css配合jquery美化select,感興趣的朋友可以參考下
一個(gè)簡(jiǎn)單的css配合jq美化select
<div id="main">
<section id="basic-usage">
<select id="basic-usage-demo">
<option value="">請(qǐng)選擇…</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select>
</section>
</div>
<script>
$(document).ready(function() {
$('#basic-usage-demo').fancySelect();
// Boilerplate
var repoName = 'fancyselect'
$.get('' + repoName, function(repo) {
var el = $('#top').find('.repo');
el.find('.stars').text(repo.watchers_count);
el.find('.forks').text(repo.forks_count);
});
var menu = $('#top').find('menu');
function positionMenuArrow() {
var current = menu.find('.current');
menu.find('.arrow').css('left', current.offset().left + (current.outerWidth() / 2));
}
$(window).on('resize', positionMenuArrow);
menu.on('click', 'a', function(e) {
var el = $(this),
href = el.attr('href'),
currentSection = $('#main').find('.current');
e.preventDefault();
menu.find('.current').removeClass('current');
el.addClass('current');
positionMenuArrow();
if (currentSection.length) {
currentSection.fadeOut(300).promise().done(function() {
$(href).addClass('current').fadeIn(300);
});
} else {
$(href).addClass('current').fadeIn(300);
}
});
menu.find('a:first').trigger('click')
});
</script>
<style type="text/css">
div#main { font-size: 16px; line-height: 26px; color: #fff; }
div#main div.fancy-select { margin: 0 auto 60px; width: 200px; }
</style>

復(fù)制代碼 代碼如下:
<div id="main">
<section id="basic-usage">
<select id="basic-usage-demo">
<option value="">請(qǐng)選擇…</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select>
</section>
</div>
復(fù)制代碼 代碼如下:
<script>
$(document).ready(function() {
$('#basic-usage-demo').fancySelect();
// Boilerplate
var repoName = 'fancyselect'
$.get('' + repoName, function(repo) {
var el = $('#top').find('.repo');
el.find('.stars').text(repo.watchers_count);
el.find('.forks').text(repo.forks_count);
});
var menu = $('#top').find('menu');
function positionMenuArrow() {
var current = menu.find('.current');
menu.find('.arrow').css('left', current.offset().left + (current.outerWidth() / 2));
}
$(window).on('resize', positionMenuArrow);
menu.on('click', 'a', function(e) {
var el = $(this),
href = el.attr('href'),
currentSection = $('#main').find('.current');
e.preventDefault();
menu.find('.current').removeClass('current');
el.addClass('current');
positionMenuArrow();
if (currentSection.length) {
currentSection.fadeOut(300).promise().done(function() {
$(href).addClass('current').fadeIn(300);
});
} else {
$(href).addClass('current').fadeIn(300);
}
});
menu.find('a:first').trigger('click')
});
</script>
復(fù)制代碼 代碼如下:
<style type="text/css">
div#main { font-size: 16px; line-height: 26px; color: #fff; }
div#main div.fancy-select { margin: 0 auto 60px; width: 200px; }
</style>
相關(guān)文章
jQuery實(shí)現(xiàn)下拉框多選 jquery-multiselect 的實(shí)例代碼
這篇文章主要介紹了jQuery實(shí)現(xiàn)下拉框多選 jquery-multiselect 的實(shí)例代碼,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-07-07jQuery中使用了document和window哪些屬性和方法小結(jié)
未列出常見(jiàn)的比如document.getElementById(),object.addEventListener()等。2011-09-09jquery彈窗時(shí)禁止body滾動(dòng)條滾動(dòng)的例子
今天小編就為大家分享一篇jquery彈窗時(shí)禁止body滾動(dòng)條滾動(dòng)的例子,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-09-09基于jquery的實(shí)現(xiàn)簡(jiǎn)單的表格中增加或刪除下一行
下面的代碼利用jquery簡(jiǎn)單的實(shí)現(xiàn)表格中增加和刪除一行,很簡(jiǎn)單。2010-08-08基于jquery的從一個(gè)頁(yè)面跳轉(zhuǎn)到另一個(gè)頁(yè)面的指定位置的實(shí)現(xiàn)代碼(帶平滑移動(dòng)的效果)
從一個(gè)頁(yè)面跳轉(zhuǎn)到另一個(gè)頁(yè)面的指定位置 如果不帶平滑移動(dòng)的效果 很容易 加個(gè) 錨點(diǎn)就行了2011-05-05