CSS实现图形效果

CSS实现图形效果

CSS实现正方形、长方形、圆形、半圆、椭圆、三角形、平行四边形、菱形、梯形、六角星、五角星、心形、消息框。

正方形

<section><div id="square"></div>
</section>
<style type="text/css">#square{width: 100px;height: 100px;background: #4C98F7;}
</style>

长方形

<section><div id="rectangle"></div>
</section>
<style type="text/css">#rectangle{width: 200px;height: 100px;background: #4C98F7;}
</style>

圆形

<section><div id="circle"></div>
</section>
<style type="text/css">#circle{width: 100px;height: 100px;background: #4C98F7;border-radius: 50%;}
</style>

半圆

<section><div id="semicircle"></div>
</section>
<style type="text/css">#semicircle{width: 100px;height: 50px;background: #4C98F7;border-radius: 100px 100px 0 0;}
</style>

椭圆

<section><div id="oval"></div>
</section>
<style type="text/css">#oval{width: 100px;height: 50px;background: #4C98F7;border-radius: 100px / 50px;}
</style>

三角形

<section><div id="regular-triangle"></div>
</section>
<style type="text/css">#regular-triangle{width: 0;height: 0;border-left: 50px solid transparent;border-right: 50px solid transparent;border-bottom: 100px solid #4C98F7;}
</style><section><div id="corner-triangle"></div>
</section>
<style type="text/css">#corner-triangle{width: 0;height: 0;border-top: 100px solid #4C98F7;border-right: 100px solid transparent;}
</style>

平行四边形

<section><div id="parallelogram"></div>
</section>
<style type="text/css">#parallelogram{margin: 0 15px;width: 200px; height: 100px; transform: skew(-20deg); background: #4C98F7;}
</style>

菱形

<section><div id="diamond"></div>
</section>
<style type="text/css">#diamond {width: 0;height: 0;border: 100px solid transparent;border-bottom-color: #4C98F7;position: relative;top: -100px;}#diamond:after {content: "";position: absolute;left: -100px;top: 100px;width: 0;height: 0;border: 100px solid transparent;border-top-color: #4C98F7;}
</style>

六角星

<section><div id="hexagons"></div>
</section>
<style type="text/css">#hexagons {width: 0;height: 0;border: 100px solid transparent;border-bottom-color: #4C98F7;position: relative;top: -100px;}#diamond:after {content: "";position: absolute;left: -100px;top: 100px;width: 0;height: 0;border: 100px solid transparent;border-top-color: #4C98F7;}
</style>

五角星

<section><div id="five-pointed-star"></div>
</section>
<style type="text/css">#five-pointed-star { margin: 100px 0 50px 0; position: relative;width: 0px; height: 0px; border-right: 100px solid transparent; border-bottom: 70px solid #4C98F7; border-left: 100px solid transparent; transform: rotate(35deg); }#five-pointed-star:before { content: ""; position: absolute; height: 0; width: 0; top: -45px; left: -65px; border-bottom: 80px solid #4C98F7; border-left: 30px solid transparent; border-right: 30px solid transparent; transform: rotate(-35deg); } #five-pointed-star:after { content: ""; position: absolute; top: 3px; left: -105px; width: 0px; height: 0px; border-right: 100px solid transparent; border-bottom: 70px solid #4C98F7; border-left: 100px solid transparent; transform: rotate(-70deg); }
</style>

心形

<section><div id="five-pointed-star"></div>
</section>
<style type="text/css">#five-pointed-star { margin: 100px 0 50px 0; position: relative;width: 0px; height: 0px; border-right: 100px solid transparent; border-bottom: 70px solid #4C98F7; border-left: 100px solid transparent; transform: rotate(35deg); }#five-pointed-star:before { content: ""; position: absolute; height: 0; width: 0; top: -45px; left: -65px; border-bottom: 80px solid #4C98F7; border-left: 30px solid transparent; border-right: 30px solid transparent; transform: rotate(-35deg); } #five-pointed-star:after { content: ""; position: absolute; top: 3px; left: -105px; width: 0px; height: 0px; border-right: 100px solid transparent; border-bottom: 70px solid #4C98F7; border-left: 100px solid transparent; transform: rotate(-70deg); }
</style>

