다음과 같은 약정이 있습니다.
<style>
.title {
background: red;
}
.outer {
display: inline-block;
border: 1px solid red;
background: green;
}
.inner {
display: inline-block;
vertical-align: middle;
}
.left {
background: yellow;
}
.right {
background: cyan;
}
</style>
<div class="outer">
<div class="title">long title</div>
<div class="inner left">
<div>1</div>
<div>2</div>
<div>3</div>
</div>
<div class="inner right">
<div>1</div>
<div>2</div>
</div>
</div>
클래스 right
가 오른쪽에 정렬되도록 div를 어떻게 만들 수 있습니까?
결과는 http://www.cssdesk.com/uCmVL 에서 볼 수 있습니다 .
편집하다
두 개의 내부 div는 수직 정렬을 유지해야합니다. 즉vertical-align: whatever;
편집 2
레이아웃이 다소 복잡하고 변환을 사용하여 확대 및 축소 top: 50%; transform: translateY(-50%);
하고 내부 클래스에서 시도했지만 SVG PATH 요소를 배치하기 위해 계산을 중단합니다
flexbox로 많은 일을 할 수 있습니다. 찾고있는 레이아웃의 예는 다음과 같습니다.
.main-container {
background-color: #eee;
}
h1 {
text-align: center;
}
.columns {
display: flex;
justify-content: space-around;
align-items: center;
}
.red {
background-color: #f00;
}
.blue {
background-color: #f99;
}
<div class="main-container">
<h1>Title</h1>
<div class="columns">
<div class="column red">
<p>First Row</p>
<p>Second Row</p>
<p>Third Row</p>
</div>
<div class="column blue">
<p>Centered First Row</p>
<p>Centered Second Row</p>
</div>
</div>
</div>
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다