2月15日重点知识梳理

本文介绍了如何使用CSS设置元素边框的弧度以创建圆形或半圆形,以及利用边框颜色创建不同方向的三角形。同时,讨论了通过调整`display`和`visibility`属性来实现元素的显示与隐藏,及其在页面布局中的差异。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、设置边框弧度

 border-radius: 30px;

二、通过边框设置三角形

注意:1.元素宽高设置为0

2.通过透明色要设置

width: 0;
height: 0;
border: 20px solid red;
border-color: red yellowgreen blue gold;
border-color: transparent transparent blue transparent;
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div.cir {
            width: 200px;
            height: 200px;
            background-color: pink;
            border-radius: 100px;
        }

        div.half {
            width: 200px;
            height: 100px;
            background-color: aqua;
            border-radius: 100px 100px 0 0;
        }

        div.half2 {
            width: 200px;
            height: 100px;
            background-color: black;
            border-radius: 0 0 100px 100px;
        }
        div.half3 {
            width: 100px;
            height: 200px;
            background-color: rgb(119, 210, 27);
            border-radius: 100px 0 0 100px ;
        }
        div.half4 {
            width: 100px;
            height: 200px;
            background-color: rgb(82, 126, 237);
            border-radius: 0 100px 100px 0;
        }

        div.halfhalf {
            width: 100px;
            height: 100px;
            background-color: blueviolet;
            border-radius: 100px 0 0 0;
        }

        div.halfhalf2 {
            width: 100px;
            height: 100px;
            background-color: brown;
            border-radius: 0 100px 0 0;
        }

        div.halfhalf3 {
            width: 100px;
            height: 100px;
            background-color: coral;
            border-radius: 0 0 100px 0;
        }
        div.halfhalf4{
            width: 100px;
            height: 100px;
            background-color: chartreuse;
            border-radius: 0 0 0 100px;
        }

        .san1 {
            /* width: 100px; */
            /* height: 100px; */
            width: 0;
            height: 0;

            /* background-color: greenyellow ; */
            border: 100px solid;
            border-color: greenyellow transparent transparent transparent;
        }

        .san2 {
            width: 0;
            height: 0;
            border: 100px solid;
            border-color: transparent black transparent transparent;
        }

        .san3 {
            width: 0;
            height: 0;
            border: 100px solid;
            border-color: transparent transparent blue transparent;

        }

        .san4 {
            width: 0;
            height: 0;
            border: 100px solid;
            border-color: transparent transparent transparent gold;

        }
    </style>
</head>

<body>
    <div class="cir"> </div>



    <div class="half"></div>
    <br>
    <div class="half2"></div>
    <div class="half3"></div>
    <div class="half4"></div>





    <div class="halfhalf"></div>

    <div class="halfhalf2"></div>
    <br>
    <div class="halfhalf3"></div>
    <br>
    <div class="halfhalf4"></div>
 


    <div class="san1"></div>

    <div class="san2"></div>

    <div class="san3"></div>

    <div class="san4"></div>


</body>

</html>

三、显示与隐藏

display:

可选值:none(影藏)block(显示)

visibility:

可选值:hidden(元素不可见)visible(元素可见)

区别是display设置隐藏时,不占用原来的位置

visibility设置元素不可见时,依旧占有原来的位置

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            width: 200px;
        }
        div{
            background-color: aqua;
        }
        p{
            background-color: blueviolet;
            display: none;
            /* visibility: hidden; */
        }
        div:hover>p{
            display: block;
            /* visibility: visible; */
        }
    </style>
</head>
<body>
   
    <div>
        开应杨不丑。
        <p>要失同命若。</p>
        <h3>一若国</h3>
    </div>
</body>



</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值