无法获取对齐内容以在CSS Flexbox网格中工作

I am using CSS flexbox to make a grid of items that wrap on page resize. I want the grid to be horizontally centered, which it is thanks to justify-content: center;. The problem is that the last box is (in some cases) centered instead of being aligned to the left. How can I make it aligned to the left?

I have tried to use align-content: flex-start; on the container, but it does not seem to work and I am not sure why.

@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap');
@-ms-viewport {width: device-width;}

.flex-container {
  max-width: 100%;
  margin: 0 auto;
  background-color: whitesmoke;
}

.flex-row {
  display: flex;
  flex-wrap: wrap;
  overflow: hidden;
  justify-content: center;
  align-content: flex-start;
}

.flex-item {
  width: 300px;
  position: relative;
  box-sizing: border-box;
  border: dashed 1px navy;
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
  -webkit-hyphens: auto;
  -ms-hyphens: auto;
  hyphens: auto;
  padding: 1em;
}

.flex-item .flex-wrapper {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background-color: crimson;
}

.flex-item a.flex-permalink {
  text-decoration: none;
  color: black;
  display: block;
  background-color: lightpink;
  height: 100%;
}

.flex-item img { width: 100%;}

.flex-item h1 {
  font-family: 'Roboto', sans-serif;
  font-size: 1.5em;
  font-weight: 500;
  margin: 0;
  padding: 1em;
}
<div class="flex-container">
	<div class="flex-row">
		<!-- ------ Let the loop begin ------ -->
		<div class="flex-item">
			<div class="flex-wrapper">
				<a class="flex-permalink" href="">
					<img src="SVG_fallback_image.svg" alt="">
					<h1>Exercitation cupidatat ex non aliqua dolore veniam veniam officia ex dolore.</h1>
				</a>
			</div>
		</div>
		<div class="flex-item">
			<div class="flex-wrapper">
				<a class="flex-permalink" href="">
					<img src="SVG_fallback_image.svg" alt="">
					<h1>Sint eiusmod est laborum reprehenderit.</h1>
				</a>
			</div>
		</div>
		<div class="flex-item">
			<div class="flex-wrapper">
				<a class="flex-permalink" href="">
					<img src="SVG_fallback_image.svg" alt="">
					<h1>Adipisicing quis tempor duis irure magna quis occaecat.</h1>
				</a>
			</div>
		</div>
		<div class="flex-item">
			<div class="flex-wrapper">
				<a class="flex-permalink" href="">
					<img src="SVG_fallback_image.svg" alt="">
					<h1>Culpa dolore sint sit non voluptate nostrud nulla dolor laborum.</h1>
				</a>
			</div>
		</div>
		<div class="flex-item">
			<div class="flex-wrapper">
				<a class="flex-permalink" href="">
					<img src="SVG_fallback_image.svg" alt="">
					<h1>Tempor consectetur do elit magna sunt cillum dolor.</h1>
				</a>
			</div>
		</div>
		<div class="flex-item">
			<div class="flex-wrapper">
				<a class="flex-permalink" href="">
					<img src="SVG_fallback_image.svg" alt="">
					<h1>AEu eiusmod qui nostrud anim nulla dolore non veniam excepteur adipisicing sed.</h1>
				</a>
			</div>
		</div>
		<div class="flex-item">
			<div class="flex-wrapper">
				<a class="flex-permalink" href="">
					<img src="SVG_fallback_image.svg" alt="">
					<h1>Lorem ipsum duis non laboris</h1>
				</a>
			</div>
		</div>
		<div class="flex-item">
			<div class="flex-wrapper">
				<a class="flex-permalink" href="">
					<img src="SVG_fallback_image.svg" alt="">
					<h1>Dolor occaecat laboris enim duis eiusmod</h1>
				</a>
			</div>
		</div>
		<div class="flex-item">
			<div class="flex-wrapper">
				<a class="flex-permalink" href="">
					<img src="SVG_fallback_image.svg" alt="">
					<h1>Exercitation do enim sint pariatur consectetur</h1>
				</a>
			</div>
		</div>
		<!-- ------ Let the loop end ------ -->
	</div>
</div>
评论