Padding option css

Your select boxes can be an incredibly functional element on your website. Here's how to style it to match the rest of your website's branding elements.

Padding option css

Default select boxes are pretty minimal. They can be one of the most functional parts of a website. Select boxes give your website visitors a better way to narrow down large quantities of information and direct them to where they need to go. 

Styling select boxes to match your brand is one of those details that creates a comprehensive look. However, select boxes are notoriously difficult to style. This tutorial gives you some easy ways to update your select box's look -- even if it's something as simple as ensuring the accent colors of the select box blend with the color scheme used throughout the brand.

Here's how to style your select boxes to fit with your website's overall theming and brand aesthetic.

HTML

Select boxes are quite hard to style, so some extra HTML is needed including wrapping everything in a "group" class so that we have elements to target with CSS:

CSS

The CSS works by using the before and after pseudo classes to create custom elements. The after class, in particular, is how we're able to styling the dropdown arrow:

Want to see how it all looks before committing to its use? Check out the JSFiddle below. Hover over the background images to see the hover effect. Be sure to scale your browser windows to various sizes to see how these sections would look on mobile display.

I cant find via Inspect how to increase the spacing between the listed option under a dropdown box filed.  Thanks!

Link to comment
Share on other sites

More sharing options...

Padding option css

AtayBalunbalunan

Posted September 27, 2020

AtayBalunbalunan

  • Padding option css

  • Caspio Guru
    • 220

    • Report
    • Share

Posted September 27, 2020

From https://stackoverflow.com/questions/12301729/styling-for-option-values-in-a-html-select-drop-down-doesnt-work-in-chrome-sa

I had to make “fat” dropdowns (selects) to match some artíst’s photoshop (I swear these people need to go back to print and stay there) with their own special arrow and everything.

So, actually, this could be a Javascript question: Dan Grossman claimed once that you could make the controls look whatever way you wanted to with Javascript. I’ve never seen this myself, but then that’s likely because of how I surf. : )

I did end up making the font-size, line-height and top-bottom padding larger, but I couldn’t do too much with the padding due to the arrows not expanding with the select.

Note: Padding creates extra space within an element. In contrast, margin creates extra space around an element.

This property is a shorthand for the following CSS properties:

  • padding-top
  • padding-right
  • padding-bottom
  • padding = 
    <'padding-top'>{1,4}

    0

/* Apply to all four sides */
padding: 1em;

/* top and bottom | left and right */
padding: 5% 10%;

/* top | left and right | bottom */
padding: 1em 2em 2em;

/* top | right | bottom | left */
padding: 5px 1em 0 2em;

/* Global values */
padding: inherit;
padding: initial;
padding: revert;
padding: revert-layer;
padding: unset;

The padding property may be specified using one, two, three, or four values. Each value is a

padding = 
<'padding-top'>{1,4}

2 or a
padding = 
<'padding-top'>{1,4}

3. Negative values are invalid.

  • When one value is specified, it applies the same padding to all four sides.
  • When two values are specified, the first padding applies to the top and bottom, the second to the left and right.
  • When three values are specified, the first padding applies to the top, the second to the right and left, the third to the bottom.
  • When four values are specified, the paddings apply to the top, right, bottom, and left in that order (clockwise).

padding = 
<'padding-top'>{1,4}

2

The size of the padding as a fixed value.

padding = 
<'padding-top'>{1,4}

3

The size of the padding as a percentage, relative to the inline size (width in a horizontal language, defined by

padding = 
<'padding-top'>{1,4}

6) of the containing block.

How to apply padding in select option CSS?

For vertical padding you can use line-height. If you don't need border, you can specify border and make it the same color as the select element background, it will give you padding appearance. box-shadow can be used to add stroke to the element if really needed. Save this answer.

What does padding 10px 20px mean?

The padding property is a shorthand property for setting 'padding-top', 'padding-right', 'padding-bottom', and 'padding-left' at the same place in the style sheet. padding: 10px 20px; top and bottom paddings are 10px, right and left paddings are 20px.

What is padding in CSS style?

CSS Demo: padding An element's padding area is the space between its content and its border. Note: Padding creates extra space within an element. In contrast, margin creates extra space around an element.

What does padding 10px 5px specifies in CSS?

Note: Padding creates extra space within an element, while margin creates extra space around an element. This property can have from one to four values. If the padding property has four values: padding:10px 5px 15px 20px; top padding is 10px.