Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Web button placement, alignment and on hover effect

Featured Replies

Hi everyone,

 

I have created a graphic in photoshop, it is a web button i would like to place on our website that links to anothe page. Here is the image:

2ext25c.jpg

 

As you can see the image is a two tier image, the top image is how the image will look on the page in a static state, and the lower image is how the image will look on mouse over.

 

I have place this image on our page, but of course the whole image is being displayed and i would like to position the image to an ideal position.

 

I would eventually like four images like this but for the moment need to learn the skills of how to position an element and apply the hover effect.

 

Here is the HTML code i have used to place the image:

<img src="http://proaudioheadz.com/uploads/vow.png"

 

This code has been placed inside of a text/HTML widget

 

I have not done any CSS work yet and my coding skills are limited.

 

Our publishing platform is latest WP.

 

Could someone please advise me as to how to proceed.

 

Regards, Wayne.

Hi everyone,

 

I have created a graphic in photoshop, it is a web button i would like to place on our website that links to anothe page. Here is the image:

2ext25c.jpg

 

As you can see the image is a two tier image, the top image is how the image will look on the page in a static state, and the lower image is how the image will look on mouse over.

 

I have place this image on our page, but of course the whole image is being displayed and i would like to position the image to an ideal position.

 

I would eventually like four images like this but for the moment need to learn the skills of how to position an element and apply the hover effect.

 

Here is the HTML code i have used to place the image:

<img src="http://proaudioheadz.com/uploads/vow.png"

 

This code has been placed inside of a text/HTML widget

 

I have not done any CSS work yet and my coding skills are limited.

 

Our publishing platform is latest WP.

 

Could someone please advise me as to how to proceed.

 

Regards, Wayne.

 

I'm assuming this will form part of your navigation?

 

What I would do is set up an unordered list for the links (in this case - Music Production) and then set the background image of either the <li> or <a> element to the position of the image you require. You'd have to set the height of it to half of that of the image.

 

Here's a good tutorial on how to set up CSS sprites: CSS-Tricks Sprites Tutorial

 

EDIT: I've just realised that you're using WP.

 

In this case, I'd set the pages up, and then add them to a Menu(Providing you're running WP3.0+) and then style the output as I've mentioned above.

Edited by jonnyhocks

  • Author

Hi jonnyhocks,

 

I suppose it would be navigation yes, the image below should give an idea of the kind of layout i am trying to achieve.

 

rur98l.jpg

 

I know the buttons are big and garish and i will most likely redo the buttons once i have the understanding of how to do this (code wise) down, i just knocked these buttons up real quick.

 

Ill take a look at that CSS tut you posted and see if its a viable way of achieving my goal.

 

Thanks for your reply.

 

Regards, Wayne.

Just to add to jonnyhocks info above, here's some code to demonstrate the basic concept...

 

<!DOCTYPE HTML>
<html>
<head>
<title>Page Title</title>
<style type="text/css">

#musicbutton {
 display: block; 
 width: 263px;
 height: 42px; 
 background: url("uploads/vow.png"); 
 } 

#musicbutton:hover { 
 background-position: 0 -42px; 
 }

</style>
</head>
<body>

<a id="musicbutton" title="Music Production" href="music-production.htm"></a>

</body>
</html>

 

 

So the HTML code is a normal link, which is styled using CSS to control the background image position (42 is half the height of your full music production image).

 

 

 

  • Author

Woops, the code in my text widget is not what i posted, it is actually this:

 

<a href="http://www.proaudioheadz.com/wp-content/uploads/2011/07/music_production1.png"><img src="http://www.proaudioheadz.com/wp-content/uploads/2011/07/music_production1.png" alt="" title="music_production" width="263" height="84" class="aligncenter size-full wp-image-196" /></a>

 

What do i need to modify in that CSS code you kindly posted?

 

For reference, the page in question can be viewed here:

 

http://www.proaudioheadz.com

 

About half way down the page is the area where the buttons are to be placed..:)

Woops, the code in my text widget is not what i posted, it is actually this:

 

<a href="http://www.proaudioheadz.com/wp-content/uploads/2011/07/music_production1.png"><img src="http://www.proaudioheadz.com/wp-content/uploads/2011/07/music_production1.png" alt="" title="music_production" width="263" height="84" class="aligncenter size-full wp-image-196" /></a>

 

What do i need to modify in that CSS code you kindly posted?

 

For reference, the page in question can be viewed here:

 

http://www.proaudioheadz.com

 

About half way down the page is the area where the buttons are to be placed..:)

 

If you're using a text widget, you would organise your links like this:

 

<ul>

<li><a>link 1</a></li>

<li><a>link 2</a></li>

<li><a>link 3</a></li>

<li><a>link 4</a></li>

</ul>

 

Then you'd add the class/id names you'd need to style them accordingly using the code provided above.

At a glance, modify the background: url line so it reads:

 

background: url("http://www.proaudioheadz.com/wp-content/uploads/2011/07/music_production1.png"); 

...and then your code in the text widget would be just:

 

<a id="musicbutton" title="Music Production" href="music-production.htm"></a>

where music-production.htm is the page the button will link to when clicked, and musicbutton matches the ID used in the style section. That will give you a single link styled using the #musicbutton style.

 

jonnyhocks code above shows how to set up multiple links.

Edited by Cascade

  • Author

Ok, so at the moment my widget containing the HTML reads as:

 

<img src="http://proaudioheadz.com/uploads/vow.png"<ul>
<li><a><a href="http://www.proaudioheadz.com/wp-content/uploads/2011/07/music_production1.png"><img src="http://www.proaudioheadz.com/wp-content/uploads/2011/07/music_production1.png" alt="" title="music_production" width="263" height="84" class="aligncenter size-full wp-image-196"</a></li>
<li><a>link 2</a></li>
<li><a>link 3</a></li>
<li><a>link 4</a></li>
</ul>

 

and the CSS reads as:

<!DOCTYPE HTML>
<html>
<head>
<title>Page Title</title>
<style type="text/css">

#musicbutton {
 display: block; 
 width: 263px;
 height: 42px; 
 background: url("uploads/vow.png"); 
 } 

#musicbutton:hover { 
 background-position: 0 -42px; 
 }

</style>
</head>
<body>

<a id="musicbutton" title="Music Production" href="music-production.htm"></a>

</body>
</html>


 

I refreshed the page and somthing has happened, not to sure what yet..

 

So the styling, someone told me i have to create a somthing called a "class"?

Ok, you're on your way there, you have the basic structure.

 

One thing you've done wrong with the link is link to the actual image when you'll actually want to send your users to the corresponding page.

 

We can't teach you HTML and CSS over here dude, it's time to pour a cuppa and start working your way through some tutorials: W3Schools

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.