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
https://forums.phpfreaks.com/topic/282346-changing-style-of-div/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.