Mimic apple.com globalsearch input field with HTML and CSS - html

OK, so if you check out http://www.marioplanet.com you can see that I am trying to mimic the design of apple.com for my menu bar, including my global search bar.
Now, I'm trying to mimic Apple's input field for the global search bar, as close as I possibly can, so I need some help here.
I would like the field to be centered in the middle, which I tried by using maring: auto auto; but that did not work..
I also would like to use the rounded corner technique, from Apple's site, but I'm not sure how to do that. Is that CSS3?
I also need to have a grayed out placeholder string reading Search but I think I may be able to use JS for that. If can use HTML or CSS, please let me know.
The little spotlight / magnifying glass image aligned to the left side of the input field is nice, but not necessary :)
OK, you can check out the site, but here is the code as well:
index.htm:
<div id="globalheader" class="apple">
<!--googleoff: all-->
<ul id="globalnav">
<li id="gn-home">Home</li>
<li id="gn-catalog">Shop!</li>
<li id="gn-about">About</li>
<li id="gn-contact">Contact</li>
<li id="gn-media">Media</li>
</ul>
<div id="globalsearch">
<form id="searchform">
<div>
<input type="text" size="30" value="" id="inputString" onkeyup="lookup(this.value);" />
</div>
<div id="suggestions"></div>
</form>
</div>
<!--googleon: all-->
</div>
default.css:
body {
background-color: #666666;
font-family:Verdana, Arial, Helvetica, sans-serif;
}
#header {
background-color: #DDDDDD;
width: 1130px;
margin: 0px auto;
}
#content {
width: 1130px;
margin: 0px auto;
}
#leftcol {
background-color:#EBEBEB;
width: 200px;
height: 550px;
font-size:14px;
clear: both;
float: left;
}
#detail {
background-color:#FFFFFF;
width: 730px;
height: 550px;
font-size:12px;
float: left;
}
#rightcol {
background-color:#EBEBEB;
width: 200px;
height: 550px;
font-size:14px;
float: left;
}
#footer {
background-color:#DDDDDD;
width: 1130px;
height:90px;
font-size:12px;
text-align:center;
clear: both;
margin: 0px auto;
}
h1 {
color: #FF0000;
}
h2 {
color:#FF0000;
}
a:link {
color:#FF0000;
}
a:visited {
color:#FF0000;
}
a:hover {
color:#00FF00;
}
a:active {
color:#FF0000;
}
img {
border:none;
}
#eznetseal {
text-align:center;
}
a.trayIcon {
position: relative;
top: 20px;
}
a.trayIcon:hover {
top: 7px;
}
#twittericon {
left: 0px;
}
#facebookicon {
left: 22.5px;;
}
#youtubeicon {
left: 45px;;
}
#tray {
position:relative;
}
#container {
position:relative;
margin-top: -40px;
}
#nav li
{
display: inline;
}
#features
{
vertical-align: top;
}
globalsearch.css:
/* BASIC RESET */
body, div, img, p { padding:0; margin:0; }
a img { border:0 }
/* HTML ELEMENTS */
body { font-family:"Lucida Grande","Lucida Sans Unicode",Arial,Verdana,sans-serif; }
/* COMMON CLASSES */
.break { clear:both; }
/* SEARCH FORM */
#searchform { margin:auto auto; font-size:18px; }
#searchform div { color:#eeeeee; }
#searchform div input { font-size:18px; width:120px; }
#suggestions{ position: relative; left:235px; width:320px; display:none; }
/* SEARCHRESULTS */
#searchresults { border-width:1px; border-color:#919191; border-style:solid; width:320px; background-color:#a0a0a0; font-size:10px; line-height:14px; }
#searchresults a { display:block; background-color:#e4e4e4; clear:left; height:56px; text-decoration:none; }
#searchresults a:hover { background-color:#b7b7b7; color:#ffffff; }
#searchresults a img { float:left; padding:5px 10px; }
#searchresults a span.searchheading { display:block; font-weight:bold; padding-top:5px; color:#191919; }
#searchresults a:hover span.searchheading { color:#ffffff; }
#searchresults a span { color:#555555; }
#searchresults a:hover span { color:#f1f1f1; }
#searchresults span.category { font-size:11px; margin:5px; display:block; color:#ffffff; }
#searchresults span.seperator { float:right; padding-right:15px; margin-right:5px;
background-image:url(../images/shortcuts_arrow.gif); background-repeat:no-repeat; background-position:right; }
#searchresults span.seperator a { background-color:transparent; display:block; margin:5px; height:auto; color:#ffffff; }
Thanks!

