您现在的位置:首页 >> 前端 >> 内容

a标签突出显示盒子非js效果

时间:2017/8/11 9:46:00 点击:

  核心提示:鼠标放在相应的标题上,显示对应的盒子!DOCTYPE htmlhtmlheadmeta charset=utf-8title/titlestyle.box{width: 300px;height: 3...

鼠标放在相应的标题上,显示对应的盒子

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
<title></title>
<style>
    .box{
        width: 300px;
        height: 300px;
        position: relative;
        border: 1px solid #000;
    }

    ul li{
        list-style: none;
        float: left;
        display: block;
    }

    .box1{
        width: 200px;
        height: 200px;
        background-color: red;
        position: absolute;
        left: 40px;
        top: 40px;
        display: none;
    }

    .box2{
        width: 200px;
        height: 200px;
        background-color: blue;
        position: absolute;
        left: 40px;
        top: 40px;
        display: none;
    }

    ul li:first-child:hover .box1{
        display: block;     //鼠标移上对应li显示盒子
    }
    ul li:nth-child(2):hover .box2{
        display: block;
    }
</style>
</head>
<body>
<p class="box">
    <ul>
        <li>
            点击显示1
            <p class="box1"></p>
        </li>
        <li>
            点击显示2
            <p class="box2"></p>
        </li>
    </ul> 
</p>
</body>
</html>

 

作者:网络 来源:kuke_kuke的