Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unwanted top padding inside div element

Tags:

html

css

padding

I have such HTML:

<div class="select-wrapper">
    <select name="type">
        <option value="test">test</option>
    </select>
</div>

And css:

#search-box .select-wrapper {
    display: inline-block;
    padding: 6px;
    background: #eaeced;
}

#search-box select {
    font-size: 11px;
    margin: 0px;
    padding: 0px;
    padding-left: 8px;
    border: 1px solid #a6a6a6;
    -webkit-border-radius:2px;
    -moz-border-radius:2px;
    -border-radius:2px;
}

However somehow wrappers top padding is bigger then bottom one:

ss1

When I highlight wrapper in inspector, it looks like that:

ss2

As you can see, there is some space between selects top border and top of the inner content of a wrapping div.

Why is it there ? How can I force both top and bottom spacing to be equal ? I need that wrapping element for additional outer border.

CSS outline and box-shadow isn't enough, because I need to specify corner rounding. Shadows rounding is relative to border rounding and its too big for me, so I need to make this outer border with DIV-wrapper with my own, small border-radius.

like image 266
Fisher Avatar asked Feb 27 '26 08:02

Fisher


1 Answers

The height of the select is smaller than the inner height of .select-wrapper.

Add display: block and height: 100% to the select so it will take the full height and width of it's parent.

DEMO.

like image 128
LinkinTED Avatar answered Mar 01 '26 21:03

LinkinTED



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!