On the div containing the textbox try text-align: center; border-width: 0px; margin-top: 6px; to do the watermark try a jquery watermark plugin
For the rounded corners apple are inserting images into spans either end. I have seen the magnifying glass done this way or by setting the image as a background-image and adding padding to avoid overwriting it.
If I were you id download firebug for firefox so you can explore the markup and css yourself, it's quite easy.
Hope this helps.

I used Firebug and Web Developer extension to find following...
Apple definately use javascript ( and of course css) to make that search box look preety.
if you turn of javascript using noscript you will see a normal square text box.
you can check following javascript and css files to figure out whats going on.
http://images.apple.com/global/scripts/search_decorator.js
http://images.apple.com/global/nav/styles/nav.css
in css files take a look at following rule set
#globalsearch .search-wrapper .left
and
#globalsearch .search-wrapper .right
following are the images used to create the search box
http://images.apple.com/global/nav/images/searchfield_leftcap.png
http://images.apple.com/global/nav/images/searchfield_rightcap.png
I found following interesting things.
They have dedicated script file just to make that search box look pretty
They do not use image sprites.
I tried to smush one of the above images and was able to smush it by 15% ( it might look trivial but when you are looking at website visited by millions this can become a big number )

Related

Why does my image have a gap above and below it?

I don't understand why the background image of my h1 has a gap at its top and bottom. I've searched around and can't someone else with a similar issue. I've tried a bunch of different properties, but it doesn't change. I have a feeling it has something to do with it being inside an h1, but that's all I got. Any help is appreciated;I'm a beginner.
Here's my code
<h1>K&C Transmission</h1>
<div class="topnav" id="myTopnav">
Home
Contact
Services
☰
</div>
.topnav {
background-color: darkblue;
overflow:hidden;
border:6px solid black;
margin-top:0px;
}
.topnav a {
float:left;
color:yellow;
text-align:center;
padding: 14px 20px;
text-decoration:none;
font-size:17px;
}
h1 {
text-align:inherit;
background-image: url("https://s9.postimg.org/tdjelhj1r/IMG_0090.jpg");
height:280px;
width:100%;
margin:0;
background-position:center;
background-size:cover;
background-repeat:no-repeat;
font-size:50px;
position:relative;
top:0px;
margin-bottom:0px;
vertical-align: top;
}
And here's the jsfiddle:
enter link description here
--Again, the problem does not exist on jsfiddle. I don't know why it does on Atom.
Try this.
* {
box-sizing: border-box;
}
h1 {
margin : 0;
padding: 0;
}
We would need the css applied to your site to get the exact answer, but have you set the following options in your css
body{
margin: 0;
padding: 0;
}
h1{
margin: 0;
padding: 0;
}
Yes, it should just be an image in the tag. The image will display at the top of the page.
Also, no point in displaying H1/Title again over the image, since the picture is descriptive enough.
Definitely give yourself a credit for using a good quality image, since you're a beginner.
<h1>K&C Transmission</h1>
<div class="topnav" id="myTopnav">
Home
Contact
Services
☰
</div>
<style>
.topnav {
background-color: darkblue;
overflow:hidden;
border:6px solid black;
margin-top:0px;
}
.topnav a {
float:left;
color:yellow;
text-align:center;
padding: 14px 20px;
text-decoration:none;
font-size:17px;
}
h1 {
text-align:inherit;
background-image: url("/Volumes/BEAR/KandC Transmission/Media/IMG_0090.jpg");
width:100%;
margin:0;
background-position:center;
background-size:cover;
background-repeat:no-repeat;
font-size:50px;
position:relative;
top:0px;
margin-bottom:0px;
vertical-align: top;
}
</style>
Try this code,it will work.I removed height from h1 tag.

