Bojak Posted September 21, 2013 Share Posted September 21, 2013 <!DOCTYPE HTML> <html> <head> <meta http-equiv="content-type" content="text/html" /> <meta name="author" content="" /> <script> ShowCommet{ document.getElementById("button").style.display = ""; } HideComment { document.getElementById("hidebutton").style.display = "none"; } </script> <title>Untitled 1</title> </head> <body> <div id="box1" style="background-color: silver" style="opacity: 50px";"> <button name="comment" id="button" onClick="ShowComment()"> <STRONG>Comment</STRONG> </button> <!--this adds the button--> <button name="hide" id="hidebutton" onClick="HideComment()" style="display:none"> <STRONG>Hide</STRONG> </button> </div> <br /> <textarea width="100" height="10" id="hidebox" onclick="HideComment()"></textarea> </body> </html> I cant seem to add height width, or opacity of the background to this div. what am i doing wrong? Quote Link to comment Share on other sites More sharing options...
Bojak Posted September 21, 2013 Author Share Posted September 21, 2013 im aware the javascript dont work. im not sure why it isnt working but ill figure that out. Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted September 21, 2013 Share Posted September 21, 2013 The right syntax when you're creating is: function FuncName() { } Quote Link to comment Share on other sites More sharing options...
kicken Posted September 21, 2013 Share Posted September 21, 2013 You can't have multiple style attributes. Combine all the rules into a single attribute. Or better yet, add a class then define your rules in a stylesheet. Quote Link to comment Share on other sites More sharing options...
Demannu Posted September 25, 2013 Share Posted September 25, 2013 Your issue is two fold, Kicken is right that you need to combine them into a single attribute, however you should either have an inline CSS proper or have an external CSS file. Secondly, your opacity needs to be in the proper format. Opacity's default value is '1' which is fully opaque. In order to have a transparent object, you will need to have value from 0.0 (completely hidden) to 1 (no transparency). Most people use the range .45-.6 as it's the most common effects needed. <head> <style> #box1{ background-color: silver; height: X%; opacity: .5; } </style> </head> Something like that will give you an inline CSS sheet so that you're not calling any other files but allows you to have a much cleaner layout and ultimately functional page. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.