定位

<!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>
        * {
            margin: 0;
            padding: 0;
        }

        body {
            background-color: #f5f5f5;
        }

       

        .box {
            width: 960px;
            margin: 20px auto;
            background-color: aquamarine;

        }

        .box li {
            float: left;
            margin-right: 15px;
            width: 180px;
            background-color: antiquewhite;
            position: relative;
            
        }

        .box li h3{
            padding: 10px 15px;
            
        }
        .box li p{
            padding: 10px 20px;
        }

        .box li p span{
            color: red;
        }

        .box li .hot{
            position: absolute;
            top: 5px;
            right: -4px;
            width: 40px;
            height: 24px;
        }

        .box-1 {
            width: 1200px;
            height: 800px;
            margin: 0 auto;
            background-color: cadetblue;
        }

        .clearFix::after {
            content: '';
            display: block;
            clear: both;
        }
    </style>
</head>

<body>
  
    <div class="box clearFix">
        <ul>
            <li>
                <a href="#">
                    <img src="./html+css/study/c-pic3.png" alt="">
                    <h3>Python高级课程Python高级课程qqqqPython高级课程</h3>
                    <p><span>高级</span>  *副标题 </p>
                    <img src="./html+css/study/hot.png" alt="" class="hot">
                </a>
            </li>
            <li>
                <a href="#">
                    <img src="./html+css/study/c-pic3.png" alt="">
                    <h3>Python高级课程Python高级课程qqqqPython高级课程</h3>
                    <p><span>高级</span>  *副标题 </p>
                    <img src="./html+css/study/hot.png" alt="" class="hot">
                </a>
            </li>
            <li>
                <a href="#">
                    <img src="./html+css/study/c-pic3.png" alt="">
                    <h3>Python高级课程Python高级课程qqqqPython高级课程</h3>
                    <p><span>高级</span>  *副标题 </p>
                    <img src="./html+css/study/hot.png" alt="" class="hot">
                </a>
            </li>
        </ul>
    </div>


</body>

</html>

 

hot 的定位  子元素绝对定位, 父元素相对定位  。

效果为 

 

 

posted on 2022-09-30 20:46  totau  阅读(29)  评论(0编辑  收藏  举报

导航