After creating a list within a centered flex div, it seems that the list is not aligning properly. I used flex on the list-div2
and the translate
rule in the parent's middle-text
div
, but it still doesn't look centered as expected.
Can anyone provide guidance on why it's not being centered correctly?
body {
margin: 0;
}
.container {
display: flex;
flex-wrap: wrap;
flex-direction: row;
height: 100vh;
background-color: white;
}
.container>div {
min-height: 100vh;
border: 1px solid black;
box-sizing: border-box;
background-color: inherit;
}
.container>div .content {
height: 100vh;
width: 100vw;
background-color: inherit;
}
.full-width {
width: 100%;
}
.half-width {
width: 50%;
}
.full-width>.content>.third-parent {
height: 100%;
display: flex;
flex-direction: row;
}
.full-width>.content>.third-parent>.third {
position: relative;
flex: 1 1 0px;
border: 1px solid black;
width: 100%;
}
.full-width>.content>.third-parent>.third>img {
position: absolute;
width: 100%;
height: auto;
left: 50%;
top: 50%;
visibility: visible;
text-align: center;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.middle-text {
position: absolute;
width: 100%;
left: 50%;
top: 50%;
visibility: visible;
text-align: center;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.full-width>.content>.third-parent>.third>.middle-text>.list-div2 {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
}
.full-width>.content>.third-parent>.third>.middle-text>.list-div2 li {
position: relative;
display: block;
border: 1px solid red;
margin-bottom: 5px;
padding: 10px;
text-align: center;
text-transform: uppercase;
visibility: visible;
list-style-type: bullet;
}
<div class="container">
<div class="full-width">
<div class="content">
<div class="third-parent">
<div class="third" id="one">
<img src="https://fakeimg.pl/350x200/?text=left">
</div>
<div class="third" id="two">
<div class="middle-text">
<h1>Headline</h1>
<div class="list-div2">
<ul class="items-list2" id="list">
<li>Entry A</li>
<li>Entry B</li>
<li>Entry C</li>
<li>Entry D</li>
</ul>
</div>
</div>
</div>
<div class="third" id="three">
<img src="https://fakeimg.pl/350x200/?text=right">
</div>
</div>
</div>
</div>
</div>