2017-05-03 69 views

回答

1

您与重视你figcaptiontop:left:属性添加position: relative

注意:如果要获得一致的结果,图像和标题的大小必须始终相同。此外,屏幕大小调整不会导致块移动。你需要解决这个问题的响应性,但这是基本的想法。

figure { 
 
    margin-top: 100px; 
 
    position: relative; 
 
} 
 

 
figcaption { 
 
    position: relative; 
 
    background: rgba(255,0,0,0.6); 
 
    -ms-transform: rotate(90deg); 
 
    /* IE 9 */ 
 
    -webkit-transform: rotate(90deg); 
 
    /* Chrome, Safari, Opera */ 
 
    transform: rotate(90deg); 
 
    left: 280px; 
 
    top: -102px; 
 

 
/* transform-origin: 100% 25px; */ 
 
} 
 

 
figcaption p { 
 
}
<div class="container"> 
 

 
    <div class="row"> 
 
    <figure class="col-md-6"> 
 
     <img src="http://placehold.it/540x360" alt="Gear"> 
 
     <figcaption class="dash-holder vertical"> 
 
     <p>Gear</p> 
 
     </figcaption> 
 
     <!-- End figcaption.vertical --> 
 
    </figure> 
 
    <!-- End figure.col-md-6 --> 
 
    </div> 
 

 

 
</div>

http://codepen.io/illdapt/pen/KmvWEx

+0

有也有修复,所以我可以从对准底部的文本,你可以在我的设计见上? – Caspert

+0

我调整了底部的codepen链接,基本上将'margin-top'添加到figcaption p元素以将其移动到所需的位置。 – Illdapt

0

你可以使用Flexbox的定位和transform-origin来控制旋转的元素。您也可以使用保证金DEMO从图底部开始修改figcaption的头寸。

figure { 
 
    margin-top: 100px; 
 
    position: relative; 
 
    align-items: flex-end; 
 
    display: flex; 
 
} 
 
figcaption { 
 
    background: rgba(255, 0, 0, 0.6); 
 
    transform: rotate(90deg); 
 
    transform-origin: top right; 
 
} 
 
figcaption p { 
 
    margin: 0; 
 
}
<figure class="col-md-6"> 
 
    <img src="http://placehold.it/540x360" alt="Gear"> 
 
    <figcaption class="dash-holder vertical"> 
 
    <p>Gear</p> 
 
    </figcaption> 
 
</figure>