使用HTML+CSS画太极八卦图

使用HTML+CSS画太极八卦图

基本语法

CSS基本语法格式:

选择符{属性1:属性值1;属性2:属性值2;属性3:属性值3;......}

选择符:

1.元素选择器:找到同名一系列
2.类选择器:找到同类名一系列
    定义:<div class="div1">web前端开发1</div>
    调用:.div1{属性1:属性值1;属性2:属性值2;属性3:属性值3;......}
3.id选择器:唯一性,只能找到一个
    定义:<div id="div1">web前端开发1</div>
    调用:#div1{属性1:属性值1;属性2:属性值2;属性3:属性值3;......}

CSS使用方式:

内嵌:使用<style></style>标签放在<head></head>中

CSS常用属性:

width:300px;---宽度
height:---高度
border:1px solid red;----复合属性 
    1px:border-width:1px;
    solid:border-style:solid;
    red:border-color:red;
background-color:---背景颜色
background-image:url(图片路径--使用相对路径)
background-repeat:平铺
background-size:背景图片的大小

字体阴影

text-shhadow:5px(水平方向偏移,可以为负) 6px(竖直方向偏移,可以为负) 5px(阴影效果,不能为负) black;

border-radius:圆角属性

圆:前提-正方形
值:大于等于二分之一的宽度即可

position: absolute;—绝对定位

//具体语法
           #div1{//Id选择器
			position: absolute;
            left: 90px;
            top: 100px;
           } 

堆叠覆盖

z-index: 300;//在有绝对定位的条件下使用 即在 position: absolute;

代码

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8"/>
        <title>圆</title>
        <style>
            .bg{
                background-color:goldenrod;
            }
            #yuan1{
                width: 200px; height: 400px;
                background-color: black;
                border-radius: 200px 0px 0px 200px ;
            }
            #yuan2{
                width: 200px; height: 400px;
                background-color:white;
                border-radius: 0px 200px 200px 0px ;
                position:absolute;
                left: 208px;
                top: 8px;
            }
            #wyuan1{
                width: 200px;height: 200px;
                background-color: white;
                border-radius: 100px;
                position: absolute;
                left: 100px;
            }
            #byuan1{
                width: 200px;height: 200px;
                background-color:black;
                border-radius: 100px;
                position: absolute;
                left: -100px;
                top: 200px;
            }
            #tbyuan{
                width: 20px;
                height: 20Px;
                background-color: black;
                border-radius: 10px;
                position: absolute;
                left: 100px;
                top: 93px;
                z-index: 200;
            }
            #twyuan{
                width: 20px;
                height: 20Px;
                background-color: white;
                border-radius: 10px;
                position: absolute;
                left: 90px;
                top: 100px;
                z-index: 300;
            }
        </style>
    </head>
    <body>
        <div class="bg">
                <div id="yuan1">
                    <div id="wyuan1">
                        <div id="tbyuan"></div>
                    </div>
                </div>
                <div id="yuan2">
                    <div id="byuan1">
                        <div id="twyuan"></div>
                    </div>
                </div>
        </div>
        
    </body>
</html>

效果

s实现效果

  • 4
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
好的,以下是一个用HTMLCSS实现太极八卦图的代码: ```html <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>太极八卦图</title> <style> #taiji { width: 200px; height: 200px; border-radius: 50%; background: linear-gradient(90deg, #000000, #ffffff, #000000); position: relative; transform: rotate(45deg); } #taiji:before { content: ''; display: block; width: 100px; height: 100px; border-radius: 50%; background-color: #ffffff; position: absolute; top: 0; left: 50%; margin-left: -50px; } #taiji:after { content: ''; display: block; width: 100px; height: 100px; border-radius: 50%; background-color: #000000; position: absolute; bottom: 0; left: 50%; margin-left: -50px; } #taiji .yin { width: 50px; height: 50px; border-radius: 50%; background-color: #ffffff; position: absolute; top: 25px; left: 50%; margin-left: -25px; } #taiji .yang { width: 50px; height: 50px; border-radius: 50%; background-color: #000000; position: absolute; bottom: 25px; left: 50%; margin-left: -25px; } #taiji .left { width: 50px; height: 50px; border-radius: 50% 0 0 50%; background-color: #000000; position: absolute; top: 75px; left: 0; } #taiji .right { width: 50px; height: 50px; border-radius: 0 50% 50% 0; background-color: #ffffff; position: absolute; top: 75px; right: 0; } #taiji .left:before { content: ''; display: block; width: 25px; height: 50px; background-color: #ffffff; position: absolute; top: 0; left: 0; } #taiji .right:before { content: ''; display: block; width: 25px; height: 50px; background-color: #000000; position: absolute; top: 0; right: 0; } #taiji .left:after { content: ''; display: block; width: 50px; height: 50px; background-color: #000000; position: absolute; top: 0; left: 25px; border-radius: 50%; transform: rotate(45deg); } #taiji .right:after { content: ''; display: block; width: 50px; height: 50px; background-color: #ffffff; position: absolute; top: 0; right: 25px; border-radius: 50%; transform: rotate(45deg); } </style> </head> <body> <div id="taiji"> <div class="yin"></div> <div class="yang"></div> <div class="left"></div> <div class="right"></div> </div> </body> </html> ``` 这段代码会生成一个200*200大小的太极八卦图使用CSS3的渐变、旋转、倾斜等属性来实现。同时,八卦图内部的阴、阳两极和四个小半圆也使用CSS来绘制。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值