消息框

<section><div id="message-box"></div>
</section>
<style type="text/css">#message-box { margin: 0 20px;width: 120px; height: 80px; background: #4C98F7; position: relative; border-radius: 10px; } #message-box:before { content:"";position: absolute; right: 100%; top: 26px; width: 0; height: 0; border-top: 13px solid transparent; border-right: 26px solid #4C98F7; border-bottom: 13px solid transparent; }
</style>

示例

<!DOCTYPE html>
<html>
<head><title>CSS实现图形效果</title><style type="text/css">section{margin: 10px 0;}#square{width: 100px;height: 100px;background: #4C98F7;}#rectangle{width: 200px;height: 100px;background: #4C98F7;}#circle{width: 100px;height: 100px;background: #4C98F7;border-radius: 50%;}#semicircle{width: 100px;height: 50px;background: #4C98F7;border-radius: 100px 100px 0 0;}#semicircle{width: 100px;height: 50px;background: #4C98F7;border-radius: 100px 100px 0 0;}#oval{width: 100px;height: 50px;background: #4C98F7;border-radius: 100px / 50px;}#regular-triangle{width: 0;height: 0;border-left: 50px solid transparent;border-right: 50px solid transparent;border-bottom: 100px solid #4C98F7;}#corner-triangle{width: 0;height: 0;border-top: 100px solid #4C98F7;border-right: 100px solid transparent;}#parallelogram{margin: 0 15px;width: 200px; height: 100px; transform: skew(-20deg); background: #4C98F7;}#diamond {width: 0;height: 0;border: 100px solid transparent;border-bottom-color: #4C98F7;position: relative;top: -100px;}#diamond:after {content: "";position: absolute;left: -100px;top: 100px;width: 0;height: 0;border: 100px solid transparent;border-top-color: #4C98F7;}#hexagons{ margin: 35px 0;width: 0; height: 0; border-left: 60px solid transparent; border-right: 60px solid transparent; border-bottom: 60px solid #4C98F7; position: relative; } #hexagons:after { width: 0; height: 0; border-left: 60px solid transparent; border-right: 60px solid transparent; border-top: 60px solid #4C98F7; position: absolute; content: ""; top: 20px; left: -60px; }#five-pointed-star { margin: 100px 0 70px 0; position: relative;width: 0px; height: 0px; border-right: 100px solid transparent; border-bottom: 70px solid #4C98F7; border-left: 100px solid transparent; transform: rotate(35deg); }#five-pointed-star:before { content: ""; position: absolute; height: 0; width: 0; top: -45px; left: -65px; border-bottom: 80px solid #4C98F7; border-left: 30px solid transparent; border-right: 30px solid transparent; transform: rotate(-35deg); } #five-pointed-star:after { content: ""; position: absolute; top: 3px; left: -105px; width: 0px; height: 0px; border-right: 100px solid transparent; border-bottom: 70px solid #4C98F7; border-left: 100px solid transparent; transform: rotate(-70deg); }#heart-shaped {position: relative;width: 100px;height: 90px;}#heart-shaped:before,#heart-shaped:after {content: "";position: absolute;left: 50px;top: 0;width: 50px;height: 80px;background: #4C98F7;border-radius: 50px 50px 0 0;transform: rotate(-45deg);transform-origin: 0 100%;}#heart-shaped:after {left: 0;transform: rotate(45deg);transform-origin: 100% 100%;}#message-box { margin: 0 20px;width: 120px; height: 80px; background: #4C98F7; position: relative; border-radius: 10px; } #message-box:before { content:"";position: absolute; right: 100%; top: 26px; width: 0; height: 0; border-top: 13px solid transparent; border-right: 26px solid #4C98F7; border-bottom: 13px solid transparent; }</style>
</head>
<body><section><div id="square"></div></section><section><div id="rectangle"></div></section><section><div id="circle"></div></section><section><div id="semicircle"></div></section><section><div id="oval"></div></section><section><div id="regular-triangle"></div></section><section><div id="corner-triangle"></div></section><section><div id="parallelogram"></div></section><section><div id="diamond"></div></section><section><div id="hexagons"></div></section><section><div id="five-pointed-star"></div></section><section><div id="heart-shaped"></div></section><section><div id="message-box"></div></section>
</body>
</html>

