用css3 怎么制作菱形图片,图片是正的不旋转,新手求大神指点,最好把代码写出来,

html-css011

用css3 怎么制作菱形图片,图片是正的不旋转,新手求大神指点,最好把代码写出来,,第1张

思路: div旋转45度 img旋转-45度

html:<div class="lx"><img src="img/replace_me.jpg" alt=""></div>

css:

.lx{transform:rotate(45deg)width:400pxheight:400pxoverflow:hiddenvertical-align: middletext-align: centermargin:100px autodisplay:flex}

.lx img{transform:rotate(-45deg)max-width:100%max-height:100%}

使用纯css制作扇形图,合并起来形成饼图:

应该知道css3中引入了圆角属性(border-radius),一旦设置这个值,边框即会出现圆角。同样,我们对正方形设置圆角,即可得到饼状图

html:<div id="circle">11</div>

css:

#circle{

width:0

height:0

border-radius:100px

border-width:100px

border-style:solid

border-color: red blue green yellow

line-height:99em

overflow:hidden

cursor:pointer

margin: 30px auto

}

效果:

4.同样我们对其中三个边框设置透明色即可得到扇形

html:<div id="fan">11</div>

css:

#fan{

width:0

height:0

border-radius:100px

border-width:100px

border-style:solid

border-color:red transparent transparent transparent

line-height:99em

overflow:hidden

cursor:pointer

margin: 30px auto

}

效果: