0

i have one div with width: 100%; and two other divs are inside it.

+---------- div, width: 100% ----------+
|  +-- div1 50% --+  +-- div2 50% --+  |
|  | contents     |  | contents     |  |
|  |              |  |              |  |
|  +--------------+  +--------------+  |
+--------------------------------------+

now i want to know, if i remove one of those two divs inside the main div for any reason, how other inside div can be automatically 100% ? if i remove div2, how div1 can be 100% automatically?

<div style="width: 100%; " >
<div style="width: 50%; display:inline; float:right; background-color:blue; color: white" >
This is test 1
</div>
<div style="width: 50%; display:inline; float:right; background-color:red" >
This is test 2
</div>
</div>

i mean, i use php , and assume that div2 is a sidebar, i control divs in php, and for example i turn off sidebar, so div2 should not display, i know i can use conditions but i want to know is there any css code to handle this changing width automatically? normally inside the main div are two divs, but in some case it should be one div with width 100%. sorry if my english is not good :(

tnx everyone

2
  • Might be helpful to know the CSS code you have now to we can suggest the best solution. Commented Sep 1, 2011 at 11:15
  • please give some code for better understanding Commented Sep 1, 2011 at 11:18

1 Answer 1

1

I don't really understand the question, but maybe this will help:

Use this:

<div style="width: 100%; " >
<div style="width: 100%; display:inline; float:right; background-color:blue; color: white" >
This is test 1
</div>
</div>

Hope it helps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.