html - Set div width and resize when it doesn't fit on the screen for absolute positioned div -


i trying set fixed width div, example 200px. want div have 200px, except when current window has not enough space it.

div {    border: 2px solid;  }  .fixedwidth {    width: 200px;    position: absolute;  }  .nowidth {    position: absolute;  }
<div class="fixedwidth">    lalala lala lalala lalala  </div>  <br />  <br />  <div class="nowidth">    alala lala alal lala  </div>

then following problem can seen when screen gets smaller:

screencap

the first div not resize , text falls outside screen.

i noticed, behaviour trying achieve max-width normal div, doesn't work absolute positioned divs.

since normal divs possible without media queries, searching solution without media queries, not sure if possible.

you should able following:

.fixedwidth {     max-width:200px;      width: 100%;  } 

this mean 200px until screen not large enough


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -