タイトルが示すように、CSS の三角形/矢印を div の右側に垂直方向に中央揃えしようとしています。もちろん、純粋な CSS ソリューションを使用してこれを実行しようとしています。
写真を含めたかったのですが、担当者が少ないため、できません。
注: 私の現在のコードは正しく機能しておらず、クロスブラウザーとの互換性もありません (つまり、Chrome では矢印が右上に表示されますが、Firefox では境界の外側に押しつぶされます)。
私のコード
HTML :
<div class="main-panel">
<nav class="left-panel">
<ul class="page-nav">
<li class="page-tab active"><a class="page-nav-link">Dashboard</a></li>
<li class="page-tab"><a class="page-nav-link">Page 1</a></li>
<li class="page-tab"><a class="page-nav-link">Page 2</a></li>
<li class="page-tab"><a class="page-nav-link">Page 3</a></li>
<li class="page-tab"><a class="page-nav-link">Somewhat long</a></li>
<li class="page-tab"><a class="page-nav-link">Somewhat long abc</a></li>
<li class="page-tab"><a class="page-nav-link">Somewhat long abcdef</a></li>
<li class="page-tab"><a class="page-nav-link">Somewhat long abcdefghi</a></li>
<li class="page-tab"><a class="page-nav-link">Somewhat long abcdefghijkl</a></li>
<li class="page-tab"><a class="page-nav-link">Very long element abcdefghijklmno</a></li>
</ul>
</nav>
<div class="right-panel">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam pellentesque nisl vitae nulla dignissim, at rutrum nunc interdum. Mauris et facilisis orci. Phasellus ac libero id nisl malesuada ultricies. Aenean vitae cursus velit. Nulla sit amet leo eu enim scelerisque volutpat. Vivamus gravida felis et pulvinar mollis. Sed bibendum consectetur nisi, sit amet tincidunt enim interdum a. Duis sed gravida felis. Fusce mauris est, bibendum a neque et, fringilla placerat magna. Vestibulum pellentesque massa quis bibendum dapibus. Praesent pharetra ipsum id libero dapibus rutrum. Quisque accumsan dictum lacinia.
Mauris ut mi nec orci accumsan consequat. Donec blandit augue eget nulla fermentum, quis porttitor lacus feugiat. Proin vehicula dolor id lorem egestas elementum. Nullam vitae rutrum tortor. Proin varius adipiscing nibh. Vivamus ultrices nibh nec varius bibendum. Integer quis nisi sed metus adipiscing sagittis. Curabitur congue, nisi nec pretium suscipit, mi leo posuere dui, pellentesque dapibus ligula urna a ligula. Quisque mauris nisl, interdum eu est in, elementum cursus arcu. Sed suscipit vel erat vitae viverra. Mauris neque ipsum, bibendum eget hendrerit ac, vulputate in eros. Ut tincidunt, urna ac auctor porttitor, mauris purus varius erat, ut pellentesque urna turpis non nibh. Aenean sed neque a velit tristique tristique.
Praesent id cursus libero. Vestibulum pulvinar feugiat neque pretium suscipit. Nam vitae magna eget elit aliquam accumsan. Duis et eleifend enim. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec nunc est, commodo quis pretium vitae, lacinia ac lectus. Cras mi tellus, suscipit non leo eget, auctor feugiat mauris. Praesent vitae vehicula ipsum, nec ultrices arcu. Proin mollis leo sit amet erat scelerisque feugiat. Nullam eget varius ante. Praesent a laoreet libero.
Suspendisse ut eros et odio rhoncus malesuada. Integer laoreet, leo at fringilla volutpat, augue lorem tincidunt augue, sit amet feugiat erat neque in est. Phasellus imperdiet, nisi vel faucibus auctor, sapien orci mollis est, tincidunt vehicula nisi nunc sit amet purus. Sed cursus ipsum nisi, id elementum leo feugiat in. Phasellus vitae arcu ac ligula pellentesque malesuada. Maecenas vulputate nunc et consequat pellentesque. Nulla semper quam a orci eleifend, vel gravida est euismod. Nam fermentum, nisi ullamcorper congue convallis, turpis purus lacinia ligula, ac posuere urna est non felis. Cras lobortis ligula neque, vel fermentum magna facilisis sit amet. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
Quisque a quam nec sem vestibulum dapibus quis non lacus. Integer eget ligula eu turpis pretium iaculis. Cras gravida ligula in mauris bibendum placerat. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Proin ac tristique risus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Quisque diam nisi, sodales vel nisi a, sollicitudin commodo ipsum. Fusce elementum nisi ac semper dignissim. Etiam nec felis dapibus lacus faucibus vehicula eget eu odio. Sed id risus tellus. Curabitur in luctus orci.
</p>
</div>
</div>
CSS :
* {
margin: 0;
padding: 0;
font-family: "Helvetica Neue",Helvetica,sans-serif;
line-height: 20px;
}
.main-panel {
min-width: 700px;
width: 100%;
min-height: 500px;
max-height: 700px;
display: -webkit-flex;
display: flex;
background: rgba(64, 64, 64, 0.4);
}
.left-panel {
border-width: 2px 0 0 0 0;
background: rgba(245, 245, 245, 0.4); /* fallback color if gradients are not supported */
background: -webkit-linear-gradient(top, rgba(245, 245, 245, 0.4), rgba(221, 221, 221, 0.4)); /* For Chrome and Safari */
background: -moz-linear-gradient(top, rgba(245, 245, 245, 0.4), rgba(221, 221, 221, 0.4)); /* For old Fx (3.6 to 15) */
background: -ms-linear-gradient(top, rgba(245, 245, 245, 0.4), rgba(221, 221, 221, 0.4)); /* For pre-releases of IE 10*/
background: -o-linear-gradient(top, rgba(245, 245, 245, 0.4), rgba(221, 221, 221, 0.4)); /* For old Opera (11.1 to 12.0) */
background: linear-gradient(to center bottom, rgba(245, 245, 245, 0.4), rgba(221, 221, 221, 0.4)); /* Standard syntax; must be last */
box-shadow: 0px 0px 7px white inset;
-moz-box-shadow: 0px 0px 7px white inset;
-webkit-box-shadow: 0px 0px 7px white inset;
overflow: hidden;
min-width: 180px;
max-width: 280px;
padding: 5px 0 5px 7px;
}
.right-panel {
background-color: white;
overflow: hidden;
padding: 5px 5px 5px 5px;
-webkit-flex: 1;
flex: 1;
flex-basis: auto;
}
.left-panel > .page-nav > .page-tab {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
border: solid 1px rgba(245, 245, 245, 0.4);
box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.3) inset;
border-top-width: 1px;
border-right-width: 0;
padding: 0 5px;
margin-bottom: 0px;
cursor: pointer;
height: 25px;
text-transform: uppercase;
font-weight: bold;
font-size: 11px;
list-style: none;
text-align: center;
}
.left-panel > .page-nav > .page-tab.active {
box-shadow: 2px 2px 2px rgba(245, 245, 245, 0.6) inset;
background: rgba(245, 245, 245, 0.4); /* fallback color if gradients are not supported */
background: -webkit-linear-gradient(top, rgba(68, 68, 68, 0.4), rgba(59, 59, 59, 0.4)); /* For Chrome and Safari */
background: -moz-linear-gradient(top, rgba(68, 68, 68, 0.4), rgba(59, 59, 59, 0.4)); /* For old Fx (3.6 to 15) */
background: -ms-linear-gradient(top, rgba(68, 68, 68, 0.4), rgba(59, 59, 59, 0.4)); /* For pre-releases of IE 10*/
background: -o-linear-gradient(top, rgba(68, 68, 68, 0.4), rgba(59, 59, 59, 0.4)); /* For old Opera (11.1 to 12.0) */
background: linear-gradient(to center bottom, rgba(68, 68, 68, 0.4), rgba(59, 59, 59, 0.4)); /* Standard syntax; must be last */
}
.left-panel > .page-nav > .page-tab.active:after {
content: " ";
height: 0;
width: 0;
border-top: 7px solid transparent;
border-bottom: 7px solid transparent;
border-right: 7px solid white;
margin-right: -5px;
display: inline-block;
float: right;
}
.left-panel > .page-nav > .page-tab:hover {
box-shadow: 2px 2px 2px rgba(245, 245, 245, 0.6) inset;
}
JSFiddle リンク: http://jsfiddle.net/LvG2C/