2009-08-19 10 views
0

드롭 다운이 나타나는 위치를 제어하는 ​​데 가장 힘든 시간을 보내고 있습니다! 나는 CSS를 통해 변경을가했지만 어떤 이유로 그들은 반영하지 않는 것 같습니다. 누군가 내가 놓친 것을 볼 수 있을까요?내 드롭 다운 div 위치 지정

아래의 링크에서 "문의하기"및 "헬프 데스크"탭 위로 마우스를 가져 가면 무슨 뜻인지 알 수 있습니다. 어떤 도움을 크게 감상 할 수

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org 
/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
<title>Untitled Document</title> 
<link href="index.css" rel="stylesheet" type="text/css" /> 
<link href="images/chromestyle.css" rel="stylesheet" type="text/css" /> 
<script language="JavaScript" type="text/javascript" src="chromejs/chrome.js"></script> 
</head> 
<div id="wrap"> 
<div id="header"></div> 
<div id="flash"> 
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash 
/swflash.cab#version=7,0,19,0" width="800" height="237" title="SAP Specialists"> 
<param name="movie" value="SAP.swf" /> 
<param name="quality" value="high" /> 
<embed src="SAP.swf" quality="high" pluginspage="http://www.macromedia.com 
/go/getflashplayer" type="application/x-shockwave-flash" width="800" height="237"> 
/embed> 
</object> 
</div> 
<div id="dropmenu"> 
<div class="chromestyle" id="chromemenu"> 
<ul> 
<li><a href="http://www.dynamicdrive.com">ABOUT US </a></li> 
<li><a href="#">THE TEAM </a></li> 
<li><a href="#">POSITIONS</a></li> 
<li><a href="#">QUICK FACTS </a></li> 
<li><a href="#">TESTIMONIALS </a></li> 
<li><a href="#">PARTNERS </a></li> 
<li><a href="#" rel="dropmenu1">CONTACT US </a></li>  
<li><a href="#">CASE STUDIES </a></li> 
<li><a href="#" rel="dropmenu2">HELP DESK</a></li> 
</ul> 
</div> 

<!--1st drop down menu -->             
<div id="dropmenu1" class="dropmenudiv"> 
<a href="http://www.dynamicdrive.com/">Locations</a> 
<a href="http://www.cssdrive.com">Register</a></div> 


<!--2nd drop down menu -->             
<div id="dropmenu2" class="dropmenudiv" style="width: 150px;"> 
<a href="http://www.cnn.com/">Collateral</a></div> 

<!--3rd drop down menu --> 
<script type="text/javascript"> 

cssdropdown.startchrome("chromemenu") 

</script> 
</div> 

<div id="main"></div> 
<div id="rr"><img src="images/RR-teaser.png" width="255" height="168" /></div> 
<div id="testimonials"><img src="images/Testimonials-bknd.png" width="258" height="168" 
/></div> 
<div id="dod"><img src="images/DoD-teaser.png" width="255" height="168" /></div> 
<div id="footer">Copyright 
2009 Kr&ouml;ntechnology.com &nbsp;I &nbsp;Contact Webmaster</div> 
</div> 
</body> 
</html> 

:

다음
.chromestyle{ 
font-weight: bold; 
} 

.chromestyle:after{ /*Add margin between menu and rest of content in Firefox*/ 
content: "."; 
display: block; 
height: 0; 
clear: both; 
visibility: hidden; 
} 

.chromestyle ul{ 
border: 1px solid #BBB; 
width: 800px; 
margin: 0; 
text-align: center; 
padding-top: 16px; 
padding-right: 0; 
padding-bottom: 0px; 
padding-left: 0; 
background-color: #000000; 
height: 32px; 
} 

.chromestyle ul li{ 
display: inline; 
font-family: Arial, Helvetica, sans-serif; 
font-size: 11px; 
font-weight: bold; 
} 

.chromestyle ul li a{ 
color: #FFFFFF; 
margin: 0; 
text-decoration: none; 
padding-right: 8px; 
padding-bottom: 4px; 
padding-left: 8px; 
padding-top: 12px; 
border-right-width: 1px; 
border-right-style: solid; 
border-right-color: #666666; 
} 

.chromestyle ul li a:hover, .chromestyle ul li a.selected{ /*script dynamically adds a 
class of "selected" to the current active menu item*/ 
} 

