裏面象這樣如何將文本位置的旋轉格箱
應該過於集中。
.diamond {
display: block;
height: 30px;
width: 30px;
background-color: white;
border: 2px solid #dcdcdc;
transform: rotate(45deg);}
裏面象這樣如何將文本位置的旋轉格箱
應該過於集中。
.diamond {
display: block;
height: 30px;
width: 30px;
background-color: white;
border: 2px solid #dcdcdc;
transform: rotate(45deg);}
以其他方式旋轉內容。
* {
margin: 0;
padding: 0;
}
.diamond {
display: block;
height: 30px;
width: 30px;
background-color: white;
border: 2px solid #dcdcdc;
transform: rotate(45deg);
text-align: center;
line-height: 30px;
margin: 25px;
}
.diamond p {
transform: rotate(-45deg);
}
<div class="diamond">
<p>Hi</p>
</div>
我會用一個僞元素這一點。
然後我只需要應用一個旋轉。
該旋轉僅在單個元素上。
.mid-angle {
color: black;
width: 50px;
height: 50px;
text-align: center;
line-height: 50px;
}
.mid-angle:before {
content: " ";
display: block;
position: absolute;
width: 50px;
height: 50px;
box-sizing: border-box;
border: 2px solid pink;
transform: rotate(45deg);
}
<div class="mid-angle">Hello</div>
這也是一個不錯的主意。瀏覽器如何支持僞元素?這不是比我們使用的「變換」更新,是嗎? – xperator
蕩,我傻。我試圖用旋轉和相對定位來做到這一點,很好的解決方案@Paulie_D。 –
噢,真好!那個想法確實在我腦海中浮現,但我認爲必須有一種更自然的方式來做到這一點。 – xperator