ghanshyam.mirani
ghanshyam.mirani

Reputation: 3101

how set width of child Element based on Parent element

I have follwoing HTML

<div style="border: 1px solid;">
  <div style="background-color: blue; width: 1200px;">
<h3>
 Ticket Details</h3>      
  </div> 
</div>

in 1360*768 resolution it displays perfact but in 1024*768 resolution that the inner Div goes out of outer Div element.

and if i apply outer div's width it also goes to out of screen in less resolution.. i want to fit width of div element size of screen

how do i set Div's width that fit with resolution

Thanks/

Upvotes: 2

Views: 402

Answers (2)

Brendan Bullen
Brendan Bullen

Reputation: 11798

Try percentage width in both. I've used 88% based on your 1200px width for resolution of 1360px. From there, I've set the inner div to 100% to take up the full inner width without going over it.

<div style="border: 1px solid;width:88%;">
  <div style="background-color: blue; width: 100%;">
    <h3>Ticket Details</h3>      
  </div> 
</div>

Upvotes: 3

Yevgeny Simkin
Yevgeny Simkin

Reputation: 28349

set the width on the outer div to the actual number, set the width of the inner div to 100% (or less)

Upvotes: 1

Related Questions