How to crop not stretch an image in a slider? I've tried 'background:cover'

I've began editing a pre-made Blogger/Blogspot template (as an amateur!!), and have come across photos in posts on a featured slider that stretch to fit the slider and look terrible. Here is the original template website where I downloaded the file: Sora Templates - 'Blogging', and it looks amazing on the example. Except my photos are not set sizes, and it would take me a very long time to crop them all to the same size.
Here is where I believe the right code is located (without images as the images are found in my posts), but I cannot seem to get Background-size: cover; to work, nor 'clip'. Is there a way to automatically have them cropped?
.related-posts{
margin:0 0% 0 0%;
background:#fff;
}
#related-posts{
border-top:1px solid #CCC;
position:relative;
padding-top:.51em;
}
.related-posts img{
border:1px solid #DEDEDE;
}
h2.relatedpost{
position:absolute;
top:-15px;
padding:0 5px 0 0;
text-indent:15px;
background:#FFF;
margin-bottom:0
}
.related-content{
float:left;
}
.related-content{}
.relatedtitle{
color:#414141;
font-variant:small-caps;
font-weight:bold;
font-size:17px!important;
}
.slider{
height: 382px!important;
padding: 10px 10px 10px 10px;
border: 1px solid #6d6e71;
}
.large-category-header {
margin-left: -30px;
margin-top: 38px;
position: absolute;
width: 100%;
z-index: 99999;
}
ul.bjqs{
position:relative;
list-style:none;
padding:0;
margin:0 0px 0;
overflow:hidden;
height:385.333333px!important;
width:100%!important;
display:block!important;
}
li.bjqs-slide{
position:absolute;
display:none;
list-style:none;
height:99%!important;
width:99.5%!important;
}
ul.bjqs-controls{
list-style:none;
margin:0;
padding:0;
z-index:9999;
}
li.slider-content img{
width:100%;
}
ul.bjqs-controls.v-centered li.bjqs-prev a,ul.bjqs-controls.v-centered li.bjqs-next a{
display:none;
}
ol.bjqs-markers{
list-style:none;
padding:0;
margin:0;
width:100%;
}
ol.bjqs-markers.h-centered{
margin-top: -34px;
position: relative;
height: 15px;
padding: 7px 4px 7px 4px;
text-align: center;
width: 98%;
background: cover;
overflow: hidden;
left: 0px !important;
}
ol.bjqs-markers li{
display:inline;
}
ol.bjqs-markers li a{
display:inline-block;
}
ul.bjqs-controls.v-centered li a{
display:none;
}
ul.bjqs-controls.v-centered li a:hover{
background:#000;
color:#fff;
}
.featured-title{
position: absolute;
bottom: 35px;
width: 93.5%;
background: rgba(0, 0, 0, 0.5);
font-weight: 600;
font-size: 25px;
font-family: 'Georgia', serif;
font-weight: 300;
padding: 20px;
text-transform: capitalize;
text-align: center;
}
.featured-posts-section{
background:#f9f9f9;
border-bottom:1px solid #ddd;
padding-top:20px;
overflow:hidden;
}
.featured-title a{
color:#fff;
}
.status-msg-wrap{display:none;}
.fpimg{
width:100% !important;
height:380px;
}
ol.bjqs-markers li a{
background: #fff;
color: #fff;
margin: 5px;
height: 10px;
border-radius: 240px;
text-decoration: none;
width: 10px;
}
ol.bjqs-markers li.active-marker a,
ol.bjqs-markers li a:hover{
background:#F26F6F;
}
p.bjqs-caption{
background:rgba(255,255,255,0.5);
}
<div class='slider' id='slider'>
<div class='large-category-header'><img alt='Featured' src='http://i1329.photobucket.com/albums/w557/iSharnie/sites%20stuff%202/featured_zpsvedkkd5i.png'/></div>
<ul class='bjqs'>
<script type='text/javaScript'>
//<![CDATA[
document.write("<script src=\"/feeds/posts/default?max-results="+numposts1+"&orderby=published&alt=json-in-script&callback=showhomeposts1\"><\/script>");
//]]></script>
</ul>
</div>
I don't think the script is actually controlling the height of the slider and its images, as in your CSS being placed into your index (dynamically) somehow, shows the "fpimg" class overriding the height and width of images placed. http://pasteboard.co/1z2hCJkX.png
Technically, if you could get into that code, if its a plugin or script, and instead of using an <img> source, and in the <a> add a background image setting in that class which loads the image you want, into the itself, you can then use background-size cover.
BUT, without having first hand access to that file or theme myself, that's about as much i can do at the moment. =) I recommend reaching out for assistance and seeing if someone can alter that plugin/script to use a background img instead of placing an actual image in the slider.

