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.

Expandable content holder

Featured Replies

Hi,

 

I've tried to ask this question before but I think I needed to make what I'm trying to do clearer.

 

Please see attached files.

 

Basically, what I'm trying to achieve is a a page which has a main content holder. Within that there are navigation menus and images.

 

But the main thing is a text box which will vary in the amount of content it holds frequently. Nothing else on the page will change.

 

So what I need to be able to do is expand the holding tag vertically to accommodate any amount of text which is entered in to the text box. The holding tag has a white background and the page bg is grey - that's why I need it to expand.

 

I've explained more in the attached files.

 

Thanks for any input.

 

Jo.

ExpandDiv.zip

its like that because every div u placed inside the content holder div has position:absolute, which takes it out of the normal flow of the website, the content holder basically doesnt know it has content so it has nothing to size it up, your gona have to do things like this without position:absolute

  • Author

So, I need to chane the side nav and text divs to position:relative ???

 

Also, do I need to set a height (100%) or just miss that property out completely.

 

Thanks

  • Author

I guess what I'm trying to figure out is a basic but essential feature of CSS so thanks for your patience.

 

I've taken out the absolute positioning and I've moved closer to what I'm trying to achieve.

 

But now I can't position the content exactly where I want it. I guess the position relative method refers to the tag previous in the html code. So the text div is positioned relative to the side panel div - is that right?

 

So how can I get to position content now if it's referring to other tags within the main holder. Life would be easier if I could position stuff relative to the main holder tag . . . . . wouldn't it!?

 

Thanks again,

 

Jo

ExpandDiv2.zip

  • Author

I forgot to refer to the amended file I uploaded where I've changed the CSS.

 

You'll see the problem I've got with position now.

  • Author

Is it acceptable to use negative values when positioning content relatively?

 

eg. top: -120px; ?????

 

PS.

Feels like I'm talking to myself now!?

By default <div> tags will expand/contract with the document flow and contents.

 

In this sample code the <div> tag will have a 1% padding and white background and will expand with the content

 

<div class="mybox">
Your content
</div>

.mybox {
padding: 1%;
background: #FFFFFF;
}

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.