4 Replies - 687 Views - Last Post: 02 July 2013 - 03:41 PM

#1 travesty  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 67
  • Joined: 04-June 13

div under another div with no certain size

Posted 01 July 2013 - 08:38 PM

On the site that I'm building the user can upload a picture. On their page to restrict size, it has a "max-height:50%;". What I want to know is how to get their name right under theirs regardless of the picture size, because the picture probably won't take up that full 50%.
Here's the css code.
#sidebar {
position:relative;
float:right;
width:25%;
height:100%;
border-left:solid #008080;
}

#profilepic {
max-width:100%;
max-height:50%;
position:absolute;
top:2px;
left:2px;
right:2px;
}

#name {
width:100%;
height:20px;
position:absolute;
top:50%;
right:2px;
}



Here's the html code.
<div id="sidebar">
	<img src="userdata/profilepics/<?php echo $profilepic ?>" id="profilepic">
	<div id="name">
		<p class="name"><?php echo $name?></p>
	</div>
</div>


Is This A Good Question/Topic? 0
  • +

Replies To: div under another div with no certain size

#2 whizard  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 2
  • Joined: 02-July 13

Re: div under another div with no certain size

Posted 02 July 2013 - 06:28 AM

Just get rid of the positioning rules, it should immediately follow the previous element as long as there are no margins, etc

Dan
Was This Post Helpful? 1
  • +
  • -

#3 travesty  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 67
  • Joined: 04-June 13

Re: div under another div with no certain size

Posted 02 July 2013 - 01:47 PM

View Postwhizard, on 02 July 2013 - 06:28 AM, said:

Just get rid of the positioning rules, it should immediately follow the previous element as long as there are no margins, etc

Dan

Yeah, that works, but how do I get the margins then?
Was This Post Helpful? 0
  • +
  • -

#4 whizard  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 2
  • Joined: 02-July 13

Re: div under another div with no certain size

Posted 02 July 2013 - 03:34 PM

You can still have side margins, I just meant that if you have a margin-bottom on your image or a margin-top on your div, it won't follow immediately. Same goes for padding obviously.'

HTH
Dan
Was This Post Helpful? 0
  • +
  • -

#5 travesty  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 67
  • Joined: 04-June 13

Re: div under another div with no certain size

Posted 02 July 2013 - 03:41 PM

margin-top seems to work fine, but the side margins is what doesn't work. I think its because the picture is taking up 100% and there's no room for the picture to have margins. I'll get it worked out. Thanks!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1