Re-Center Webpage in CSS/HTML

I have custom built CSS for me but am no longer in contact with the creator. I wanted to make a div (#rightcolumn) bigger by 55px. I did this by making iframe in the div bigger and it auto expands for me. However the banner, (#topsection), became a little short - so I had to add 55px to that to make it 1255px width.
Now page is off center some. When I try to edit other float commands to fix, the div's end up all over. I've tried for a few days. If anyone could help now with re-centering this. I would really appreciate.
Test page: Serious Sports Bigger
Link to css: CSS link
New Css
body {
margin:0;
padding:0;
line-height:1.5em;
background:#C0C0C0;
}
b {
font-size:110%;
}
em {
color:red;
}
#maincontainer {
width:1200px;
margin:0 auto;
}
#topsection {
background:#191919;
height:90px;
width:1255px
}
#contentwrapper {
float:left;
width:100%;
}
#contentcolumn {
margin:0 360px 0 180px;
color:#F1F1F1;
}
#leftcolumn {
float:left;
width:180px;
margin-left:-1200px;
background:#C8FC98;
}
#rightcolumn {
float:left;
width:355px;
margin-left:-355px;
background:#E5E5E5;
}
#footer {
clear:left;
width:100%;
background:#191919;
color:#FFF;
text-align:center;
padding:4px 0;
}
#footer a {
color:#62C301;
}
.innertube {
margin:10px;
margin-top:0;
}
.arrowgreen {
width:180px;
border-style:solid solid none solid;
border-color:#94AA74;
border-size:1px;
border-width:1px;
}
.arrowgreen ul {
list-style-type:none;
margin:0;
padding:0;
}
.arrowgreen li a {
font:bold 12px Verdana, Arial, Helvetica, sans-serif;
display:block;
background:transparent url(http://i39.tinypic.com/2r2rhnc.gif) 100% 0;
height:24px;
padding:4px 0 4px 10px;
line-height:24px;
text-decoration:none;
}
.arrowgreen li a:link, .arrowgreen li a:visited {
color:#5E7830;
}
.arrowgreen li a:hover {
color:#26370A;
background-position:100% -32px;
}
.arrowgreen li a.selected {
color:#26370A;
background-position:100% -64px;
}
You also have to change DOCTYPE to
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
#maincontainer is only 1200px;, your contents are overflowing. Solution:
#maincontainer{
width:1255px; margin:0 auto;
}
Try to add this:
body {
margin : 0 auto;
}
All the CSS is being applied twice, you will need to look into that.
Just apply the following CSS:
#maincontainer {
width: 1255px;
margin: 0 auto;
}
#contentwrapper {
float: left;
width: 1200px;
}

How to make the margins and border in a mobile website invisible html/css