/* ######### Style for Drop Down Menu ######### */ 

.dropmenudiv{ 
position:absolute; 
border: 1px solid #BBB; /*THEME CHANGE HERE*/ 
border-bottom-width: 0; 
font:normal 12px Verdana; 
line-height:18px; 
z-index:100; 
background-color: white; 
width: 150px; 
visibility: hidden; 
} 


.dropmenudiv a{ 
width: auto; 
display: block; 
text-indent: 3px; 
border-bottom: 1px solid #BBB; /*THEME CHANGE HERE*/ 
padding: 2px 0; 
text-decoration: none; 
font-weight: bold; 
color: black; 
} 

* html .dropmenudiv a{ /*IE only hack*/ 
width: 100%; 
} 

.dropmenudiv a:hover{ /*THEME CHANGE HERE*/ 
background-color: #F0F0F0; 
} 

가 페이지의 HTML 코드는 다음과 같습니다

http://krontechnology.com/dev/index_new.html

은 드롭 다운의 CSS입니다 !!!!

+0

드롭 다운을 원하십니까? 나는 위치의 bcoz일지도 모른다 생각한다 : 절대! IE6에서 실행 중이며 극단적 인 드롭 다운을 볼 수 있습니다! – RubyDubee

답변

0

#wrap div의 offsetLeft는 고려하지 않습니다.

cssdropdown 파일을 변경하십시오.

cssdropdown.dropit = function(obj, e, dropmenuID){ 
    if (this.dropmenuobj!=null) //hide previous menu 
     this.hidemenu() //hide menu 
    this.clearhidemenu() 
    this.dropmenuobj=document.getElementById(dropmenuID) //reference drop down menu 
    this.asscmenuitem=obj //reference associated menu item 
    this.showmenu(this.dropmenuobj, e) 
    this.dropmenuobj.x=this.getposOffset(obj, "left") 
    this.dropmenuobj.y=this.getposOffset(obj, "top") 
     // <<<<<< BEGIN CHANGE (notice the "- document.getElementById('wrap').offsetLeft") 
    this.dropmenuobj.style.left=(this.dropmenuobj.x-this.clearbrowseredge(obj, "rightedge")-document.getElementById('wrap').offsetLeft)+"px" 
     // <<<<<< END CHANGE 
    this.dropmenuobj.style.top=this.dropmenuobj.y-this.clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+1+"px" 
    this.positionshim() //call iframe shim function 
} 
3

세 가지 당신이 잘못하고있어 :

  1. 위치를 변경하기 위해 자바 스크립트를 사용하여 상대 부모
  2. 없이 절대 위치를 사용하는 것은 그 자체
  3. 정말 잘못하지 값,하지만 당신은 잃을 드롭 다운은 메뉴의 일부가 아니기 때문에 의미를 알 수 있습니다. 부모 항목과 관련이 없습니다.

# 1의 경우 메뉴 (#dropmenu)를 position:relative으로 설정해야합니다. 그런 다음 절대적으로 배치 된 모든 하위 요소는 해당 요소의 왼쪽 상단을 기준으로 배치됩니다. 즉, top: 0; left: 500px을 드롭 다운 *에 넣을 수 있으며 항상 같은 위치에 나타납니다. (500 값은 추측 일 뿐이지 만 디자인이 고정되어 있으므로 상수 값이됩니다.)

# 2의 경우 요소를 재배치 할 때 자바 스크립트를 사용할 필요가 없음을 의미합니다. 가시성 켜기/끄기.

# 3의 경우 형제가 아닌 메뉴의 하위 항목을 드롭 다운하는 것이 좋습니다. 이것은 의미 론적이며 스크린 리더는 메뉴 항목 간의 관계를 알고 있습니다. 이에 HTML 비슷한 사용할 수 있습니다

<ul class="menu-level1"> 
    <li><a href="">About Us</a></li> 
    <li><a href="">Contact Us</a> 
    <ul class="menu-level2"> 
     <li><a href="">Locations</a></li> 
     <li><a href="">Register</a></li> 
    </ul> 
    </li> 
    <li><a href="">Case Studies</a></li> 
</ul> 

당신은 .menu-level2.menu-level1position: absoluteposition: relative을 설정합니다.