Cascading style sheet button image composite

I'm currently working on a Sprite project, but I've hit a roadblock and can't seem to find a solution.

Check out the code snippet here

Here is the HTML for a simple button:

<a href="#" class="ui-button sub-beta-button">
  <span class="button-content">Sign Up for Beta</span>
</a>

and its corresponding CSS styles:

.sub-beta-button {
  height: 78px;
  background: transparent url("http://i.imgur.com/PSpIGLA.png") 100% -160px no-repeat;
  padding-right: 50px;
  margin-left: 30px;
  bottom: 18px;
  z-index: 1;
  position: relative;
}

.ui-button {
  background: 0;
  border: 0;
  cursor: pointer;
  display: inline-block;
  height: auto;
  overflow: visible;
  padding: 0;
  margin: 0;
  vertical-align: middle;
  outline: 0;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
}
.sub-beta-button .button-content {
  background-image: url("http://i.imgur.com/PSpIGLA.png");
  padding-left: 50px;
  color: #fff;
  font: normal normal 18px/86px "Bliz Quadrata", Times New Roman;
  text-transform: uppercase;
  text-shadow: 0 0 4px #000, 0 0 8px #000;
  overflow: hidden;
  min-width: 110px;
  margin-left: -30px;
  height: 76px;
  z-index: 2;
}
.ui-button span {
  outline: 0;
  display: inline-block;
  background-repeat: no-repeat;
}

However, despite this setup, I'm only seeing a partial result. It seems like something is not quite right.

This is what the Sprite should look like:

View the complete code in action here

Answer №1

When you use the .ui-button class, it removes the background (background: 0).

A recommended approach is to initially get the button functioning without the ui-button class and then gradually add rules to the ui-button class one by one. This method ensures that you are utilizing minimal and precise css.

Answer №2

I have made some revisions and cleaned up the unnecessary code. To center the text, adjust the padding-left and include text align:center

padding-left

replace it with

text-align:center

http://jsfiddle.net/xy764

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is it possible to save an entire webpage that infinitely scrolls without actually manually scrolling through it?

I'm dealing with a webpage that has infinite downward scrolling. I tried automating the scrolling, but eventually the page became too large to continue scrolling. To fix this, I manually removed some DIV blocks from the source code which decreased the ...

Unique layout design that organizes calendar using nested divs with flexbox - no

I am having difficulties achieving the desired outcome with my calendar header layout implemented using flexbox for the years, months, and days. What could be the issue? Is it due to the structure of the HTML or is there something missing in the CSS? The ...

Tips on restricting camera view within the boundaries of a DIV element

I'm facing a challenge with adding a navigation menu to this AR site due to the inability to override the default full screen camera view of AR.JS. My code, similar to Jerome's original code, is structured as follows: <body style='margin ...

Using InnerHtml functionality can be successful on the initial attempt, but may encounter issues following a Post

Currently, I have a webpage that features an empty div with the id "PreAcquisitionDiv" and it is set to run on the server. When the C# code-behind runs on Page_Load, I create a table and assign it to PreAcquisitionDiv.InnerHtml. Everything appears fine o ...

What could be the reason for the malfunction of jQuery's show() function?

Using jQuery, I have implemented a functionality to hide a div using the hide() method. However, upon clicking a link, the div is supposed to show but unexpectedly disappears after appearing briefly. HTML Code Snippet <div id="introContent"> & ...

No JavaScript needed for this CSS framework

I have been tasked with creating a website without the use of JavaScript, following very specific instructions. Furthermore, it must be compatible with iPhone and other mobile devices, while still adhering to the no JavaScript rule. I am open to utilizing ...

Mysterious failure of JavaScript regular expression when encountering the term "tennis"

We developed a JavaScript script to detect duplicates or potential duplicates, but it seems to have some issues with certain words like "tennis." The script functions correctly in most cases, but fails when analyzing phrases related to the word "tennis" fo ...

The backdrop takes precedence over all other elements

The issue I'm facing is that the other Div is not appearing above the background. My goal is to have the background fill the entire screen. <title>The Ultimate Cube World Resource!</title> <link href="style.css" rel="stylesheet" type=" ...

How can we stop a form from being submitted when the input field is

Similar Question: How to prevent submitting the HTML form’s input field value if it empty <?php include '../core/init.php'; if(isset($_POST['nt']) && isset($_POST['ntb'])){ mysql_query("INSERT INTO `pos ...

Developing a PHP switch statement to alternate between different stylesheets based on specific

I've encountered a challenge while trying to create a button on my website that switches the stylesheet back and forth. The button is functioning properly, but whenever I click on it from a page other than the homepage, it keeps switching back to the ...

How to use Vue v-bind to fetch an array object from a different array iteration

I am currently working on a project where I have developed a table component that is utilized across multiple pages with different configurations. Each table has its own configuration stored in a separate file, containing keys, titles, and size classes for ...

The way in which the DOM responds to adding or deleting elements from its structure

My typical method for displaying a popup involves adding an empty div tag and a button to the webpage: <div id="popupDiv"></div> <input type="button" id="popupButton" /> I then use jQuery to handle a button click event, make an ajax cal ...

What could be causing the inner div's content to unexpectedly collapse to the left in Firefox?

Seeking assistance to resolve a display issue with the inner div on this website. The problem occurs in Firefox but not in Safari or Chrome. Here is the code on jsfiddle. As a beginner in web design, I might be overlooking something obvious and have been u ...

Issue with PrimeNG DataTable contextMenu alignment inside TabView

I encountered an issue with displaying a DataTable - contextMenu when it is placed within a TabView. The contextMenu was appearing off-center. However, the DataTable - contextMenu worked perfectly fine when it was not wrapped in a TabView. To address this ...

Ways to implement a shared ng-model across multiple elements

Brand new to AngularJS here! I have a page with multiple input boxes where users can enter tracking numbers. The number of input boxes can vary from 1 to 10. I am struggling to fetch data from all input boxes as I am only able to retrieve data from the fi ...

The table's content extends beyond the confines of the page

I have an HTML page where I am embedding an SSRS report. The report extends beyond the page as shown in the image below: This is the table that is generated: <table cellpadding="0" cellspacing="0" id="ctl00_MainContent_FiveYearReportViewer_fixedTable" ...

"Patience is a virtue: Tips for waiting until a webpage is completely loaded using

I attempted to use a special class name that only shows up after the page has completely loaded, but for some reason it appears before the content is visible on screen. try: WebDriverWait(self.browser, 20).until(EC.element_to_be_clickable((By.CLASS_NA ...

Resolving AJAX requests within a loop

I am working with a JSON file that contains widgets {"widgetname": "widget1", "widgetID": "FJRH585fKFJN234NC"} As I iterate through the JSON, I generate HTML for each widget object. $.ajax({ url: "get_json.php", data: {action: "get_widgets", ...

Using "-webkit-overflow-scrolling: touch" can cause issues with the CSS 3D perspective rendering

Looking for a solution specifically for iOS Safari Using -webkit-overflow-scrolling: touch seems to disrupt the 3d perspective on iOS devices. Check out the demonstration on CodePen. HTML <div class="pers"> <div class="scroll"> <di ...

Real-time webpage featuring dynamically updating text sourced from a file

After spending 5 hours attempting this on my own, I've decided to reach out for help. I am in need of creating a page that will automatically update itself and display the content of a file when it changes. For example, let's say we have a file ...