Css select appearance padding

[html] Select option padding not working in chrome

Seems to work in the current chrome 39.0.2171.71 (64-bit) and safari (I only tested this on a mac).

This seems to remove the default styling added to the select input (it also removed the drop down arrow), but allows you to then use your own styling without chrome overriding it.

I stumbled across this fix while using code from here: http://fettblog.eu/style-select-elements/

This simple hack will indent the text. Works well.

Unfortunately, webkit browsers do not support styling of option tags yet.

you may find similar question here

The most widely used cross browser solution is to use ul li

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)); 

Very, VERY simple idea, but you can modify it accordingly. This isn’t set up to look good, only to provide the idea. Hope it helps.

Not padding but if your goal is to simply make it larger, you can increase the font-size . And using it with font-size-adjust reduces the font-size back to normal on select and not on options, so it ends up making the option larger.

Not sure if it works on all browsers, or will keep working in current.

Tested on Chrome 85 & Firefox 81.

screenshot (on Firefox)

 

That’s not work on option entry because it’s a «system» generated drop-down menu but you can set the padding of a select.

Just reset the box-sizing property to content-box in your CSS.

The default value of select is border-box .

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.

option.dummy-option-for-chrome
function prepareHtml5Selects() < var is_chrome = /chrome/.test( navigator.userAgent.toLowerCase() ); if(!is_chrome) return; $('select >option').each(function() ') .insertBefore($(this)); >); $(' ') .insertAfter($('select > option:last-child')); > 

Hey guy the easy way to give option text padding from let just use like check below

hope everyone enjoys this

No Jquery — No Third party js file

function clickComboBox() else _x000D_ > _x000D_ >_x000D_ function clickOpt(value1,text1)
#customComboBox_x000D_ .opt
_x000D_ -Select Value-_x000D_
_x000D_ _x000D_
_x000D_
Test1
_x000D_
Test2
_x000D_
Test3
_x000D_

Arbitrary Indentation of any Option

If you just want to indent random, arbitrary elements, you can use   , which has the greatest cross-browser compatibility of the solutions posted here.

 

Ordered Indentation of Options

But if you have some sorted, ordered structure to your data, then it is recommended that you use the syntax.

The HTML element creates a grouping of options within a element. (Source: MDN Web Docs: )

 

Unfortunately, only one level is allowed and currently supported by browsers today. (Source: w3.org.) Personally, I would consider that part of the spec broken, but you can always extend to third, fourth, etc., levels of indentation with using the   trick up above.

You can use font-size property for option if you need.

Simply set height of the select tag

You should be targeting select for your CSS instead of select option.

View this article Styling Select Box with CSS3 for more styling options.

Источник

Стилизация select CSS для отображения в разных браузерах

В этой статье мы расскажем о том как реализуется стилизация select CSS для отображения в разных браузерах с примерами, фрагментами кода и скриншотами.

Для тестирования на Windows 8.1 использовались следующие браузеры:
• Firefox 35 ;
• Internet Explorer 11 ;
• Google Chrome 40 ;
• Windows Safari 5.1 .

Список свойств CSS , которые поддерживаются браузерами:

CSS Firefox Chrome IE11
Background ДА ДА ДА
Border ДА ДА ДА
box-shadow ДА ДА ДА
Color ДА ДА ДА
Font ДА ДА ДА
Height ДА ДА ДА
margin ДА ДА ДА
opacity ДА ДА ДА
padding ДА ДА ДА
position ДА ДА ДА
width ДА ДА ДА

Были протестированы следующие сценарии стилизации SELECT CSS :

  • Элемент SELECT без применения CSS ;
  • Элемент SELECT с применением свойств CSS padding и height или line-height ;
  • Элемент SELECT с применением свойств CSS border , background и text-color ;
  • Элемент SELECT с применением различных правил CSS .

Элемент SELECT без применения CSS

SELECT без применения CSS выглядит одинаково во всех перечисленных браузерах. За исключением того, что Internet Explorer для SELECT CSS оформления по умолчанию использует черную рамку, и стили стрелки выпадающего списка определяются по-разному.

// HTML 

Источник

CSS Add padding to the select options and change the border color

The following tutorial shows you how to use CSS to do «CSS Add padding to the select options and change the border color».

CSS Style

The CSS style to do «CSS Add padding to the select options and change the border color» is

p, select < margin:6px; font:16px Arial; > select !-- w w w . d e m o2 s .c o m --> width:262px; height:32px; padding:4px; line-height:32px; text-indent:4px; cursor:pointer; > select option < padding:20px 30px; > select option:checked < background:#C0C7CF; >

HTML Body

body> p>What did you buy at the grocery store? select> option>Milk option>Eggs option>Lettuce option>Tomatoes option>Cream of chicken soup option>Butter   

The following iframe shows the result. You can view the full source code and open it in another tab.

html> head> meta name="viewport" content="width=device-width, initial-scale=1"> style id="compiled-css" type="text/css"> p, select < margin: 6px; font: 16px Arial; > select !-- w w w . d e m o 2 s . c o m--> width: 262px; height: 32px; padding: 4px; line-height: 32px; text-indent: 4px; cursor: pointer; > select option < padding:20px 30px; > select option:checked < background: #C0C7CF; >  body> p>What did you buy at the grocery store? select> option>Milk option>Eggs option>Lettuce option>Tomatoes option>Cream of chicken soup option>Butter    

  • HTML CSS CSS Form Select Box
  • CSS add border red to checkbox when selected CSS
  • CSS Add gradient to select box w/ CSS3 in chrome
  • CSS Add padding to the select options and change the border color
  • CSS Add ‘selected’ attribute using the option value
  • CSS Add ‘selected’ attribute using the option value (Demo 2)
  • CSS Adding a Down Arrow to Select Drop Down

demo2s.com | Email: | Demo Source and Support. All rights reserved.

Источник

Читайте также:  Php line count files
Оцените статью