How can i make a div tag which will Re size vertically depending upon the Text length of the this tag..??

Dani AI

Generated

The behavior you described (form showing up at the top-left and overlapping comments) is almost always a DOM/CSS flow issue rather than a PHP problem. already confirmed it was fixed, but for future readers: make sure the form is actually inserted into the same container as the comments and that neither the comments container nor the form uses absolute positioning or a fixed height that removes them from normal flow.

Common, reliable fixes:

  • Output or append the form inside the comments wrapper so it sits after the loop that prints each comment (server-side or client-side).
  • If comment boxes were floated, clear the floats before the form (or use a clearfix on the comments container) so the container height expands to contain them.
  • Avoid position: absolute on the form (or set position: relative / static) so it participates in layout.

Example CSS patterns to make content expand and keep the form below floated items:

.comments::after {
  content: "";
  display: table;
  clear: both;
}

.comment-form {
  clear: both;
  display: block;
  margin-top: 1em;
}

If you use JavaScript to append dynamically, append into the comments container, not directly to document.body:

document.querySelector('.comments').insertAdjacentHTML('beforeend', formHtml);

Quick checklist:

  • Remove any fixed height on containers (use min-height if needed).
  • Use clearfix or overflow:auto on parent wrappers to contain floats.
  • Confirm the element you append to is the comments wrapper.
  • Avoid position:absolute and explicit top/left for the form unless layering is intended.

These steps will ensure the DIV grows with its content and the comment form appears immediately after the last comment rather than floating at the page corner.

Recommended Answers

All 3 Replies

am not sure if this is your answer but, if you use px for width and percentage for height then the vertical column can be resized. i havent tried but if u dont specify a height then i think it will automatically be resized based on ur text content. try it. if it doesnt work let me know.

I am designing a commenting script.I am fetching comments from My sql database with the help of php.And after fetching all comments i am trying to append the comment form (Enter Name:,Enter Comment blah blah...)at the last of the page.

For Example:
The main page here...

++++++++++++++++++++++++++++++
Name: XXX XXX
Comment: This is Comment!!
++++++++++++++++++++++++++++++
Name: XXX XXX
Comment: This is Comment!!
++++++++++++++++++++++++++++++
Name: XXX XXX
Comment: This is Comment!!
++++++++++++++++++++++++++++++
The Comment form :
Enter Name : [_____________]
Enter Comment : [_____________]

[Submit Comment][Reset Form]
++++++++++++++++++++++++++++++


When i am adding the form to the page.Its appearing Top left corner of the page (Over lapping the fetched Comments).
My question is How to append the form Just after all comments.

thanks i have done it....!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.