把下面的盒子用css代码写出来

html-css016

把下面的盒子用css代码写出来,第1张

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html charset=utf-8" />

<title>~\(≧▽≦)/~</title>

<style type="text/css">

*{padding:0margin:0list-style:nonetext-decoration:none}

.box{width:390pxheight:400pxbackground-color:#f6f6f6position:relative}

.hot{width:54pxheight:23pxposition:absoluteleft:0top:0background:url(hot.jpg) no-repeat}

.box li{width:100%border-top:1px solid #f9f9f9border-bottom:1px solid #fdfdfdpadding:35px 0 20px 0px}

.box li a{font-family:"微软雅黑"color:#767676display:blockmargin-left:15px}

.box li p{width:180pxoverflow:hiddenwhite-space:nowraptext-overflow: ellipsismargin-top:5pxmargin-left:15pxfont-family:"微软雅黑"font-size:14pxcolor:#767676float:left}

.box li span{color:#999999font-family:"微软雅黑"font-size:12pxdisplay:blockmargin-left:320pxmargin-top:5px}

  </style>

 </head>

 <body>

<div class="box">

        <ul>

            <li><i class="hot"></i>

                <a href="" class="title" style="color:#F00">摄影师资格证报名开始啦!</a>

                <p>不单单只是摄影师需!(第几个)</p><a href=""><span>[详细]</span></a>

            </li>

            <li>

                <a href="" class="title">星空星轨拍摄方法、后期合成技术</a>

                <p>这个视频是前些时间拍的</p><a href=""><span>[详细]</span></a>

            </li>

            <li>

                <a href="" class="title" style="color:#f9be54">“去哪拍”专区开放啦!</a>

                <p>这个视频是前些时间拍的</p><a href=""><span>[详细]</span></a>

            </li>

            <li>

                <a href="" class="title">自制波点散景墙</a>

                <p>一般来说说说说试试自制波点散景墙</p><a href=""><span>[详细]</span></a>

            </li>

        </ul>

    </div>  

</body>

</html>

整个文档粘这了,我是个新手,可能有很多不规范的写法,凑合看吧,就当抛砖引玉了...

--定义样式 border-style:

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title>菜鸟教程(runoob.com)</title>

<style type="text/css">

    .block {

      width: 200px

  height:200px

      padding: 30px

  background-color: red

  border-style:solid

  border-width:10px

  border-color:green

  //border:10px solid yellow

  //border-radius: 20px

  //margin:auto

    }

</style>

</head>

<body>

    <div class="block">border</div>

</body>

</html>

--兄弟元素margin合并

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <title>Title</title>

    <style type="text/css">

        body {

            background: pink

        }

        .div {

            //overflow: hidden

            //margin: 0 auto

            width: 300px

            height: 600px

            background: #aaa

        }

        .div1 {

            width: 200px

            height: 200px

            background: red

            //margin: 50px 0px

            //float: left

        }

        .div2 {

            width: 200px

            background: green

            //margin: 50px 0px

            height: 200px

            //float: left

        }

    </style>

</head>

<body>

    <div class="div">

        <div class="div1"></div>

        <div class="div2"></div>

    </div>

</body>

</html>

----父子元素margin合并

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title>菜鸟教程(runoob.com)</title>

<style type="text/css">

        body {

            background: pink

        }

        .div1 {

            //margin-top: 20px

            width: 450px

            height: 450px

            background: #aaa

//overflow:hidden

//border:1px solid red

        }

        .div2 {

            width: 200px

            height: 200px

            background: red

            //margin-top: 50px

        }

    </style>

</head>

<body>

    <div class="div1">

        <div class="div2"></div>

    </div>

</body>

</html>

--box-sizing

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title>菜鸟教程(runoob.com)</title>

<style type="text/css">

.group {

      /* background-color: blue*/

      overflow: hidden

  }

    .block {

      width: 33.33%

      padding: 20px

      float: left

      //box-sizing: border-box

    }

    .red {

      background-color: red

//box-sizing: conten-box

//overflow: hidden

//outline:#00FF00 dotted thick

    }

    .green {

      background-color: green

    }

    .gray {

      background-color: gray

//box-sizing: border-box 

    }

</style>

</head>

<body>

<div class="group">

    <div class="block red">1</div>

    <div class="block green">2</div>

    <div class="block gray">3</div>

</div>

</body>

</html>

--盒子显示(display)类型

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title>菜鸟教程(runoob.com)</title>

<style>

.background{

background-color:#F60

margin-bottom:5px

margin-left:5px

height:50Px

}

.display1{

display:block

}

.display2{

display:inline

//display:inline-block

}

</style>

<div class="background ">Div默认为 block</div>

<div class="background ">Div默认为 block</div>

<div class="background ">Div默认为 block</div>

<div class="background display2">修改为 inline</div>

<div class="background display2">修改为 inline</div>

<div class="background display2">修改为 inline</div>

<span class="background display1">加了block属性</span>

<span class="background display1">加了block属性</span>

<span class="background display1">加了block属性</span>

<span class="background">没加block属性</span>

<span class="background">没加block属性</span>

<span class="background">没加block属性</span>

</body>

</html>