Изображения (выравнивание по вертикали) внутри контейнера flexbox, не изменяет размер, если родитель изменяет размер (используя flexbox) - PullRequest
0 голосов
/ 27 января 2019

У меня есть контейнер, разделенный на две части.В левой части у меня есть текст, а в правой части у меня есть изображения.

Проблема в том, что изображение остается тем же, не сжимается при сгибании или с помощью медиа-запросов.

.container{   
display:flex;
   flex-direction: row;
    max-width: 40.25rem;
    margin: 0 auto;
    justify-content: flex-start;
    border: 1px solid red;
}

.place {
    display: flex;
    flex-basis: 160px;
    flex-direction: column;
    margin-left: 20px;
}    

@media only screen and (max-width: 600px) {

.place {
flex-basis: 100px;
}
}
.place > * { 
flex: 0 1 100%;
}

.place > * img { 
max-width: 100%;

}
<div class="container">
  <div class="content">
  of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
  </div>
  <div class="place">
    <a href=""> <img src="https://via.placeholder.com/150" /></a>
    <a href=""> <img src="https://via.placeholder.com/150" /></a>
    <a href=""> <img src="https://via.placeholder.com/150" /></a>
   </div>
 </div>

1 Ответ

0 голосов
/ 27 января 2019

Даже если ваш вопрос мне не понятен, похоже, вы пытаетесь установить размеры на место , но не получаете того, на что рассчитываете.

Но место установило значение по умолчанию для flex-shrink: 1, и поскольку доступное пространство уменьшается, место сокращается до доступного пространства.

Я изменил это на без сжатия , чтобы показать, что вы действительно можете установить эти размеры

.container{   
display:flex;
   flex-direction: row;
    max-width: 40.25rem;
    margin: 0 auto;
    justify-content: flex-start;
    border: 1px solid red;
}

.place {
    display: flex;
    flex-basis: 160px;
    flex-direction: column;
    margin-left: 20px;
    flex-shrink: 0; /* added */
}    

@media only screen and (max-width: 600px) {

.place {
flex-basis: 100px;
}
}
.place > * { 
flex: 0 1 100%;
}

.place > * img { 
max-width: 100%;

}
<div class="container">
  <div class="content">
  of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
  </div>
  <div class="place">
    <a href=""> <img src="https://via.placeholder.com/150" /></a>
    <a href=""> <img src="https://via.placeholder.com/150" /></a>
    <a href=""> <img src="https://via.placeholder.com/150" /></a>
   </div>
 </div>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...