每日一题

https://github.com/WindrunnerMax/EveryDay

参考

https://www.jianshu.com/p/f40617d863a3
https://css-tricks.com/the-shapes-of-css/
https://www.w3cplus.com/css/create-shapes-with-css

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/22401.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

使用onnxruntime加载YOLOv8生成的onnx文件进行目标检测

在网上下载了60多幅包含西瓜和冬瓜的图像组成melon数据集&#xff0c;使用 LabelMe 工具进行标注&#xff0c;然后使用 labelme2yolov8 脚本将json文件转换成YOLOv8支持的.txt文件&#xff0c;并自动生成YOLOv8支持的目录结构&#xff0c;包括melon.yaml文件&#xff0c;其内容…

干货!如何在Jmeter中实现对NCR响应的解析

最近做接口测试时发现了一个问题&#xff0c;部分请求的响应是通过NCR编码实现的&#xff0c;这样就导致了无法对这些请求进行断言&#xff0c;为了解决这个问题进行了如下调研&#xff0c;大家可以参考下面两篇文章&#xff1a; 使用Java apache commons包五分钟搞定NCR解析&…

CCIG 2024:大模型技术及其前沿应用论坛深度解析

一、CCIG论坛介绍 中国图象图形大会&#xff08;CCIG 2024&#xff09;是一场备受瞩目的学术盛会&#xff0c;近期在陕西省西安市曲江国际会议中心举行。这次会议以“图聚智生&#xff0c;象合慧成”为主题&#xff0c;由中国图象图形学学会主办&#xff0c;旨在汇聚图像图形领…

架构每日一学 14:架构师如何进行可行性探索?

架构活动中&#xff0c;如果不进行可行性探索可能会导致重大失误&#xff0c;为企业发展带来风险。 可行性探索是架构活动的最后一个节点&#xff0c;在这之后的架构活动就像是离弦之箭&#xff0c;即便发现重大风险也很难再回头了。 互联网公司之间的竞争非常激烈&#xff0…

elementUI中,el-table-column中设定min-width无效的解决办法

方案一&#xff1a;必须为所有的列都设置min-width&#xff0c;只设定几项是无法生效的。而且不能使用px。 <el-table-column ......(省略其它设置) :min-width"122" ......(省略其它设置) </el-table-column>

ABAP 长文本编辑器弹窗控件

前言 用户想在ALV上编辑长文本&#xff0c;但是ALV只有128个字符肯定是不够用的&#xff0c;所以需要用一个长文本编辑器来输入&#xff0c;本来想自己写的&#xff0c;发现有标准的函数&#xff0c;还挺好用的 代码 在用户双击ALV字段时&#xff0c;触发下述form&#xff0…

Go 语言中的切片:灵活的数据结构

切片&#xff08;slice&#xff09;是 Go 语言中一种非常重要且灵活的数据结构&#xff0c;它提供了对数组子序列的动态窗口。这使得切片在 Go 中的使用非常频繁&#xff0c;特别是在处理动态数据集时。本文将探讨切片的概念、操作和与函数的交互&#xff0c;以及如何有效地使用…

Less的简单总结

Less 是一个开源的 CSS 预处理器&#xff0c;它扩展了 CSS 语言&#xff0c;增加了变量、嵌套规则、运算符、函数等特性&#xff0c;使编写 CSS 更加高效、灵活且易于维护。下面是对 "Less" 的一个总结文档&#xff1a; 简介 名称&#xff1a;Less&#xff08;通常表…

使用Rufus工具制作Ubuntu To Go——很详细

一、准备工作 准备工具&#xff1a; 1、下载Rufus(主角)软件 2、准备一个U盘或硬盘&#xff08;小白128G足够&#xff0c;装Ubuntu系统&#xff09; 3、下载Ubuntu系统镜像文件 1、下载软件Rufus 先来看一下官网介绍&#xff1a; Rufus 是一款格式化和创建 USB 启动盘的辅助工…

“GPT-4o深度解析:技术演进、能力评估与个人体验综述“

