Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
How to replace the "Search" button by image of a magnifier and put "Search the site" inside the search box. Thanks!
Comment | File | Size | Author |
---|---|---|---|
#8 | Screenshot 2021-05-12 at 6.39.05 PM.png | 20.62 KB | BhumikaVarshney |
Comments
Comment #1
danpros CreditAttribution: danpros commentedHi,
You can try the following steps:
with this
Dan
Comment #2
11309 CreditAttribution: 11309 commentedThank you so much! I made it! I really appreciate for your prompt reply.
Comment #3
danpros CreditAttribution: danpros commentedSolved :)
Notes: If you want to replace the search submit button in a block form, use search-block-form.tpl.php instead.
Dan
Comment #4
somnathpawar CreditAttribution: somnathpawar commentedComment #5
alex_lx CreditAttribution: alex_lx commentedLo que yo hice para cambiar a imagen el submit y el textbox de la busqueda fue esto:
#header-wrapper #search-box input.form-text
{
border:0px;
width: 160px;
background:url(images/search.png) no-repeat;
}
div#search-box .form-submit
{
border:0px;
background:url(images/submit.png) no-repeat;
color:rgba(0,0,0,0);
-width:30px;
-height:30px;
margin-left:-4px;
}
simple no ?..
Comment #6
liquid-v CreditAttribution: liquid-v commentedI'm a beginner and couldn't figure out how to make it happen on drupal 7.x ...
No "search-theme-form.tpl.php" in /modules/search
Nothing happens when editing "search-block-form.tpl.php"
No submit class or id
Any help?
Thanks!!!
Comment #7
nicholassimon CreditAttribution: nicholassimon as a volunteer commentedInstructions for Drupal 8 / FontAwesome 5
Create a YOUR_THEME_NAME_HERE.THEME file and place it in your themes directory (ie. your_site_name/themes/your_theme_name)
Paste this into the file, it is PHP code to find the Search Block and change the value to the UNICODE for the FontAwesome icon. You can find other characters at this link https://fontawesome.com/cheatsheet.
Open the CSS file of your theme (ie. your_site_name/themes/your_theme_name/css/styles.css) and then paste this in which will change all input submit text to FontAwesome. Not sure if this will work if you also want to add text in the input button though for just an icon it is fine.
Make sure you import FontAwesome, add this at the top of the CSS file
@import url('https://use.fontawesome.com/releases/v5.0.9/css/all.css');
then add this in the CSS
FLUSH ALL CACHES AND IT SHOULD WORK FINE
Add Google Font Effects
If you are using Google Web Fonts as well you can add also add effects to the icon (see more here https://developers.google.com/fonts/docs/getting_started#enabling_font_e...). You need to import a Google Web Font including the effect(s) you would like to use first in the CSS so it will be
Then go back to your .THEME file and add the class for the 3D Float Effect so the code will now add a class to the input. There are different effects available. So just choose the effect you like, change the CSS for the font import and the change the value FONT-EFFECT-3D-FLOAT int the code below to font-effect-WHATEVER_EFFECT_HERE. Note effects are still in Beta and don't work in all browsers so read here before you try it https://developers.google.com/fonts/docs/getting_started#enabling_font_e...
Comment #8
BhumikaVarshney CreditAttribution: BhumikaVarshney as a volunteer and at OpenSense Labs commentedBy css you can easily do this.
You can use an image button on the button
or set submit button background to an image using css
input[type=submit] {
background:url(BACKGROUND_IMAGE_PATH_HERE);
border:0;
display:block;
height:Change_TO_backgroundimageheight;
width: Change_To_backgroundimageWidth;
}
Or you can add in .theme file just like in screenshot.