2013-09-30 2 views
1

나는 다음과 같은 모양이있는 메뉴 만들 수있는 것 : 나는 CSS를 사용하여 배경 색상을 만들어 관리해야의 ExtJS 4.2.1 - 모든 팝업 메뉴에 상단 화살표를 추가

enter image description here

과 모서리를 둥글게 게다가.

이제 상단 화살표를 추가하려고합니다.

메뉴 (화살표)에 요소를 추가하고 원래의 열린 위치를 이동하려면 어떻게해야합니까?

답변

4

상단의 삼각형을 포함하도록 메뉴의 renderTpl을 수정할 수 있습니다. Ext.menu.Menu을 확장하는 클래스를 만드는 것이 좋습니다. this example을 참조하십시오.

Ext.define('Ext.menu.TriangleMenu', { 
    extend: 'Ext.menu.Menu', 

    initComponent: function() { 
     //get the original template 
     var originalTpl = Ext.XTemplate.getTpl(this, 'renderTpl'); 

     //add the triangle div (or img, span, etc.) 
     this.renderTpl = new Ext.XTemplate([ 
      '<div class="menu-triangle"></div>', 
      originalTpl.html,   //the html from the original tpl 
      originalTpl.initialConfig //the config options from the original tpl 
     ]); 

     this.callParent(); 
    }, 

    beforeSetPosition: function() { 
     //shift the menu down from its original position 
     var pos = this.callParent(arguments); 

     if (pos) { 
      pos.y += 5; //the offset (should be the height of your triangle) 
     } 

     return pos; 
    } 
}); 

어떻게 삼각형을 렌더링 하느냐는 전적으로 귀하에게 달려 있습니다. 이 깔끔한 작은 테두리 트릭을 사용하여 이미지를 사용하지 않고도 작업을 수행 할 수 있습니다.

.menu-triangle { 
    height: 0; 
    width: 0; 
    border-bottom: 5px solid black; 
    border-left: 5px solid transparent; 
    border-right: 5px solid transparent; 
} 
+0

내가 필요한 것은 맞지만, 여전히 약간의 문제가 있습니다. 프레임 메뉴를 사용하고 있으므로 모서리가 둥글게됩니다. originalTpl은 메뉴 본문 만 보유하고 있지만 여전히 프레임 안에 있습니다 ... 프레임 밖으로 놓을 수 있습니까? – AMember

+1

좀 더 까다 롭습니다. 당신은 삼각형에'position : absolute'을 가지고 빠져 나올 수 있고, 다른 스타일을 가지고 노는 것이 필요할 때 나타날 수 있습니다. 또한 부모 div가 오버 플로우 : visible을 가지고 있는지 확인해야하는데, 이는 부작용이있을 수 있습니다. – Towler

+0

잘 다시 그것은 매력처럼, 어떻게 기본 오프셋을 설정할 수 있습니다 그래서 그 위치가 조금 아래로 이동됩니다 열립니다? – AMember