programming4us
programming4us
WEBSITE

Smashing Html5 : Working with Color Values - Adding Transparency to Color

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

One of the new features you can see on an HTML5-compliant browser is transparency, or variable opacity. A fully opaque object on the screen blocks whatever is beneath it, while a fully transparent object allows anything beneath it to be fully seen — like glass. The value used to describe the level of opacity is expressed in an alpha property set between 0 and 1. Using either the RGB or HSL color formatting, the alpha is the fourth parameter. (Unfortunately, there is no hexadecimal alpha parameter in CSS3.) For example, rgba(255,0,0, 0.5) generates red with 50 percent opacity. Likewise, hsla(120, 100%, 50%, 0.3) creates green with 30 percent opacity (or 70 percent transparency).

In Part IV of this book, I discuss ways to add depth to your page with the <canvas> tag so that when you stack objects on top of one another, you can better see why having some transparency in your creations is important. For now, though, you need something that you can place beneath text blocks that can be viewed through a transparent text block. The easiest method is to place a background object using the background-image property. The following code snippet shows how:

body { background-image:url(imageFile.png); }

You can use any .jpg, .gif, or .png file for a background image. For this example, three circles in the colors red, green, and blue are used as a background and on top are <h1> text with 50 percent opacity to show the effect that different colors have when viewed through a transparent object. The following code  uses both rgba() and hsla() formats.

<!DOCTYPE HTML>

<html>

<head>

<style type=”text/css”>

body {

background-image:url(rgbBalls.png);

}

.transRed {

color:rgba(255, 0, 0, .5);

}

.transGreen {

color:rgba(0, 255, 0, .5);

}

.transBlue {

color:hsla(240, 100%, 50%, .5);

}

.transBackground

{

background-color:hsla(120, 100%, 50%, .5);

}

</style>

<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8”>

<title>Transparency/Opacity</title>

</head>

<body>

<h1 class=”transRed”>Testing 123, Testing 123, Testing 123</h1>

<h1 class=”transGreen”>Testing 123, Testing 123, Testing 123</h1>

<h1 class=”transBlue”>Testing 123, Testing 123, Testing 123</h1>

<h1 class=”transBackground”>Testing 123, Testing 123, Testing 123</h1>

</body>

</html>

The results shown in Figure 4-6 are shown on an iPhone and they look no different than what you’ll see on your a computer screen.

As you can see, the transparent text and background allow the background object to show through. When a color is transparent, it picks up some of the underlying color; so, when you use it, bear in mind what the combination of the underlying and overlying colors look like together. (By the way, Figure 1 shows why you rarely want to use background images — they have a way of cluttering the screen and destroying any sensibility in the text.)

977279-fg0406.eps

Figure 1: Transparent text over solid graphics.

Other  
  •  Smashing Html5 : Working with Color Values - Understanding RGB Color (part 2) - RGB decimal integer settings
  •  Smashing Html5 : Working with Color Values - Understanding RGB Color (part 1) - Using names, RGB and HSL percentages
  •  Web Security Testing : Automating Specific Tasks with cURL - Impersonating a Specific Kind of Web Browser or Device
  •  Web Security Testing : Automating Specific Tasks with cURL - Checking for Directory Traversal with cURL
  •  Web Security Testing : Automating Specific Tasks with cURL - Following Redirects Automatically, Checking for Cross-Site Scripting with cURL
  •  Web Security Testing : Automating Specific Tasks with cURL - Fetching Many Variations on a URL
  •  Web Security Testing : Automating Specific Tasks with cURL - Fetching a Page with cURL
  •  Sharepoint 2013 : SharePoint Publishing Infrastructure (part 6) - Check In/Out, Versioning, and Content Approval
  •  Sharepoint 2013 : SharePoint Publishing Infrastructure (part 5) - Content Management - Putting It All Together
  •  Sharepoint 2013 : SharePoint Publishing Infrastructure (part 4) - Content Management - Master Pages,Page Layouts
  •  
    Top 10
    Free Mobile And Desktop Apps For Accessing Restricted Websites
    MASERATI QUATTROPORTE; DIESEL : Lure of Italian limos
    TOYOTA CAMRY 2; 2.5 : Camry now more comely
    KIA SORENTO 2.2CRDi : Fuel-sipping slugger
    How To Setup, Password Protect & Encrypt Wireless Internet Connection
    Emulate And Run iPad Apps On Windows, Mac OS X & Linux With iPadian
    Backup & Restore Game Progress From Any Game With SaveGameProgress
    Generate A Facebook Timeline Cover Using A Free App
    New App for Women ‘Remix’ Offers Fashion Advice & Style Tips
    SG50 Ferrari F12berlinetta : Prancing Horse for Lion City's 50th
    - Messages forwarded by Outlook rule go nowhere
    - Create and Deploy Windows 7 Image
    - How do I check to see if my exchange 2003 is an open relay? (not using a open relay tester tool online, but on the console)
    - Creating and using an unencrypted cookie in ASP.NET
    - Directories
    - Poor Performance on Sharepoint 2010 Server
    - SBS 2008 ~ The e-mail alias already exists...
    - Public to Private IP - DNS Changes
    - Send Email from Winform application
    - How to create a .mdb file from ms sql server database.......
    programming4us programming4us
    programming4us
     
     
    programming4us