Обтекание текста (и изображений) вокруг плавающего элемента div - PullRequest
0 голосов
/ 14 мая 2018

Я пытаюсь сконструировать блок следующим образом:

enter image description here

изображение должно автоматически изменить размер и занять всю ширину, пока не достигнет красногоБлок.

Вот мой CSS:

#container {
  background: yellow;
}

#floated {
  float: right;
  min-width: 200px;
  max-width: 50%;
  background: red;
}

#image {
  width: 100%;
  height: auto;
}

Скрипка, чтобы попробовать вживую:

http://jsfiddle.net/kYDgL/1835/

1 Ответ

0 голосов
/ 14 мая 2018

установите стиль img для деформации div и установите width

#container {
  width: 400px;
  background: yellow;
}

#floated {
  float: right;
  width: 150px;
  background: red;
}

img {
  width: 240px;
  height: auto;
}
<div id="container">
  <div id="floated">float float float float float floatfloat float floatfloat float floatfloat float floatfloat float floatfloat float floatfloat float floatfloat float floatfloat float floatfloat float floatfloat float floatfloat float floatfloat float floatfloat float
    floatfloat float floatfloat float floatfloat float floatfloat float floatfloat float floatfloat float floatfloat float floatfloat float floatfloat float floatfloat float floatfloat float floatfloat float.</div>
  Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
  survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,


<div id="iamge">
<img src="https://kbob.github.io/images/sample-1.jpg" />
</div>
<div>
   and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry.
  Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting,
  remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>

</div>

К вашему комментарию

@media screen and (min-device-width : 320px) and (max-device-width : 480px) {
            img { width: 150px; }
}

Подробнее о media-query: https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...