Doing a input type=“text” with CSS3 and fixed image on the background

前端 未结 3 1580
萌比男神i
萌比男神i 2021-01-14 13:02

I am developing my first HTML5 / CSS3 website and I want to do all I can correctly and with well methods and being usable too.

I have to reproduce the next search in

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-14 13:50

    You can use a submit button with a background-image and position it over the searchbox.

    Do not forget to add padding to the right of your input box to allow for the button without overlap. (i have also added a class to your search box so the rules do not target the same elements)

    Html

    
    

    Css

    #header-search{overflow:auto;}
    
    #header-search input.searchbox {
         -webkit-border-radius: 5px;
         -moz-border-radius: 5px;
         border-radius: 5px;
         border:1px solid #8e8e8e;
         background-color:#f5f5f5;
         height:16px;
         padding:4px;
         padding-right:28px;
         color:#4a4a4a;
         float:left;
     }
    
    #header-search input.button{
        border:0;
        padding:0;
        margin:0 0 0 -24px;
        width:24px;
        height:24px;
        background:transparent url('your-search-icon-path-here') center center  no-repeat;
        float:left;
    }
    

    the end result is

    enter image description here

    demo http://jsfiddle.net/gaby/F5Nmp/1/

提交回复
热议问题