css div模仿select下拉框跳轉效果

來源:互聯網
上載者:User
提示:您可以先修改部分代碼再運行

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.111cn.et/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title></title><style type="text/css">body{ font:12px/20px Arial, Helvetica, sans-serif ,"宋體"; color:#222}ul,dl,dt,dd,form,p,h1,h2,h3,h4,h5,h6,blockquote,pre{margin:0;padding:0}li{list-style:none}/*li,dd{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}*/img{border:0}a{color:#1E5494}a:hover{color:#2674D1}input,select{font-size:12px;font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif}.select{ position:relative; padding:5px 5px 2px 5px; width:52px; background:#F4F4F4;}.select span{ cursor:pointer}#sub_list{ position:absolute; padding:0 2px 2px 0; top:28px; left:0; width:60px; background:#F4F4F4}#sub_list ul{ display:block; padding:5px; border:1px solid #E1E1E1; background:#FFF}#sub_list ul li{ border-bottom:1px solid #E1E1E1;}#sub_list ul li a{ display:block; padding:3px 0 2px 3px; text-decoration:none}#sub_list ul li a:hover{ background:#F4F4F4}.hidden{ display:none}</style></head><body><div class="select"> <span onclick="showSelect(this,'sub_list')">請選擇▲</span> <div id="sub_list" class="hidden" onclick="this.style.display = 'none'"> <ul> <li>1</li> <li>2</li> <li>3</li> </ul> </div></div></body></html><script type="text/javascript">function showSelect(hld,id){ var ele = document.getElementById(id); ele.style.display = 'block'; var timer = null; ele.onmouseover = function(){ if(timer){ clearTimeout(timer); } ele.style.display = 'block'; } ele.onmouseout = function(){ timer = setTimeout(function(){ele.style.display = 'none'},500); } hld.onmouseover = function(){ if(timer){ clearTimeout(timer); } } hld.onmouseout = function(){ timer = setTimeout(function(){ele.style.display = 'none'},500); }}</script>
提示:您可以先修改部分代碼再運行

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.