css 选择器方法 :hover

css 选择器方法 hover、focus、active、link、visited

hover 英[ˈhɒvə®]
美[ˈhʌvər]
v. 翱翔; 盘旋; 踌躇,彷徨(尤指在某人身边); 靠近(某事物); 处于不稳定状态;
1.html

<!DOCTYPE html>
<html lang="en"><!--提示是否翻译的-->
<head>
    <meta charset="UTF-8">
    <title>划过显示详情</title>
    <!--import css-->
    <style>
        *{
            margin: 0;
            padding:0;
        }
        .box{
            
            box-sizing: border-box;/*盒子最终的宽高*/
            width: 200px;
            height: 40px;
            border: 1px solid lightcoral;
            margin: 20px auto;/*20与其他的上下位置  位置居中*/

            text-align: center;/*水平居中*/
            line-height: 40px;/*与height相同 为垂直居中*/

            position: relative;/*子元素相对于父元素定位*/

            
        }

        .box .detail{
            display: none;/*默认隐藏*/
            position: absolute;/*定位*/
            right: -1px;/*定位 左边衔接*/
            top: 38px;

            box-sizing: border-box;/*盒子最终的宽高*/
            width: 500px;
            height: 100px;
            line-height: 100px;
            text-align: center;
            border: 1px solid lightcoral;
            z-index: -1;/*层级 默认为零 detail 是子元素 调box是一起的*/
        }
        .box:hover .detail{/*.box:hover划过事件*/
            display: block;
        }
        .box:hover{
            border-bottom-color: azure;
           /* z-index: 1;*/
        }
        /*点击实现,可用:target 实现手风琴效果*/
    </style>


</head>
<body>
    <!--基于CSS实现,需要详情区域是按钮的子元素-->
    <div class="box">
        <span>购物车</span>
        <div class="detail">
            详细信息
        </div>
    </div>
</body>
</html>

在线查看效果:https://blog.csdn.net/ResumeProject/article/details/108597174

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值