jquery - How to align divs of different parents? -
i'd have menu has content inside , content align other menu items.
currently have:
[- someth else] [- else something] [- else some]
and want aligned this:
[- someth else ] [- else something] [- else ]
here code of have now, how may make way want?
.menu { width: 100%; } .menu-item { display: flex; justify-content: space-between; align-items: center; } .wrapper2 { display: flex; }
<div class="menu"> <div class="menu-item"> <div class="wrapper1">someth</div> <div class="wrapper2"> <p>something else</p> <p></p> </div> </div> <div class="menu-item"> <div class="wrapper1">something</div> <div class="wrapper2"> <p>something else</p> <p>something</p> </div> </div> <div class="menu-item"> <div class="wrapper1">some</div> <div class="wrapper2"> <p>something else</p> <p>some</p> </div> </div> </div>
something this.
flex container expands items fill available free space, or shrinks them prevent overflow. flex: 1;
divide flex-box in 2 equal parts
.menu { width: 100%; } .menu-item { display: flex; justify-content: space-between; align-items: center; } .wrapper2 { display: flex; width: 50%; } .wrapper2 > p { flex: 1; } .wrapper2 > p:last-child { text-align: right; }
<div class="menu"> <div class="menu-item"> <div class="wrapper1">someth</div> <div class="wrapper2"> <p>something else</p> <p></p> </div> </div> <div class="menu-item"> <div class="wrapper1">something</div> <div class="wrapper2"> <p>something else</p> <p>something</p> </div> </div> <div class="menu-item"> <div class="wrapper1">some</div> <div class="wrapper2"> <p>something else</p> <p>some</p> </div> </div> </div>
Comments
Post a Comment