크롬에서 작동하지 않는 옵션 패딩 선택
크롬에서 작동하지 않는 옵션 패딩 선택
<style>
select option { padding:5px 0px; }
</style>
<select>
<option>1</option>
<option>2</option>
<option>3</option>
</select>
크롬의 선택 입력에 패딩을 적용하는 방법을 찾았습니다.
select{
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
padding: 5px;
}
현재 크롬 39.0.2171.71 (64 비트)과 사파리 (Mac에서만 테스트)에서 작동하는 것 같습니다.
이것은 선택 입력에 추가 된 기본 스타일링을 제거하는 것처럼 보이지만 (드롭 다운 화살표도 제거됨) 크롬을 재정의하지 않고 자신 만의 스타일을 사용할 수 있습니다.
http://fettblog.eu/style-select-elements/ 에서 코드를 사용하는 동안이 수정 사항을 우연히 발견했습니다.
이 간단한 해킹은 텍스트를 들여 씁니다. 잘 작동합니다.
select {
text-indent: 5px;
}
그것은 보인다
안타깝게도 웹킷 브라우저는 아직 옵션 태그 스타일을 지원하지 않습니다.
여기에서 비슷한 질문을 찾을 수 있습니다.
가장 널리 사용되는 크로스 브라우저 솔루션은 ul li를 사용하는 것입니다.
도움이 되었기를 바랍니다.
아주 간단한 아이디어이지만 그에 따라 수정할 수 있습니다. 이것은보기 좋게 설정되지 않고 단지 아이디어를 제공하기위한 것입니다. 도움이 되었기를 바랍니다.
CSS :
ul {
width: 50px;
height: 20px;
border: 1px solid black;
display: block;
}
li {
padding: 5px 0px;
width: 50px;
display: none;
}
HTML :
<ul id="customComboBox">
 
<li>Test</li>
<li>Test 2</li>
<li>Test 3</li>
</ul>
스크립트:
$(document).ready(function(){
$("#customComboBox").click(function(){
$("li").toggle("slow");
});
});
이는 option
"시스템"생성 드롭 다운 메뉴이기 때문에 입력시 작동하지 않지만 선택 항목을 설정할 수 있습니다 padding
.
CSS에서 box-sizing
속성을 content-box
로 재설정하면 됩니다 .
의 기본값은 select
입니다 border-box
.
select {
box-sizing: content-box;
padding: 5px 0;
}
나는 이것으로 그것을 고쳤다
select {
max-height: calc(1.2em + 24px);
height: calc(1.2em + 24px);
}
max-height: calc(your line height + (top + bottom padding));
height: calc(your line height + (top + bottom padding));
I have a little trick for your problem. But for that you must use javascript. If you detected that the browser is Chrome insert "dummy" options between every options. Give a new class for those "dummy" options and make them disabled. The height of "dummy" options you can define with font-size property.
CSS:
option.dummy-option-for-chrome {
font-size:2px;
color:transparent;
}
Script:
function prepareHtml5Selects() {
var is_chrome = /chrome/.test( navigator.userAgent.toLowerCase() );
if(!is_chrome) return;
$('select > option').each(function() {
$('<option class="dummy-option-for-chrome" disabled></option>')
.insertBefore($(this));
});
$('<option class="dummy-option-for-chrome" disabled></option>')
.insertAfter($('select > option:last-child'));
}
You can use font-size
property for option if you need.
Simply set height of the select tag
select{
height: 30px;
max-height: 30px;
}
You should be targeting select for your CSS instead of select option.
select {
padding: 10px;
margin: 0;
-webkit-border-radius:4px;
-moz-border-radius:4px;
border-radius:4px;
}
View this article Styling Select Box with CSS3 for more styling options.
참고URL : https://stackoverflow.com/questions/22681141/select-option-padding-not-working-in-chrome
'program story' 카테고리의 다른 글
여러 파일 유형을 검색하는 Unix find 명령에 해당하는 Windows (0) | 2020.10.30 |
---|---|
범용 앱에서 iPad 및 iPhone Retina 그래픽을 모두 지원하는 방법 (0) | 2020.10.29 |
푸시 알림이 testflight에서 작동하지 않는 이유는 무엇입니까? (0) | 2020.10.29 |
Excel에서 비어 있지 않은 모든 셀을 선택하기 위해 countifs를 얻는 방법은 무엇입니까? (0) | 2020.10.29 |
ASP.NET MVC의 Page.ResolveUrl에 해당하는 것은 무엇입니까? (0) | 2020.10.29 |