Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Div not resizing to accomodate text

Featured Replies

I'm trying to make a good, responsive/scaleable website but am having a problem with the basic design. I will post the code below. When resized very small, so the larger text overflows, that text goes beneath its own div and past the footer underneath, into a white space. I'll attach a screenshot to show this. I don't really understand why the div is not scaling to accomodate the text. The footer is obviously a problem in the screenshot too, but not the one I'm currently focusing on. Please let me know if this isn't explained adequetely :unsure:

Sorry I don't have this up live so you can look at it properly...

 

CSS:

 

	*{
	margin:0;padding:0;
	}
	html, body	{
		margin:0;
		height:100%;
		font-size:62.5%;
	}
	a:link, a:visited, a:active	{
		text-decoration:none;
		color:inherit;
	}
	a:hover		{
		text-decoration:none;
		color:#CDFAFF;
	}
	#wrapper	{
		height:100%;
		width:100%;
		position:relative;
	}
	#main	{
		background-color:#E6FDFF;
		background-image:url('images/dia.png');
		background-repeat:no-repeat;
		color:#B28A6C;
		height:100%;
		width:100%;
		font-family:"Lucida Bright", "DejaVu Serif", Georgia, serif;
		font-size:6em;
		margin:0;
		position:absolute;
	}
	#footer	{
		width:100%;
		text-align:center;
		margin:0;
		padding:.7%;
		min-height:10px;
		top:95%;
		word-spacing:2.5em;
		background-color:#B28A6C;
		font-family:"Lucida Bright", "DejaVu Serif", Georgia, serif;
		color:#FFE2CD;
		font-size:.5em;
		position:absolute;
	}
	.hometext	{
		font-size:2.2em;
		top:30%;
		left:30%;
		max-width:30%;
		min-width:25%;
		margin:0;
		position:absolute;
}

 

HTML:

 

<body>

	<div id="wrapper">
	
	<div id="main">
    <p class="hometext">test text<br>
    (more text)</p>
    <div id="footer">
    ♦  <a href="">about</a> ♦ 
    <a href="">portfolio</a> ♦ 
    <a href="">contact</a> ♦
    </div>
    </div>
    
    </div>
    
</body>

post-62874-0-79194700-1404496581_thumb.jpg

 

post-62874-0-53223000-1404496582_thumb.jpg

 

 

Edit - the absolute positioning seems to be causing the problem... still don't really understand why, though - is there a way to get around this?

Edited by rhubarblover

Edit - the absolute positioning seems to be causing the problem... still don't really understand why, though - is there a way to get around this?

 

With absolute positioning, you need to declare the container's height, which is a pain; all other position states can manage auto-height's. If you intend to continue using absolute positioning (there could be an alternative solution), then you'll have to declare the height; properties like overflow: hidden won't take effect.

 

One work-around is to write a piece of jQuery that gets the container's height on page-load with the content in and then apply absolute position via jQuery, so the container's height (automatically adjusted by the content) will be calculated first, then applied, then made to be position absolute.

Why are you using position absolute here, looking at your screenshots if the brown coloured bar is last in your source then it will be at the bottom of the page from the default document flow. If you need it to be pushed down then just give a sibling node (one that contains your page content) a min height.

Also dont use ID's in your css. ID's should be used for js targeting.

Edited by rbrtsmith

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.