我有以下问题:
-我要旋转图片中显示的文字
-在这里,我尝试在以下代码中执行此操作
谁能为我提供解决方案?
div {
width: 200px;
height: 30px;
background-color: yellow;
border: 1px solid black;
margin-top:20px;
}
div#myDiv {
-ms-transform: rotate(315deg);
-webkit-transform: rotate(315deg);
transform: rotate(315deg);
}
<html>
<head>
<style>
</style>
</head>
<body>
<div id="myDiv">
This div element is rotated .
</div>
<div id="myDiv">
This div element is rotated .
</div>
<div id="myDiv">
This div element is rotated .
</div>
</body>
</html>
最佳答案
您可以在div上显示:inline-block,并将transform-origin设置为right.
原文链接:https://www.f2er.com/html/530408.html请参见下面的示例:
div#myDiv {
width: 200px;
height: 30px;
background-color: yellow;
border: 1px solid black;
margin-top: 20px;
display: inline-block; /* add display: inline-block */
}
div#myDiv {
transform: rotate(315deg);
transform-origin: right;
}
<div id="myDiv">
This div element is rotated .
</div>
<div id="myDiv">
This div element is rotated .
</div>
<div id="myDiv">
This div element is rotated .
</div>