文章目录 每日一句正能量前言对比分析模型架构性能应用场景用户体验技术创新社区和生态系统总结 技术能力语言生成能力语言理解能力技术实现总结 个人感受关于GPT-4o的假设性观点&#xff1a;关于当前语言模型的一般性观点&#xff1a; 后记 每日一句正能量 又回到了原点&#…

Objective-C中分类无法添加实例变量的底层原理

在 Objective-C 中&#xff0c;分类&#xff08;category&#xff09;无法添加实例变量&#xff0c;这是由于底层实现的限制。要理解这一点&#xff0c;需要先了解 Objective-C 的类和对象内存布局及运行时机制。 类和对象的内存布局 在 Objective-C 中&#xff0c;每个对象都…

“智能分析赋能等保:大数据技术在安全审计记录中的应用“

智能分析技术在信息安全领域&#xff0c;尤其是等保&#xff08;等级保护&#xff09;合规性方面&#xff0c;发挥了关键作用。特别是结合大数据技术&#xff0c;安全审计记录的处理和分析能力得到了显著增强。以下几点阐述了大数据技术是如何赋能等保安全审计的&#xff1a; …

【Python】 Python中的functools.wraps:装饰器的优雅包装

基本原理 在Python中&#xff0c;装饰器是一种非常强大的工具&#xff0c;它允许我们以一种非常灵活的方式修改或增强函数的行为。装饰器本质上是一个函数&#xff0c;它接收一个函数作为参数&#xff0c;并返回一个新的函数。然而&#xff0c;当我们使用装饰器时&#xff0c;…

python输出字符串的几种方式

使用 print() 函数 这是最基础和常用的输出方式。它可以直接输出字符串,也可以输出其他数据类型,如数字、列表等。 name "Alice" age 25 print(name) # Output: Alice print("My name is", name, "and Im", age, "years old.") #…

【笔记】Sturctured Streaming笔记总结(Python版)

目录 相关资料 一、概述 1.1 基本概念 1.2 两种处理模型 &#xff08;1&#xff09;微批处理 &#xff08;2&#xff09;持续处理 1.3 Structured Streaming和Spark SQL、Spark Streaming关系 二、编写Structured Streaming程序的基本步骤 三、输入源 3.1 File源 &a…

Docker 基础使用 (1) 使用流程概览

文章目录 Docker 软件安装Docker 镜像仓库Docker 仓库指令Docker 镜像指令Docker 容器指令Docker 使用实例 —— 搭建 nginx 服务nginx 概念nginx 使用用 docker 启动 nginx Docker 基础使用&#xff08;0&#xff09;基础认识 Docker 基础使用 (1) 使用流程概览 Docker 基础使…

如何自研一个低代码工具

自研一个低代码工具是一个复杂且需要多方面技能的任务。以下是一个大致的步骤和指南&#xff0c;帮助你开始这个项目&#xff1a; 明确目标和需求&#xff1a; 确定你的低代码工具要解决的主要问题或满足的主要需求。 定义目标用户群和他们的技术背景。 确定你的工具要支持的…

f-stack和DPDK

GPT-4 (OpenAI) f-stack和DPDK&#xff08;数据平面开发套件&#xff09;都是与高性能网络处理相关的技术。它们的目的是提高数据包的处理速度&#xff0c;优化网络I/O的性能。以下是对这两者的简要解释&#xff1a; 1. **DPDK (Data Plane Development Kit):** DPDK 是一个…

药物设计中的SE3等变图神经网络层- EGNN 解析

此部分内容介绍了常用在药物设计深度学习中的SE3等变网络层 EGNN。主要对EGNN的代码逻辑、模块进行解析&#xff0c;并介绍其中的SE3等变在模型中的原理。 注&#xff1a;EGNN代码有多种。此部分EGNN代码来源于DiffLinker。其源头为EDM模型&#xff0c;DiffLinker进行了修改。…

【软件安全国产化替代解决方案】亮相2024澳门万讯论坛

近日&#xff0c;2024万讯论坛在澳门成功举办。本次论坛由万讯电脑科技主办&#xff0c;旨在引进国内尖端科技厂商&#xff0c;提供全方位的信创解决方案&#xff0c;分享信创化过程中所面临的挑战及阶段性转换经验。开源网安作为拥有软件安全领域全链条产品的厂商&#xff0c;…