/    Sign up×
Community /Pin to ProfileBookmark

css for image button

Do anybody know how to use css for image button
instead of using image?

to post a comment
CSS

4 Comments(s)

Copy linkTweet thisAlerts:
@otuatailJun 25.2007 — You use an image instead of a button. This is not realy a CSS issue. Why would this be a problem?
Copy linkTweet thisAlerts:
@WebJoelJun 25.2007 — The question should be '...use of CSS for image-[I]less[/I] buttons' so you won't get quick retorts that are unhelpful. :o

Yes:

[B]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"

"http://www.w3.org/TR/html4/strict.dtd">[/B]


<html><head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<meta http-equiv="Content-Style-Type" content="text/css" />

<meta http-equiv="Content-Script-Type" content="text/javascript" />

<title></title>

<style type="text/css">

[B]* {border:0; padding:0; margin:0;}[/B]/* Set everything to "zero" */

body {min-height:100%; height:101%;

font:x-small Arial, Verdana, sans-serif;

voice-family: ""}"";voice-family:inherit;

font-size:small;/*for IE 5.5 */

} html>body {font-size:small; height:auto;}/* Assist IE6 & <, 100% height */

font-size: small; voice-family: ""}"";

voice-family: inherit; font-size: medium;} /* Assist IE rendering height, keyword-font sizes, etc. */

p {font-size: 90%; line-height:1.3em; margin:12px 0 2px 0;}

h1, h2, h3, h4, h5, h6 {font-family: 'times new roman', arial, verdana, serif; background-color:none;

font-style:normal; font-variant:normal; font-weight:normal; margin:14px 0 4px 10px;}

h1{font-size: 1.93em;}

h2{font-size: 1.72em;}

h3{font-size: 1.52em;}

h4{font-size: 1.42em;}

h5{font-size: 1.32em;}

h6{font-size: 1.21em;}

</style>


[B]<style type="text/css">

ul#navigation {width:77px; height:190px; padding:5px 5px 5px 7px; margin:25px; border:6px double black;}

ul#navigation li {list-style-type:none;margin:27px 0 27px 0; }

ul#navigation li a {text-align:center; color:black; display:inline; padding:5px 10px; text-decoration:none; background-color:#ececec;

border-bottom:6px solid silver; border-left:6px solid silver; border-top:6px solid #898989; border-right:6px solid #898989; }

ul#navigation li a:hover {color:red; letter-spacing:0.09em; padding: 5px 7px; position:relative; top:1px;right:1px; border-top:6px solid #acacac; border-right:6px solid #acacac; border-bottom:7px solid #636363; border-left:6px solid #636363; }

</style>[/B]



<link rel="shortcut icon" href="favicon.ico"><!-- path to your favicon -->

</head>

<body>

[B]<ul id="navigation">

<li><a href="#">Link #1</a></li>

<li><a href="#">Link #2</a></li>

<li><a href="#">Link #3</a></li>

<li><a href="#">Link #4</a></li>

</ul>[/B]


</body>

</html>[/QUOTE]
No images used here, yet it looks like an image roll-over effect.
Copy linkTweet thisAlerts:
@cssuserauthorJun 25.2007 — thanks webjoel, i am new to css, thats why such mistakes?
Copy linkTweet thisAlerts:
@WebJoelJun 26.2007 — Not a problem.

You'll note that the "hover" state the border-colors change/swap around, giving the appearance of 'something changed', but it is [I][B]this[/B][/I] part:...ul#navigation li a:hover {color:red; letter-spacing:0.09em; padding: 5px 7px; [B]position:relative; top:1px; right:1px;[/B] border-top:6px solid #acacac; border-right:6px solid #acacac; border-bottom:7px solid #636363; border-left:6px solid #636363;... [/QUOTE] that tricks the eye into thinking it is a 'button'. By "hovering" over this, it 're-positions' itself 1-pixel down and 1-pixel to the left...

An even more effective 'non-image button' would be to move this from the [B]a:hover[/B] (when you 'hover over' the button) to a [B]a:active[/B] selector (the 'mouse-down' effect). That would really suggest a 'button' being depressed...

I suppose one could even add a sound-file to a:active to 'click' or 'squeek', and really make this a button effect... (not sure if this can be done w/out launching the default sound-player which would be waaaaay to cumbersome to deal with).
×

Success!

Help @cssuser spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...