css3 - CSS media-query to squeeze image into container -


i forced work table-based layout , need make responsive. struggling images: when image-width exceeds screen-width, should shrink fit on screen. in several articels here found max-width being recommended, somehow i'm not getting work.

here's code:

.headerimg { max-width: 100%; }  @media (max-width: 600px) {              .maintabwidth {width: 100%;}         .halfwitdth   {width:  50%;}      .qwidth       {width:  25%;}  }  @media (min-width: 601px)  {              .maintabwidth {width: 594px;}          .halfwidth    {width: 236px;}       .qwidth       {width: 113px;}  }
  <body style="font-family: arial;font-size: 12pt;margin:0px;">        <table align="center" border="0" cellpadding="0" cellspacing="0"        style="border-collapse: collapse;" class="maintabwidth">          <tbody>          <tr>          <td style="padding: 10px;">      lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. @ vero eos et accusam et justo duo dolores et ea rebum. stet clita kasd gubergren, no sea takimata sanctus est lorem ipsum dolor sit amet. lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. @ vero eos et accusam et justo duo dolores et ea rebum. stet clita kasd gubergren, no sea takimata sanctus est lorem ipsum dolor sit amet.      lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. @ vero eos et accusam et justo duo dolores et ea rebum. stet clita kasd gubergren, no sea takimata sanctus est lorem ipsum dolor sit amet. lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. @ vero eos et accusam et justo duo dolores et ea rebum. stet clita kasd gubergren, no sea takimata sanctus est lorem ipsum dolor sit amet.              </td>          </tr>            <tr>              <td><img src="http://mbaas.de/wordle.png" class=              "headerimg" /></td>            </tr>          </tbody>        </table>      </body>

i have set fiddle (full-screen here).

it's better approach change order of media queries in case, plus regarding image

when image-width exceeds screen-width, should shrink fit on screen.

here need do:

.maintabwidth {    table-layout: fixed;  }  .headerimg {    max-width: 100%;  }  @media (min-width: 601px) {    .maintabwidth {      width: 594px;    }    .halfwidth {      width: 236px;    }    .qwidth {      width: 113px;    }  }  @media (max-width: 600px) {    .maintabwidth {      width: 100%;    }    .halfwitdth {      width: 50%;    }    .qwidth {      width: 25%;    }  }
<body style="font-family: arial;font-size: 12pt;margin:0px;">    <table align="center" border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse;" class="maintabwidth">      <tbody>        <tr>          <td style="padding: 10px;">            <img class="headerimg" src="http://lorempixel.com/1000/300" />          </td>        </tr>          <tr>          <td style="padding: 10px;">this text embedded in cell of table-row table styled media-query, in width >607px, table should 594px wide , on smaller screens (max-width: 600px), table should fill available space 100%.            if resize , observe, see contrary: on large screens, table takes space , on small screens takes 594px - seems wrong query selected...??? lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed            diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. @ vero eos et accusam et justo duo dolores et ea rebum. stet clita kasd gubergren, no sea takimata sanctus est lorem ipsum dolor sit amet. lorem            ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. @ vero eos et accusam et justo duo dolores et ea rebum. stet clita kasd gubergren, no sea            takimata sanctus est lorem ipsum dolor sit amet. lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. @ vero eos et accusam et justo duo            dolores et ea rebum. stet clita kasd gubergren, no sea takimata sanctus est lorem ipsum dolor sit amet. lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,            sed diam voluptua. @ vero eos et accusam et justo duo dolores et ea rebum. stet clita kasd gubergren, no sea takimata sanctus est lorem ipsum dolor sit amet.</td>        </tr>      </tbody>    </table>  </body>


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -