2017-09-06 9 views
3

DHTMLX Combo을 매우 간단한 FlexBox 격자 안에 정렬하는 것이 어렵습니다. 그것은 그것에 할당 된 너비를 확장하는 것으로 보인다.콤보 박스를 플렉스 박스 그리드에 정렬하는 방법

피들 here.

e.e. 다음과 같은 HTML이 주어진다 :

<div class='flex-row'> 
    <label>select:</label> 
    <div id="combo_id"></div> 
</div> 

<div class='flex-row'> 
    <label>name:</label> 
    <input type='text' /> 
</div> 

& hellip; 다음 CSS :

.flex-row { 
    display: flex; 
    justify-content: flex-start; 
} 

.flex-row > label { 
    width: 20%; 
    max-width: 4em; 
} 

.flex-row > *:nth-child(2) { 
    border: 1px solid red; 
    width: 50%; 
    max-width: 12em; 
} 

& hellip; 내가 사용 콤보 만들 때 :

const combo = new dhtmlXCombo({ 
    parent: "combo_id", 
    name: "alfa2", 
    items: [], // no items, this is just a SSCCE 
    readonly: false 
}); 

을 나는 다음과 같은 상황을 얻을 : 화면이 넓어으로

enter image description here

또한, 콤보의 폭은 업데이트하지 않습니다.

제 목표는 Combo 요소의 길이를 그 아래에있는 input 요소의 길이와 동일하게 만드는 것입니다. 콤보 요소의 길이는 input 요소의 길이가 모두 이고 인 드롭 다운 목록 단추의 길이를 의미합니다.

+0

이 무엇을 실현하려할까요 얻을 것 같은 다른 값 유형에
변경 max-width? 동일한 너비를 선택하고 이름을 지정하려면? 또는 무엇을? – Taldakus

+0

@Taldakus 질문이 업데이트되었습니다. –

+1

'DHTMLX 콤보'가 자체 너비를 설정하는 것처럼 보입니다. 생성자 정의에는 픽셀 단위의 숫자를 취하는 width 매개 변수가 있습니다. 해당 객체를 검사하면 요소 수준에서 스타일을 설정한다는 것을 알 수 있습니다. 스타일은이를 무시하지 않습니다. – MikeTheReader

답변

4

문제는 max-width:12em입니다. 글꼴 크기가 고려됩니다.
두 요소 모두 font-size이 다르므로 max-width 값이 다릅니다. px 또는 동일한 font-size으로 두 요소를 확인하고는 동일한 width

 const combo = new dhtmlXCombo({ 
 
     parent: "combo_id", 
 
     name: "alfa2", 
 
     items: [], // no items, this is just a SSCCE 
 
     readonly: false 
 
    });
 .flex-row { 
 
     display: flex; 
 
     justify-content: flex-start; 
 
    } 
 
     
 
    .flex-row > label { 
 
     width: 20%; 
 
     max-width: 4em; 
 
    } 
 
     
 
    .flex-row > *:nth-child(2) { 
 
     border: 1px solid red; 
 
     width: 50%; 
 
     max-width: 12em; 
 
     font-size:12px; 
 
    }
<link href="https://cdn.dhtmlx.com/5.0/dhtmlx.css" rel="stylesheet"/> 
 
<script src="https://cdn.dhtmlx.com/5.0/dhtmlx.js"></script> 
 
<link href="https://cdn.dhtmlx.com/5.0/skins/skyblue/dhtmlx.css" rel="stylesheet"/> 
 
<div class='flex-row'> 
 
    <label>select:</label> 
 
    <div id="combo_id"></div> 
 
</div> 
 

 
<div class='flex-row'> 
 
    <label>name:</label> 
 
    <input type='text' /> 
 
</div>

+1

좋은 답변입니다. 'max-width : 12em'에서'max-width : 12rem'까지 간단한 스위치는 문제를 해결합니다. –

+0

'px' 또는 rem' 단위로 문제를 해결하지만 화면 크기를 줄이면 콤보 컨트롤이 반응하지 않습니다. 이 답변의 코드 스 니펫에서 전체 페이지로 열어 화면 너비를 축소해야합니다. JavaScript를 사용하여 구성 할 때 콤보는 구성 요소의 너비를 한 번만 설정하는 것 같습니다. –

+0

@MarcusJuniusBrutus 물론 이것은 페이지로드시 js 계산을 수행 할 때의 예외 동작입니다. –