CSS - can't get element look exactly right - advice please

We have a website built 6 years ago which uses Google Custom Search to allow users to search the website content. The search button and text entry field were styled to suit the website look and are exactly what we still want.

We now have to replace the Google Custom Search with a FreeFind search. The search itself works fine but I have very little html/ css experience and I cannot get the html provided by FreeFind correctly updated to be as close as possible to the layout we currently have.

Ideal (and current) look:

Below is the current google script and css which produces that look.

Script

	<script type="text/javascript">
	google.load('search', '1', {language : 'en', style : google.loader.themes.MINIMALIST});
	google.setOnLoadCallback(function() {
		var customSearchControl = new google.search.CustomSearchControl('009044625502831953428:eos3iok5mqe');
		customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
		var options = new google.search.DrawOptions();

		<!-- put the results page URL in here -->
		options.enableSearchboxOnly("/union/files/results.html", null, true);   -->	
		<!-- end of URL details -->

		options.setAutoComplete(true);
		customSearchControl.draw('cse-search-form', options);

		var active_color = '#ffffff'; // Colour of user provided text
		var inactive_color = '#a6a6b8'; // Colour of default text
		$("input.gsc-search-button").val("site search");
		$("input.gsc-input").val("enter search term");
		$("input.gsc-input").css("color", inactive_color);
		var default_values = new Array();
		$("input.gsc-input").focus(function() {
			if (!default_values[this.id]) {
				default_values[this.id] = this.value;
			}
			if (this.value == default_values[this.id]) {
				this.value = '';
				this.style.color = active_color;
			}
			$(this).blur(function() {
				if (this.value == '') {
					this.style.color = inactive_color;
					this.value = default_values[this.id];
				}
			});
		});
	}, true);

	</script>



CSS styles on page


<style type="text/css">

		td.gsc-search-button {
			margin: 0px;
		}

		form.gsc-search-box {
			margin: 0px;
			padding: 0px;
		}

		table.gsc-search-box {
			margin: 0px;
		}

		table.gsc-search-box td.gsc-input {
			padding: 0px;
		}

		input.gsc-input {
			padding: 0px;
			border: none;
		}

		.gsc-input input.gsc-input {
			background: none repeat scroll 0% 0% #33335C !important;
			margin: 0px;
			height: 23px;
			position: relative;
			left: 78px;
			width: 167px;
			font-size: 14px;
			padding: 1px 7px;
			box-sizing: border-box;
			-moz-box-sizing: border-box;
		}

		td.gsc-clear-button {
			display: none;
		}

		input.gsc-search-button {
			height: 23px;
			position: relative;
			right: 167px;
			width: 78px;
			border-radius: 0px;
			-moz-border-radius: 0px;
			border: none;
			background-color: #4c4c70;
			margin: 0px;
			font-weight: normal;
			font-size: 12px;
			padding: 2px 0px;
			cursor: pointer;
		}

	#search-poss {
			position: absolute;
			top: 78px;
			height: 23px;
			width: 245px;
			background-color: #4e486c;
		}


</style>

New html where advice is needed

Below is my new html, effectively what FreeFind provide with a couple of tweaks. Which unsurprisingly looks like this screen grab link. If someone can suggest likely changes to this html / css it will be much appreciated.

<div id="search-poss">
<!-- start of freefind search box html -->
<table cellpadding=0 cellspacing=0 border=0 margin = 0px>
<tr>
	<td  colspan=2 style="font-family: Arial, Helvetica, sans-serif; font-size: 7.5pt;">
		<form style="margin: 0px; padding: 0px;" action="http://search.freefind.com/find.html" method="get" accept-charset="utf-8" target="_blank">
		<input type="submit" value="site search">
		<input type="hidden" name="si" value="64367592">
		<input type="hidden" name="pid" value="r">
		<input type="hidden" name="n" value="0">
		<input type="hidden" name="_charset_" value="">
		<input type="hidden" name="bcd" value="&#247;">
		<input type="text" name="query" size="20"> 
		</form>
	</td>
