Jump to content

changing style of div


Bojak

Recommended Posts

<!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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.