html - Centering an CSS arrow -


i've used following code create myself arrow,

.arrow-divider{     height:12px;     width:12px;     transform:rotate(-45deg);     border-right:2px solid white;     border-bottom:2px solid white; } 

whenever try center using margin:0 auto not center because want half of right side of box centered, centers whole box, how fix this?

i'm stuck on following code

<div class="box">    <div class="center-divider"> </div>    <div class="arrow-wrapper">    <div class="arrow-divider"></div>     </div>  </div>  .box{   position:relative;   background:orange;   width:100%;   height:50px;   text-align:center;   line-height:50px; }  .arrow-wrapper{   display:inline-block; }  .center-divider{   position:absolute;   width:6px;height:100%;   background:red;   left:0;right:0;   margin:auto; } .arrow-divider{   height:12px;   width:12px;   transform:rotate(-45deg);   border-right:2px solid black;   border-bottom:2px solid black; } 

i've included following demo: jsfiddle

last word, i'm not looking use flexbox , it's align-items , justify-content feature.

edit: why downvote?

since arrow divider fixed width/height of 12px... why not subtract half of it: margin-left:-6px ?

.arrow-divider{   height:12px;   width:12px;   margin-left:-6px;   transform:rotate(-45deg);   border-right:2px solid black;   border-bottom:2px solid black; } 

here updated fiddle.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -