Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

CSS rollover buttons

Posted on 2010-09-13
2
Medium Priority
?
682 Views
Last Modified: 2013-12-25
I am trying to make a rollover menu that swaps different backgrounds and changes the color of the text.

My first approach has the button looking the way I want it to with the correct image and text centered, but does not work for the rollover.

input.button      {
      background-image:url('images/stonelblu.png');
      background-position:center;
      background-repeat:no-repeat;
      border:none;
      width:150px;
      height:42px;
      color:white;
      font-family:"Baskerville Old Face";
      font-size:20px;
      
}

input.button:hover      {
      background-image:url('images/stoneblk.png');
      color:olive;
}


My second approach has the rollover working, but I cannot get the text to align vertically.  It wants to have the text nested at the top of the button.

p.navbuttons a {
      background-image:url('images/stonelblu.png');
      background-position:center;
      border:none;
      width:150px;
      height:42px;
      color:white;
      font-family:"Baskerville Old Face";      vertical-align:middle;
      text-align:center;
      font-size:20px;
}

p.navbuttons a:hover, p.navbuttons a:active {
      background-image:url('images/stoneblk.png');
      background-position:center;
      border:none;
      width:150px;
      height:42px;
      color:olive;
      font-family:"Baskerville Old Face";
      text-align:center;
}

I have tried the "vertical-align" and a couple others but it doesn't seem to really do any good.  I have tried to give it a negative value to make it go below where it puts it, but it doesn't move.  However if I put a positive number it will raise it to the point it is off or partially off the button.
0
Comment
Question by:Pangeia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 2

Accepted Solution

by:
Adesso21 earned 2000 total points
ID: 34083285
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
      <title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
      BODY {
            background-color : #FFFFFF;
      }
      #roll-over-image {
            background-image : url('images/blackred.gif');
            background-repeat : no-repeat;
            background-position : 0px 0px;
            color : #FFFFFF;
            text-align : center;
            vertical-align : middle;
            width : 100px;
            height : 100px;
            line-height : 100px;
      }
      #roll-over-image:HOVER {
            background-position : 0px -100px;
      }
</style>
</head>
<body>
      <div id="roll-over-image">
            Button
      </div>
</body>
</html>

Important was to make the line-height the same as the box, so that the text can be aligned vertical
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question