</tr>
</table>
<!-- end of freefind search box html -->
</div>
</html>

Hi there lizlynchpl,

and a warm welcome to these forums. :winky:

Does this help…

<!DOCTYPE HTML>
<html lang="en">
<head>

<meta charset="utf-8">
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1">

<title>untitled document</title>

<link rel="stylesheet" href="screen.css" media="screen">

<style media="screen">
body {
    background-color: #fefefe;
    font: 1em/150% arial, helvetica, sans-serif;
 }

#search-site {
    display: inline-block;
    padding: 1em;
    background-color: #110639;
    color: #fff;
    text-align: center;
 }

#search-site label {
    display: inline-block;
    margin-bottom: 1em;
    text-transform:uppercase;
 }

#search-site input {
    border: 0;
    font-size: 1em;
    color: #fff;
 }

#search-site input[type="submit"] {
      background-color: #4e4b6f;
 }

#search-site input[type="text"] {
      background-color: #38335c;
 }
</style>

</head>
<body> 

 <form id="search-site" action="http://search.freefind.com/find.html" method="get" accept-charset="utf-8">
  <label for="term">search our site</label><br>
  <input type="submit" value="site search">
  <input type="hidden" name="si" value="64367592">
  <input type="hidden" name="pid" value="r">
  <input type="hidden" name="n" value="0">
  <input type="hidden" name="_charset_" value="">
  <input type="hidden" name="bcd" value="&#247;">
  <input type="text" name="query" id="term" size="20" placeholder="enter search term"> 
 </form>

</body>
</html>

coothead

Hi, and thanks for your helpful code, which in itself is perfect as a self-contained static html page, and which has moved me in the right direction!

It leaves me with one issue, which is that I can’t get the search area positioned on my page correctly: it remains near the top rather than in the position I need.

This is what the page should look like (this is a png from the live site):

Front page to show correct Search area position

You can access the development version of this website so that you can look at the underlying html/css at:

Development website

Click on the ‘Site Search’ button on the lefthand side about a third of the way down. You will have to log in: use the credentials:

username : test
password: TEST

You will see that the search button and text input area is incorrectly appearing above where it should, instead of in the light blue box area where it clearly belongs, level with the tabs for future events etc,

If you or anyone else is able to look at the test version of the site and advise on html changes to get that positioned correctly it would be great.

Hi there lizlynchpl,

To get it into the correct position, find this code…


	<div id="search-poss">
		<div id="cse-search-form"></div>
	<!-- Comment BACK IN  the different Google Search actions depending on whether the user is logged in -->
	  		
			<div id="search-link"><a href="/union/WebObjects/union.woa/wa/checkLoginForSearch?wosid=gt55Jelqtjg9AQKM9dlOLw">site search</a></div>
		
	
	</div>

…and change it to this…

<div id="search-poss">
 <form id="search-site" action="http://search.freefind.com/find.html" method="get" accept-charset="utf-8">
  <input type="submit" value="site search">
  <input type="hidden" name="si" value="64367592">
  <input type="hidden" name="pid" value="r">
  <input type="hidden" name="n" value="0">
  <input type="hidden" name="_charset_" value="">
  <input type="hidden" name="bcd" value="&#247;">
  <input type="text" name="query" id="term" size="16" placeholder="enter search term"> 
 </form>
</div>

Then add this CSS…

#search-site {
    background-color: #110639;
    color: #fff;
    text-align: center;
 }

#search-site input {
    border: 0;
    line-height: 1.75em;
    color: #fff;
 }

#search-site input[type="submit"] {
      background-color: #4e4b6f;
 }

#search-site input[type="text"] {
      background-color: #38335c;
 }

…to the stylesheet which you consider most appropriate. :winky:

coothead

Thanks very much for the help. I will look into implementing that shortly.

Good luck with that. :biggrin:

coothead

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.