Margin-right of a flex div not respected on narrow-width viewports

I have an image and a <p> inside a <div class = "man"> with display: flex. When I try to resize the window with the dev tools, the margin-right of the div colored with orange in the image is not respected, so the image seems stuck to the right side. The image for now has no padding/margin, but there is a margin applied to the div that contains both the <p> and the <img>; why is it not respected?

Screenshot of my issue w/ dev tools open

<!DOCTYPE html>
<html lang="it">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    div.man {
      max-width: fit-content;
      margin: 20px;
      display: flex;
    }
    div.man p {
      margin: 0px;
    }
    div.man img {
      max-width: 450px;
      height: auto;
    }
    @media (max-width: 655px) {
      div.man {
        flex-direction: column;
      }
    }
  </style>
</head>

<body style="margin: 0px;">
  <div style="width: fit-content;" class="man">
    <img src="man2.jpg">
    <p>Questo concept restaurant desidera donare ai propri membri un viaggio sensoriale e spirituale tramite le linee
  del design, l'attenta scelta dei suoni, l'accurata selezione delle essenze, un'altra riflessione della
  funzionalità e della comodità
    </p>
  </div>

</body>

</html>

4

I am assuming that when you say respected, you want the image to fill the entire page, but limit it to a maximum width of 450px. If this is the case, then what I have done is added a width: 100% under div.man img.

Notice that with this, the image margins are still in place, but the width of the image is not distorting the page layout.

div.man {
  max-width: fit-content;
  margin: 20px;
  display: flex;
}

div.man p {
  margin: 0px;
}

div.man img {
  width: 100%;
  max-width: 450px;
  height: auto;
}

@media (max-width: 655px) {
  div.man {
    flex-direction: column;
  }
}
<!DOCTYPE html>
<html lang="it">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>

</head>

<body style="margin: 0px;">
  <div style="width: fit-content;" class="man">
    <img src="https://picsum.photos/600/300">
    <p>
      Questo concept restaurant desidera donare ai propri membri un viaggio sensoriale e spirituale tramite le linee del design, l'attenta scelta dei suoni, l'accurata selezione delle essenze, un'altra riflessione della funzionalità e della comodità
    </p>
  </div>

</body>

</html>

In CSS, a margin is the space around an element’s border, while padding is the space between an element’s border and the element’s content. If you are setting margin for a full width element, you may need to set its width using calc like width:calc(100% – 2x) where x stands for margin.

However, in your case, I believe using padding is a better choice. (Obviously, use it with box-sizing.)

 div.man {
      max-width: calc(100% - 40px);
      margin: 20px;
      display: flex;
    }
    div.man p {
      margin: 0px;
    }
    div.man img {
      max-width: 450px;
      height: auto;
    }
    @media (max-width: 655px) {
      div.man {
        flex-direction: column;
      }
    }
    
    body{margin:0}
  <div style="width: fit-content;" class="man">
    <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/3f/Fronalpstock_big.jpg/1200px-Fronalpstock_big.jpg">
    <p>Questo concept restaurant desidera donare ai propri membri un viaggio sensoriale e spirituale tramite le linee
  del design, l'attenta scelta dei suoni, l'accurata selezione delle essenze, un'altra riflessione della
  funzionalità e della comodità
    </p>
  </div>

In your case, the image has given a max-width property. but width not restricted to maximum of 100% of parent div.
try to change the width of the image.then the problem will solve

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật