Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-15-2012, 12:07 PM   PM User | #1
rizzledon
New Coder

 
Join Date: Mar 2012
Posts: 16
Thanks: 3
Thanked 0 Times in 0 Posts
rizzledon is an unknown quantity at this point
Hovering text of semi-transparent rectangle?

I'm trying to hover text over a semi-transparent rectangle. The only way I knew how to create the rectangle was with a div (css below). If I put the text in the #rectangle div it lowers the opacity of the text aswell. Can anyone tell me how I can hover it above the box? I can't figure it out. Thanks

Code:
#rectangle {
	width:101px;
	height:25px;
	background-color:#ffffff;
	border:none;
	opacity:0.5;
	filter:alpha(opacity=100);
	margin-right: 50px;
	margin-bottom: 30px;
	margin-top: 10px;
  }
rizzledon is offline   Reply With Quote
Old 03-15-2012, 01:52 PM   PM User | #2
webdev1958
Banned

 
Join Date: Apr 2011
Posts: 656
Thanks: 14
Thanked 69 Times in 69 Posts
webdev1958 can only hope to improve
You can take the text out of #rectangle and use css positioning to move it over #rectangle.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
        <title></title>
        <style type="text/css">
            #rectangle {
                width: 200px;
                height: 100px;
                background-color: green;
                opacity: 0.25;
                filter: alpha(opacity=25);
                margin-right: 50px;
                margin-bottom: 30px;
                margin-top: 10px;
            }
            #p1{
                position: relative;
                top: -75px;
                left: 30px;
            }
        </style>
        <script type="text/javascript"></script>
    </head>
    <body>
        <div id="rectangle"></div>
        <p id="p1">My Text</p>
    </body>
</html>

Last edited by webdev1958; 03-15-2012 at 02:32 PM..
webdev1958 is offline   Reply With Quote
Users who have thanked webdev1958 for this post:
rizzledon (03-15-2012)
Old 03-15-2012, 02:25 PM   PM User | #3
rizzledon
New Coder

 
Join Date: Mar 2012
Posts: 16
Thanks: 3
Thanked 0 Times in 0 Posts
rizzledon is an unknown quantity at this point
Thanks mate, that was really helpful
rizzledon is offline   Reply With Quote
Old 03-15-2012, 02:27 PM   PM User | #4
webdev1958
Banned

 
Join Date: Apr 2011
Posts: 656
Thanks: 14
Thanked 69 Times in 69 Posts
webdev1958 can only hope to improve
glad it's sorted
webdev1958 is offline   Reply With Quote
Reply

Bookmarks

Tags
hover, transparent

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:33 AM.


Advertisement
Log in to turn off these ads.