*{
margin:0;
padding:0;
border:0;
font-family: Helvetica, sans-serif;
-webkit-text-size-adjust:none;
}
#menubar * { padding: 0; margin: 2; }
body { padding: 5px; font-family: Helvetica, Arial, sans-serif; width:95%; font-size:12px}
#menubar ul{
text-align:center;
}
#menubar ul li { display:inline-block; padding: 2px; position: relative; margin-left:-10px; margin-right:-20px; margin:invisible; }
#menubar ul a { display: table-cell; vertical-align: middle; width: 80px; height: 30px; text-align:center; background: #FFF; color:#000; border-style: solid; border-width:2px; border-color:#1570a6; text-decoration: none; }
#menubar li:after{
border-left:50px solid black;
border-right:60px solid black;
content:"";
position:relative;
left:-12px;
top:-18px;
z-index:-1;
display:block;
height:1px;
}
Ive got this code on the header and ive set the margin and border to 0 but im still getting a blank white space on the sides when i preview the webpage. Any suggestions?
This is the webpage that i have made and its for mobiles so if you want to get the proper user experience you could browse it with your mobile phone http://obdkey.comyr.com/Home.html
this is a temporary domain for the website
Your body still has 5px padding on it, set it to:
body {
padding:0px;
}
You have a
<br />
that's causing the white space at the bottom of the page.
Also your width is set to 95%, which is causing the space on the right.
Unsure as to whether that's intentional or not, but thought it worth a mention in case you were trying to get rid of that white space as well.
body { padding: 5px;
this may be your problem, try removing this attribute.

layout problems with CSS position

hey guys i'm trying to create a navigation system similar to the one you can find on starbucks.com. Here is the link to my sample: http://dl.dropbox.com/u/73992/js_tests/test.htm I am accomplishing the effect with navigation sample on the bottom but as you can see there are positioning problems. You can find the CSS in the source code. I figured this is the best way to test it. Thank you in advance for any help I can get it.
as per the suggestion here's the css
*
{
margin:0;
padding:0;
}
#nav
{
position:relative;
margin-top:3em;
margin-left:3em;
}
#nav ul
{
list-style-type:none;
}
#nav ul li
{
position:relative;
margin-top:10px;
}
#nav ul li ul li
{
margin-top:0px;
}
#nav ul li h1
{
font-size:15px;
font-weight:bold;
text-align:center;
color:#000000;
background-color:#F7FF88;
border:solid 5px black;
width:100px;
height:30px;
border-bottom:none;
z-index:20;
}
.content
{
position:relative;
width:300px;
background-color:#F7FF88;
border:solid 5px black;
}
.content form
{
display:block;
margin:10px 10px 10px 10px;
}
.content p
{
text-align:left;
display:block;
margin:10px 10px 10px 10px;
}
.gallery
{
margin:10px 10px 10px 10px;
background-color:#ffffff;
border:solid 1px black;
}
.gallery img
{
display:inline-block;
margin:10px 5px 10px 0px;
float:left;
}
/*
This next section is identical but represents what happens w/ the absolute positioning.
*/
.content2
{
position:absolute;
width:300px;
background-color:#F7FF88;
border:solid 5px black;
top:30px;
z-index:-5;
}
.content2 form
{
display:block;
margin:10px 10px 10px 10px;
}
.content2 p
{
text-align:left;
display:block;
margin:10px 10px 10px 10px;
}
.clear
{
clear:both;
}
if this helps this is what I am trying to accomplish
Give this a try. Change the position from absolute to relative, and remove the 30px top margin. You should be able to get the same effect as the 3 examples above yours.
.content2
{
position: relative;
width:300px;
background-color:#F7FF88;
border:solid 5px black;
z-index:-5;
}
[EDIT]
First off, remove the "border-bottom:none;" so your h1 will still have bottom borders for that tabbed effect.
#nav ul li h1
{
font-size:15px;
font-weight:bold;
text-align:center;
color:#000000;
background-color:#F7FF88;
border:solid 5px black;
width:100px;
height:30px;
z-index:20;
}
Give your h1 a class, let's say "tabbed"
<li><h1 class="tabbed">Ex. 1</h1>
And probably use some negatives for your CSS.
h1.tabbed {
position:absolute;
top:-28px;
}
Give this one a try.
Put display:inline; on li
And float:left; on ul
I think it's your big problem, if I had understand well your problem.
float : left can solve your positioning problem. You have to add just two lines in your css
#nav ul li {
float: left;
margin: 0 15px;
position: relative;
}