CSSing your my.opera site - part 3
Tuesday, 4. March 2008, 11:59:07
This time again a little bit of magic. For the first time we will use "attribute selectors", to give our blog search a freakin' cool effect. 
Blog Search
Usually the search box looks a bit boring, don't you think? So, what about some "magic" effects, huh? There are two ways to get that: You are either a Grand Mage... or just a simple CSS magician.
As most of us are no Grand Mages, we do it the CSS way. So let's have a look at the code of the box:
<div id="blogsearch" class="sidebox">
<h2><label for="searchbox">Blog search</label></h2>
<form action="/Schalandra/search/?" method="get">
<div class="pad">
<input type="text" name="search" value="" id="searchbox" maxlength="128" />
<input type="submit" value="search" id="submitsearch" />
</div>
</form>
</div>Nothing to worry about. Just 2 input fields of type "text" and "submit". Now if we would just go ahead and write
#side input {
color: #ffffff;
font-size: 12px;
border: 1px solid black;
background: #181818;
width: 162px;
height: 16px;
}we would end up in 2 big boxes for the input field AND the button. Looks stupid? It is indeed! And no magic effect either. So let's start with out first magic trick, called "pseudo classes". In short these pseudo classes enable you to trigger some basic events like: the cursor is hovering over an element... or you just click an element. In our case we use the pseudo classes :hover (we hover over our input field) and :focus (our focus is on that element, means we are using it). And to take it a bit further we use a background image for the different states:
#side input {
color: #ffffff;
font-size: 12px;
border: 1px solid black;
background: #181818 url('SERVER_URL/input.png');
margin: 0px 0px 5px 5px;
width: 162px;
height: 16px;
}
#side input:hover {
background: #272727 url('SERVER_URL/input_hover.png');
}
#side input:focus {
background: #363636 url('SERVER_URL/input_focus.png');
} Yay! Now we have a really cool effect for our input box. Still, the submit button looks weird... and now it's even worse!But as we are CSS magicians we have the right spell for this: Attribute selectors. Using attribute selectors you get access to the attributes of a tag. In our case we want to style the submit button. A submit button is in fact just an input field of type "submit":
#side input[type="submit"] {
background: #272727;
width: 44px;
height: 18px;
}
#side input[type="submit"]:hover {
background: #003256;
}So let's cast our spell: Attribute selectors!! POOF!
Now we have a "magic" search field and our search button is still looking fine.
By themugs, # 6. March 2008, 22:27:23
As i can se you have an eye for Norway and also for buildings in Norway (From your photos) I hope you will visit our site / Group http://my.opera.com/HytterMedNeven/blog/
In translation, it is about sustainable cottages, but it is also about raising your fist against suppression and claiming ones right to a rouf in this world.(We combine this with the thoughts of a beloved norwegian philosopher Arne Ness, teaching that the world has enough to satisfie evry ones need, but not our greed)
There is not one solution to our enviromental challange but a thousend, and we must remember to use at least a hundred of these solutions to sustain our need for transport. Hydrogen cars and aspecially planes are one of them.
(http://my.opera.com/Geir_Holst/blog/2007/10/03/english-speaking-friends)
If you are learning "Norsk" you can get some serious challenges of typical Norwegian duble communication at this groupsite. Duble comunication in this contekst onely adds to the pressision of the comunication, not lagging it like usual.
http://my.opera.com/HytterMedNeven/blog/
Geir Holst
By Geir_Holst, # 18. March 2008, 00:05:14
Thanks for visiting.
By Schalandra, # 18. March 2008, 09:15:02
it has one minor problem though. in IE6 there are no attribute selectors, so the search button is as big as the input field. but it is still functional, so it is not necesarry to fix it.
alternatively you could add a selector to the input field also, so then IE6 would ignore all of it, and leave them as default...
just thinking...
I don't like IE, especially version 6, but it still has more of the market than firefox and opera together...
anyway good article
By Quinnuendo, # 18. March 2008, 16:28:50
By Schalandra, # 19. March 2008, 08:00:45
but those are the demands of the market
By Quinnuendo, # 19. March 2008, 16:43:22
#searchbox {width: 162px !important;
height: 16px !important;
}
#submitsearch {
width: 44px !important;
height: 20px !important;
}
Next I deleted the width/height params from the #side input definitions and I get a cleaner and more compatible code.
I will add it to my next CSSing blog post.
By Schalandra, # 19. March 2008, 17:08:46