如何旋转外部div而不是内部内容

2022-09-06 00:00:00 rotation html css css-transforms

如何将图像放入div中,并且此div以45度旋转?


解决方案

img的转换样式中添加scale值,如下所示:

数据-lang="js"数据-隐藏="假"数据-控制台="真"数据-巴贝尔="假">
.profile-photo { width: 210px; height: 210px; position: relative; left: 43px; top: 50px; border: 8px solid #000; border-radius: 60px; transform: rotate(45deg); overflow: hidden; z-index: 2; background: #34983e;padding:0 }

.profile-photo img {
  width: 100%;
  transform: rotate(-45deg) scale(1.21)
}
<div class="profile-photo"> 
  <img alt="Profile photo" src="http://www.michiganurology.com/wp-content/uploads/2015/10/reddy.jpg" onerror="this.onerror=null;this.src='https://via.placeholder.com/500/E5E8EC/4B89DA?text=error+image';">
</div>

相关文章