/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] CSS background image button size control

I’m trying to make a button with a background image.

Trouble is, no matter what I seem to change, I cannot control the size of the button
to see the image. I appears that the image is there, just very small.

Is there something obvious (obviously since it doesn’t work) that I am missing?

[code]
<!DOC HTML>
<html>
<head>
<title> CSS image button </title>
<style type=”text/css”>

#btn1 {
height:150px; width:150px;
background-image: url(“http://upload.wikimedia.org/wikipedia/commons/9/92/Easy_button.JPG”);
background-size: 150px 150px;
background-repeat: no-repeat;
}
#btn2 {
height:100px; width:100px;
background-image: url(“http://25.media.tumblr.com/tumblr_m8s5qtbyI41qe1z7co1_400.gif”);
background-size: 100px 100px;
background-repeat: no-repeat;
}

.button {
padding: 5px;
border-top: 1px solid #777; border-left: 1px solid #777;
border-bottom: 2px solid #000; border-right: 2px solid #000;
}
.button:hover {
padding: 5px;
border-top: 2px solid #000; border-left: 2px solid #000;
border-bottom: 1px solid #777; border-right: 1px solid #777;
}
</style>
</head>
<body>

<a href=”http://www.google.com/” id=”btn1″ class=”button”> </a>
<a href=”http://www.webdeveloper.com/” id=”btn2″ class=”button”> </a>

</body>
</html>
[/code]

to post a comment
CSS

2 Comments(s)

Copy linkTweet thisAlerts:
@bionoidAug 17.2012 — Try that:

[CODE]<![COLOR="Red"]DOCTYPE[/COLOR] HTML>
<html>
<head>
<title> CSS image button </title>
<style type="text/css">

#btn1 {
height:150px; width:150px;
background-image: url("http://upload.wikimedia.org/wikipedia/commons/9/92/Easy_button.JPG");
background-size: 150px 150px;
background-repeat: no-repeat;
[COLOR="red"]display: inline-block;[/COLOR]
}
#btn2 {
height:100px; width:100px;
background-image: url("http://25.media.tumblr.com/tumblr_m8s5qtbyI41qe1z7co1_400.gif");
background-size: 100px 100px;
background-repeat: no-repeat;
[COLOR="red"]display: inline-block;[/COLOR]
}

.button {
padding: 5px;
border-top: 1px solid #777; border-left: 1px solid #777;
border-bottom: 2px solid #000; border-right: 2px solid #000;
}
.button:hover {
padding: 5px;
border-top: 2px solid #000; border-left: 2px solid #000;
border-bottom: 1px solid #777; border-right: 1px solid #777;
}
</style>
</head>
<body>

<a href="http://www.google.com/" id="btn1" class="button"> </a>
<a href="http://www.webdeveloper.com/" id="btn2" class="button"> </a>

</body>
</html>[/CODE]
Copy linkTweet thisAlerts:
@JMRKERauthorAug 17.2012 — That did it. Thanks a lot. ?

I would not have thought of a "display:inline-block" in a million years.

Something I was definitely missing.
×

Success!

Help @JMRKER 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 4.29,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

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