你好,欢迎访问远方教程PC版!
//
设为首页
//
加入收藏
//
给我留言
//
精品导航
//
怀念旧版
网站首页
HTML入门
ASP教程
PHP教程
PS教程
Office教程
站长讲堂
统计之窗
资源下载
正规学历 专本科热招
吉林飞燕舞蹈队
文字广告位5元/月
文字广告位5元/月
文字广告位5元/月
文字广告位5元/月
广告投放QQ:114859419
网站首页
>>
网页特效
>>
菜单特效
>> 文章内容
超醋logo下拉菜单
[日期:2015-01-23] 来源:远方教程 作者:远方教程 阅读:3213次
[字体:
大
中
小
]
访问[
旧版
]
温馨提示:特效代码在文本域中,您可以点击文本域下方的预览按钮先查看效果。
<!--远方教程-满足你的求知欲!http://www.52yfjc.com/--> <style type="text/css"> .select {BORDER-RIGHT: buttonface 0px inset; BORDER-TOP: buttonface 0px inset; FONT: icon; BORDER-LEFT: buttonface 0px inset; WIDTH: 100px; CURSOR: default; BORDER-BOTTOM: buttonface 0px inset} .selected {BORDER-RIGHT: buttonface 0px inset; PADDING-RIGHT: 0px; BORDER-TOP: buttonface 0px inset; PADDING-LEFT: 0px; BACKGROUND: window; PADDING-BOTTOM: 0px; FONT: icon; BORDER-LEFT: buttonface 0px inset; PADDING-TOP: 0px; BORDER-BOTTOM: buttonface 0px inset} .selectTable {BORDER-RIGHT: buttonhighlight 2px inset; BORDER-TOP: buttonhighlight 2px inset; BACKGROUND: buttonface; BORDER-LEFT: buttonhighlight 2px inset; WIDTH: 100%; BORDER-BOTTOM: buttonhighlight 2px inset; HEIGHT: 100%} .option {PADDING-RIGHT: 3px; PADDING-LEFT: 3px; PADDING-BOTTOM: 1px; FONT: icon; WIDTH: 100%; PADDING-TOP: 1px} .dropDown {BORDER-RIGHT: windowtext 1px solid; PADDING-RIGHT: 0px; BORDER-TOP: windowtext 1px solid; PADDING-LEFT: 0px; BACKGROUND: window; VISIBILITY: hidden; PADDING-BOTTOM: 0px; BORDER-LEFT: windowtext 1px solid; WIDTH: 100%; COLOR: windowtext; PADDING-TOP: 0px; BORDER-BOTTOM: windowtext 1px solid; POSITION: absolute} .select .button {BORDER-RIGHT: buttonhighlight 2px outset; PADDING-RIGHT: 0px; BORDER-TOP: buttonhighlight 2px outset; PADDING-LEFT: 0px; FONT-SIZE: 11px; PADDING-BOTTOM: 0px; BORDER-LEFT: buttonhighlight 2px outset; WIDTH: 16px; PADDING-TOP: 0px; BORDER-BOTTOM: buttonhighlight 2px outset; FONT-FAMILY: webdings; HEIGHT: 5px}</style> <p>超醋logo下拉菜单效果-远方教程特效演示:</p> <!--将以下代码加入HTML的<Body></Body>之间--><script language="Javascript"> var overOptionCss = "background: highlight; color: highlighttext"; var sizedBorderCss = "2 inset buttonhighlight"; var globalSelect; //This is used when calling an unnamed selectbox with onclick="this.PROPERTY" var ie4 = (document.all != null); var q = 0; function initSelectBox(el) { copySelected(el); var size = el.getAttribute("size"); // These two lines combined with execution in optionClick() allow you to write: // onchange="alert(this.options[this.selectedIndex].value)" el.options = el.children[1].children; el.selectedIndex = findSelected(el); //Set the index now! // Some methods that are supported on the real SELECT box el.remove = new Function("i", "int_remove(this,i)"); el.item = new Function("i", "return this.options[i]"); el.add = new Function("e", "i", "int_add(this, e, i)"); // The real select box let you have lot of options with the same NAME. In that case the item // needs two arguments. When using DIVs you can't have two with the same NAME (or ID) and // then there is no need for the second argument el.options[el.selectedIndex].selected = true; dropdown = el.children[1]; if (size != null) { if (size > 1) { el.size = size; dropdown.style.zIndex = 0; initSized(el); } else { el.size = 1; dropdown.style.zIndex = 90; if (dropdown.offsetHeight > 250) { dropdown.style.height = "250"; dropdown.style.overflow = "auto"; } } } highlightSelected(el,true); } function int_remove(el,i) { if (el.options[i] != null) el.options[i].outerHTML = ""; } function int_add(el, e, i) { var html = "<div class='option' noWrap"; if (e.value != null) html += " value='" + e.value + "'"; if (e.style.cssText != null) html += " style='" + e.style.cssText + "'"; html += ">"; if (e.text != null) html += e.text; html += "</div>" if ((i == null) || (i >= el.options.length)) i = el.options.length-1; el.options[i].insertAdjacentHTML("AfterEnd", html); } function initSized(el) { //alert("initSized -------->"); var h = 0; el.children[0].style.display = "none"; dropdown = el.children[1]; dropdown.style.visibility = "visible"; if (dropdown.children.length > el.size) { dropdown.style.overflow = "auto"; for (var i=0; i<el.size; i++) { h += dropdown.children[i].offsetHeight; } if (dropdown.style.borderWidth != null) { dropdown.style.pixelHeight = h + 4; //2 * parseInt(dropdown.style.borderWidth); } else dropdown.style.height = h; } dropdown.style.border = sizedBorderCss; el.style.height = dropdown.style.pixelHeight; } function copySelected(el) { var selectedIndex = findSelected(el); selectedCell = el.children[0].rows[0].cells[0]; selectedDiv = el.children[1].children[selectedIndex]; selectedCell.innerHTML = selectedDiv.outerHTML; } // This function returns the first selected option and resets the rest // in case some idiot has set more than one to selcted :-) function findSelected(el) { var selected = null; ec = el.children[1].children; //the table is the first child var ecl = ec.length; for (var i=0; i<ecl; i++) { if (ec[i].getAttribute("selected") != null) { if (selected == null) { // Found first selected selected = i; } else ec[i].removeAttribute("selected"); //Like I said. Only one selected! } } if (selected == null) selected = 0; //When starting this is the most logic start value if none is present return selected; } function toggleDropDown(el) { if (el.size == 1) { dropDown = el.children[1]; if (dropDown.style.visibility == "") dropDown.style.visibility = "hidden"; if (dropDown.style.visibility == "hidden") showDropDown(dropDown); else hideDropDown(dropDown); } } function optionClick() { el = getReal(window.event.srcElement, "className", "option"); if (el.className == "option") { dropdown = el.parentElement; selectBox = dropdown.parentElement; oldSelected = dropdown.children[findSelected(selectBox)] if(oldSelected != el) { oldSelected.removeAttribute("selected"); el.setAttribute("selected", 1); selectBox.selectedIndex = findSelected(selectBox); } if (selectBox.onchange != null) { // This executes the onchange when you chnage the option if (selectBox.id != "") { // For this to work you need to replace this with an ID or name eval(selectBox.onchange.replace(/this/g, selectBox.id)); } else { globalSelect = selectBox; eval(selectBox.onchange.replace(/this/g, "globalSelect")); } } if (el.backupCss != null) el.style.cssText = el.backupCss; copySelected(selectBox); toggleDropDown(selectBox); highlightSelected(selectBox, true); } } function optionOver() { var toEl = getReal(window.event.toElement, "className", "option"); var fromEl = getReal(window.event.fromElement, "className", "option"); if (toEl == fromEl) return; var el = toEl; if (el.className == "option") { if (el.backupCss == null) el.backupCss = el.style.cssText; highlightSelected(el.parentElement.parentElement, false); el.style.cssText = el.backupCss + "; " + overOptionCss; this.highlighted = true; } } function optionOut() { var toEl = getReal(window.event.toElement, "className", "option"); var fromEl = getReal(window.event.fromElement, "className", "option"); if (fromEl == fromEl.parentElement.children[findSelected(fromEl.parentElement.parentElement)]) { if (toEl == null) return; if (toEl.className != "option") return; } if (toEl != null) { if (toEl.className != "option") { if (fromEl.className == "option") highlightSelected(fromEl.parentElement.parentElement, true); } } if (toEl == fromEl) return; var el = fromEl; if (el.className == "option") { if (el.backupCss != null) el.style.cssText = el.backupCss; } } function highlightSelected(el,add) { var selectedIndex = findSelected(el); selected = el.children[1].children[selectedIndex]; if (add) { if (selected.backupCss == null) selected.backupCss = selected.style.cssText; selected.style.cssText = selected.backupCss + "; " + overOptionCss; } else if (!add) { if (selected.backupCss != null) selected.style.cssText = selected.backupCss; } } function hideShownDropDowns() { var el = getReal(window.event.srcElement, "className", "select"); var spans = document.all.tags("SPAN"); var selects = new Array(); var index = 0; for (var i=0; i<spans.length; i++) { if ((spans[i].className == "select") && (spans[i] != el)) { dropdown = spans[i].children[1]; if ((spans[i].size == 1) && (dropdown.style.visibility == "visible")) selects[index++] = dropdown; } } for (var j=0; j<selects.length; j++) { hideDropDown(selects[j]); } } function hideDropDown(el) { if (typeof(fade) == "function") fade(el, false); else el.style.visibility = "hidden"; } function showDropDown(el) { if (typeof(fade) == "function") fade(el, true); else if (typeof(swipe) == "function") swipe(el, 2); else el.style.visibility = "visible"; } function initSelectBoxes() { var spans = document.all.tags("SPAN"); var selects = new Array(); var index = 0; for (var i=0; i<spans.length; i++) { if (spans[i].className == "select") selects[index++] = spans[i]; } for (var j=0; j<selects.length; j++) { initSelectBox(selects[j]); } } function getReal(el, type, value) { temp = el; while ((temp != null) && (temp.tagName != "BODY")) { if (eval("temp." + type) == value) { el = temp; return el; } temp = temp.parentElement; } return el; } if (ie4) { window.onload = initSelectBoxes; document.onclick = hideShownDropDowns; } </SCRIPT><script language="Javascript"> function writeSelectBox(matrix, id, size, onchange, css) { var d = window.document; var ie4 = (document.all != null); if (ie4) { // alert("Before!"); var s = createIEString(matrix, id, size, onchange, css); document.write(s); // alert("After!"); // alert(s); } else { document.write(createXString(matrix, id, size, onchange, css)); } } function createIEString(matrix, id, size, onchange, css) { var str = ""; // Span startTag str += '<span class="select"'; if (size == null) size = 1; str += ' size="' + size + '"'; if (id != null) str += ' id="' + id + '"'; if (onchange != null) str += ' onchange="' + onchange + '"'; if (css != null) str += ' style="' + css + '"'; str += '>\n'; // Table Tag str += '<table class="selectTable" cellspacing="0" cellpadding="0"\n'; str += ' onclick="toggleDropDown(this.parentElement)">\n'; str += '<tr>\n'; str += '<td class="selected"> </td>\n'; str += '<td align="CENTER" valign="MIDDLE" class="Button"\n'; str += ' onmousedown="this.style.border=\'2 inset buttonhighlight\'"\n'; str += ' onmouseup="this.style.border=\'2 outset buttonhighlight\'">\n'; str += '<span style="position: relative; left: 0; top: -2; width: 100%;">6</span></td>\n'; str += '</tr>\n'; str += '</table>\n'; // DropDown startTag str += '<div class="dropDown" onclick="optionClick()" onmouseover="optionOver()" onmouseout="optionOut()">\n'; for (var i=0; i<matrix.length; i++) { html = matrix[i].html; value = matrix[i].value; css = matrix[i].css; selected = matrix[i].selected; // Write option starttag str += '<div class="option"'; if (value != null) str += ' value="' + value + '"'; if (css != null) str += ' style="' + css + '"'; if (selected != null) str += ' selected'; str += '>\n'; // Write HTML contents str += html; // Write end tag str += '</div>\n'; } //DropDown endtag str += '</div>\n'; // Span endTag str += '</span>\n'; return str; } function createXString(matrix, id, size, onchange, css) { // var str = "\n"; // form startTag var str = '<form>\n'; // Select startTag str += '<select'; if (size == null) size = 1; str += ' size="' + size + '"'; if (id != null) str += ' id="' + id + '"'; if (onchange != null) str += ' onchange="' + onchange + '"'; // if (css != null) // str += ' style="' + css + '"'; str += '>\n'; // write options for (var i=0; i<matrix.length; i++) { html = matrix[i].html; value = matrix[i].value; css = matrix[i].css; selected = matrix[i].selected; // Write option starttag str += '\n<option'; if (value != null) str += ' value="' + value + '"'; // if (css != null) // str += ' style="' + css + '"'; if (selected != null) str += ' selected'; str += '>'; // Write HTML contents str += stripTags(html); // Write end tag str += '</option>\n'; } str += '\n</select>\n'; str += '</form>\n'; return str; } function stripTags(str) { var s = 0; var e = -1; var r = ""; s = str.indexOf("<",e); do { r += str.substring(e + 1,s); e = str.indexOf(">",s); s = str.indexOf("<",e); } while ((s != -1) && (e != -1)) r += str.substring(e + 1,str.length); return r; } function Option(html, value, css, selected) { this.html = html; this.value = value; this.css = css; this.selected = selected; } </SCRIPT><SCRIPT language=JavaScript> topArray = new Array(); topArray[0] = new Option('<nobr><img src="images/xhwtz.gif" alt="风行软件下载!" width=88 height=31 border=0 align="absmiddle"> [美女图片]</nobr>', "http://www.52yfjc.com/list.asp?id=12"); topArray[1] = new Option('<nobr><img src="/images/logo-link.png" alt="站长建站之家!" width=88 height=31 border=0 align="absmiddle"> [远方教程]</nobr>', "http://www.52yfjc.com/"); topArray[2] = new Option('<nobr><img src="./images/tmsc.jpg" alt="网购的第一选择!" width=88 height=31 border=0 align="absmiddle"> [天猫商城]</nobr>', "http://www.tmall.com/go/chn/tbk_channel/tmall_new.php?pid=mm_31545295_3013744_10170214&eventid=101334"); topArray[3] = new Option('<nobr><img src="./images/xhlogo.gif" alt="让你捧腹大笑!" width=88 height=31 border=0 align="absmiddle"> [精品笑话]</nobr>', "http://yfxiaohua.3vzhuji.com/"); writeSelectBox(topArray, "select2", 1, "window.open(this.options[this.selectedIndex].value, '_blank')", "margin-left: 10; width: 150;"); </SCRIPT>
上一篇:超链接陷下效果
下一篇:很酷的连接提示效果
图片展示
纯CSS下拉导航菜单代码
左键菜单
热门下载
Dreamwerver 8.0
中文绿色版
AE: After Effects CS5.5
官方完整版+序列号
会声会影X5入门到精通
高清视频教程
腾讯电脑管家最新版
优化+杀毒
2345手机浏览器
免费打电话
相关评论
站长推荐
最新添加
确认链接特效
随机链接地址特效
会滚动的文字链接特效
导航特效代码:HTML5+CSS3模拟apple
用CSS制作的文字变化的导航菜单
CSS+JS仿天猫侧边可折叠展开的网页
纯CSS下拉导航菜单代码
快速制作CSS导航菜单(选项卡效果)
热门阅读
随机链接地址特效
CSS+JS仿天猫侧边可折叠展开的网页
确认链接特效
会滚动的文字链接特效
快速制作CSS导航菜单(选项卡效果)
导航特效代码:HTML5+CSS3模拟apple
纯CSS下拉导航菜单代码
用CSS制作的文字变化的导航菜单
广告招租
本站承接网站制作,维护等业务,并长期招租各类文字、图片广告。业务QQ:1348328127. Email:
admin@52yfjc.com
微信客服(微信号):
kf_52yfjc
.