当前位置:网站首页 > HTML与CSS基础 > 正文

css3画立体图形

一,效果

在这里插入图片描述

二,代码

<template> <div id="app"> <div> <div class="yuanzhui"> <div></div> </div> </div> <div class="cube"> <div class="side front"></div> <div class="side back"></div> <div class="side right"></div> <div class="side left"></div> <div class="side top"></div> </div> <div class="cube2"> <div class="side front"></div> <div class="side back"></div> <div class="side right"></div> <div class="side left"></div> <div class="side top"></div> </div> </div> </template> <script> export default { 
    name: "App", components: { 
   }, data() { 
    return { 
   }; }, methods: { 
   }, }; </script> <style scoped lang="scss"> .yuanzhui { 
    margin: auto; position: relative; width: 200px; height: 300px; // background: red; &::before { 
    position: absolute; content: ""; left: 0px; width: 0; height: 0; border-bottom: 120px solid rgba(255, 103, 116, 0.8); border-left: 100px solid transparent; border-top: 170px solid transparent; transform: skewY(10deg); filter: drop-shadow(3px 3px 5px rgba(241, 198, 241, 0.5)); } &:after { 
    position: absolute; content: ""; right: 0px; width: 0; height: 0; border-bottom: 120px solid rgba(255, 103, 116, 0.8); border-right: 100px solid transparent; border-top: 170px solid transparent; transform: skewY(-10deg); filter: drop-shadow(6px 6px 5px rgba(241, 198, 241, 0.5)); } div { 
    position: absolute; bottom: 2px; left: 98px; width: 4px; height: 120px; background: #fff; z-index: 9; opacity: 0.3; box-shadow: 0px -2px 4px 1px #fff; } } .cube { 
    position: relative; top: 30px; width: 400px; height: 5px; // background: red; margin: auto; transform-style: preserve-3d; transform: rotateX(-10deg) rotateY(45deg); transform-origin: center; height: 2px; .side { 
    position: absolute; width: 200px; height: 200px; background: transparent; // border: 1px solid rgba(0, 0, 0, 0.5); color: white; } .front { 
    transform-origin: top; transform: translateZ(100px) rotateX(30deg); width: 200px; height: 0; border-bottom: 200px solid rgba(247, 67, 226, 0.8); border-left: 100px solid transparent; border-right: 100px solid transparent; filter: drop-shadow(3px 3px 5px rgba(0, 0, 0, 0.5)); } .top { 
    transform: rotateX(90deg) translateZ(100px) translateX(100px); background: rgba(247, 67, 226, 0.8); } .left { 
    transform-origin: top; transform: translateX(-100px) rotateY(-90deg) rotateX(30deg); width: 200px; height: 0; border-bottom: 200px solid rgba(247, 67, 226, 0.8); border-top: 0 solid transparent; border-left: 100px solid transparent; border-right: 100px solid transparent; filter: drop-shadow(3px 3px 5px rgba(0, 0, 0, 0.5)); } .right { 
    transform-origin: top; transform: translateX(100px) rotateY(90deg) rotateX(30deg); width: 200px; height: 0; border-bottom: 200px solid rgba(247, 67, 226, 0.8); border-top: 0 solid transparent; border-left: 100px solid transparent; border-right: 100px solid transparent; filter: drop-shadow(3px 3px 5px rgba(0, 0, 0, 0.5)); } .back { 
    transform-origin: top; transform: translateZ(-100px) rotateX(-30deg); width: 200px; height: 0; border-bottom: 200px solid rgba(247, 67, 226, 0.8); border-top: 0 solid transparent; border-left: 100px solid transparent; border-right: 100px solid transparent; filter: drop-shadow(3px 3px 5px rgba(0, 0, 0, 0.5)); } } .cube2 { 
    position: relative; top: 300px; width: 800px; height: 5px; margin: auto; transform-style: preserve-3d; transform: rotateX(-10deg) rotateY(45deg); transform-origin: center; .side { 
    position: absolute; width: 400px; height: 400px; background: transparent; // border: 1px solid rgba(0, 0, 0, 0.5); color: white; } .front { 
    transform-origin: top; transform: translateZ(200px) rotateX(30deg); width: 400px; height: 0; border-bottom: 400px solid rgba(30, 119, 252, 0.8); border-left: 200px solid transparent; border-right: 200px solid transparent; filter: drop-shadow(3px 3px 5px rgba(0, 0, 0, 0.5)); } .top { 
    transform: rotateX(90deg) translateZ(100px) translateX(200px); background: rgba(15, 89, 201, 0.8); } .left { 
    transform-origin: top; transform: translateX(-200px) rotateY(-90deg) rotateX(30deg); width: 400px; height: 0; border-bottom: 400px solid rgba(30, 119, 252, 0.8); border-top: 0 solid transparent; border-left: 200px solid transparent; border-right: 200px solid transparent; filter: drop-shadow(3px 3px 5px rgba(0, 0, 0, 0.5)); } .right { 
    transform-origin: top; transform: translateX(200px) rotateY(90deg) rotateX(30deg); width: 400px; height: 0; border-bottom: 400px solid rgba(30, 119, 252, 0.8); border-top: 0 solid transparent; border-left: 200px solid transparent; border-right: 200px solid transparent; filter: drop-shadow(3px 3px 5px rgba(0, 0, 0, 0.5)); } .back { 
    transform-origin: top; transform: translateZ(-200px) rotateX(-30deg); width: 400px; height: 0; border-bottom: 400px solid rgba(30, 119, 252, 0.8); border-top: 0 solid transparent; border-left: 200px solid transparent; border-right: 200px solid transparent; filter: drop-shadow(3px 3px 5px rgba(0, 0, 0, 0.5)); } } </style> 
到此这篇css3画立体图形的文章就介绍到这了,更多相关内容请继续浏览下面的相关推荐文章,希望大家都能在编程的领域有一番成就!

版权声明


相关文章:

  • css中用两种方法实现两列布局,左列定宽200px,右列自适应宽2024-12-02 07:36:09
  • css中三栏布局之两边宽度固定,中间宽度自适应-5种方法总结——flex布局、浮动布局、绝对定位布局、圣杯布局、双飞翼布局2024-12-02 07:36:09
  • 网络爬虫开发(二)-爬虫基础——使用cheerio库解析html并提取img的src属性& 使用download库批量下载图片& encodeURI()函数-解决若有中文文件名,需使用base64编码2024-12-02 07:36:09
  • 登录和注册(三)01登录页——原生loading、setItem设置session、store.commit使用vuex、原生http.post请求、removeAttribute()删除html属性2024-12-02 07:36:09
  • 奉劝你别看!是会缩放的红色爱心代码2024-12-02 07:36:09
  • webpack5热更新失效,且只有css修改后失效?2024-12-02 07:36:09
  • webpack5学习与实战-(十三)-postcss处理css3兼容性前缀2024-12-02 07:36:09
  • 前端项目,css样式获取到了,没能渲染页面2024-12-02 07:36:09
  • css3动画的使用2024-12-02 07:36:09
  • 移动端H5界面 前端html app 自动清除引入的css js缓存方法2024-12-02 07:36:09
  • 全屏图片