Resize Div To Content

I have a div that I need to resize to it's content.  Can I do this with CSS?

<?php
		error_reporting(E_ALL);
			if(isset($_POST['email'])) {
				$subject = $_POST['subject'];
				$name = $_POST['name']; // required
				$email_from = $_POST['email']; // required
				$comments = $_POST['comments']; // required
				$popOut = "";
				$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
				if(!preg_match($email_exp,$email_from)) {
					$popOut .= 'Invalid Email.<br />';  }
					$string_exp = "/^[A-Za-z .'-]+$/"; 
					if(!preg_match($string_exp,$name)) {
						$popOut .= 'Name (Letters Only).<br />';}
						if(strlen($comments) < 2) {
							$popOut .= 'Comments (> 3 Characters).<br />';  }
							if(strlen($popOut) < 1) {
								function clean_string($string) {
  								$bad = array("content-type","bcc:","to:","cc:","href");
  							return str_replace($bad,"",$string); }

							$popOut = "Request Sent.  Thank you!";

							//$email_message = "Information.\n\n";
							$email_message .= "Subject: ".clean_string($subject)."\n";
							$email_message .= "Name: ".clean_string($name)."\n";
							$email_message .= "Email: ".clean_string($email_from)."\n";
							$email_message .= "Comments: ".clean_string($comments)."\n";
							// create email headers
							$headers = 'From: '.$email_from."\r\n". 
							'Reply-To: '.$email_from."\r\n".
							'X-Mailer: PHP/' . phpversion();
							mail($email_to, $email_subject, $email_message, $headers);
							}
							?>
							<div class="popup" "visibility:hidden">
								<div class="close_popup" align="right">X</div>
									<div align="center">
										<?php echo $popOut; ?>
									</div>
								</div>
							<?php } ?>

Open in new window


The Current CSS
.popup
		{
			font:Arial, Helvetica, sans-serif;
			font-size:36px;
			font-style:normal;
			font-color;#FFF;
			line-height:50px;
			width:500px;
			height:100px;
			position:absolute;
			z-index:10;
			left:50%;
			top:50%;
			margin-left:-250px;
    		margin-top:-50px;
			border-style:solid;
 			border-color:#FFF;
			border-width:8px;
			background-color:#000000;
			opacity:0.6;
   			filter:alpha(opacity=60); /* For IE8 and earlier */
			padding:25px;
			border-radius-topleft: 20px; /* top left corner */
			border-radius-topright: 20px; /* top right corner */
			border-radius-bottomleft: 20px; /* bottom left corner */
			border-radius-bottomright: 20px; /* bottom right corner */
			border-radius: 20px 20px 20px 20px; /* shorthand topleft topright bottomright bottomleft */
			-webkit-border-top-left-radius: 20px;
			-webkit-border-top-right-radius: 20px;
			-webkit-border-bottom-left-radius: 20px;
			-webkit-border-bottom-right-radius: 20px;
			-moz-border-radius-topleft: 20px;
			-moz-border-radius-topright: 20px;
			-moz-border-radius-bottomleft: 20px;
			-moz-border-radius-bottomright: 20px;
		}

Open in new window

DS928Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GaryCommented:
If you give the div a css display inline-block (with no width/height) or inline it will only ever be as big as it's content.
What particular div or a link?
0
DS928Author Commented:
Its the Din popup at the bottom of the php code
0
GaryCommented:
Two options
Add to it's css  - display:inline - and remove the width (width would no longer work anyway).
This will only take as much room as needed.

Second option, you may like it to have a min-width so add to its css - display:inline-block - and change the width property to min-width:100px (or whatever value)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DS928Author Commented:
Perfect!  Thank you!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
CSS

From novice to tech pro — start learning today.