Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

forum input 100% width

Tags:

html

css

I have truble setting input width to 100% in my search form. I'm not sure what I'm doing wrong. Tried setting 100% everywhere posible, put it's only changes when I set size px.

http://jsfiddle.net/26Gmz/

.searchInput {
    background: none repeat scroll 0 0 #FFFFFF;
    border: 1px solid #CCCCCC;
    border-radius: 5px;
    display: table-cell;
    height: 29px;
    padding: 0 4px;
    vertical-align: middle;
    width: 100%;
}


.searchIn {
    -moz-appearance: none;
    -moz-box-sizing: border-box;
    background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
    border: 0 none;
    font-size: 15px;
    margin: 0;
    outline-width: 0;
    padding-left: 4px;
    width: 97%;
}

                <form method="post">
                        <div class="searchEn">
                                <input type=hidden name="do" value=search>
                                <input type="hidden" name="subaction" value="search" />
                                <div class="searchInput">
                                        <input class="searchIn" name="story" width="100%" type="text" />
                                </div>

                        </div>
                </form>
like image 941
kkgzjjmj Avatar asked May 26 '26 06:05

kkgzjjmj


1 Answers

I think you can get the effect you are after by changing the display rule of .searchInput to block (and then the width to 98%) like this (demo)

.searchInput {
    background: none repeat scroll 0 0 #FFFFFF;
    border: 1px solid #CCCCCC;
    border-radius: 5px;
    display: block;
    height: 29px;
    padding: 0 4px;
    vertical-align: middle;
    width: 98%;
}

Or for a more complete fix (addressing a bunch of padding and width issues) you could use this CSS (demo) (changes are commented)

.searchEn {
    background-image: linear-gradient(to bottom, #FFFFFF 0px, #DFDFDF 100%);
    border-radius: 5px;
    color: #000000;
    /*Push the right side over slightly more*/
    padding: 4px 6px 4px 4px;
}
.searchInput {
    background: none repeat scroll 0 0 #FFFFFF;
    border: 1px solid #CCCCCC;
    border-radius: 5px;
    display: block;
    height: 29px;
    /*Remove padding from this element (now in the parent element)*/
    padding: 0;
    vertical-align: middle;
    /*These can be full width if you fix the padding on the parent element*/
    width: 100%;
}
.searchIn {
    -moz-appearance: none;
    -moz-box-sizing: border-box;
    background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
    border: 0 none;
    font-size: 15px;
    margin: 0;
    outline-width: 0;
    padding-left: 4px;
    /*Center the input box better inside the container*/
    padding-top: 6px;
    /*And make the input full width*/
    width: 100%;
}
like image 157
Jason Sperske Avatar answered May 27 '26 21:05

Jason Sperske



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!