4-4案例应用?

来源:4-6 案例应用

qq_找回我丢失的记忆_0

2017-12-05 15:49:04

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>实例应用</title>

<style type="text/css">

*{margin: 0px;padding: 0px;}

.center{width: 200px;margin: 0px auto;text-align: center;}

.one{width: 100%;

background: black;

color: white;

font-family: "微软雅黑";

font-weight: bolder;

font-size:20px;

   height: 100px;

   line-height: 100px;}

        .two{background: #f0f4f5;padding: 15px;}/**/

        .p1{border-bottom:1px solid gray;

         font-family: "微软雅黑";line-height: 1.5em;}

        span{font-family: none;font-size: 15px;}

        .p2{border: none;}

</style>

</head>

<body>

<div class="center">

<div class="one">前端课程排列</div>

<div class="two">

<p class="p1">HTML+CSS基础课程

<span>456695人在学</span>

            </p>

<p class="p1">HTML+CSS基础课程

<span>456695人在学</span>

            </p>

            <p class="p1 p2">HTML+CSS基础课程

<span>456695人在学</span>

            </p>

</div>

</div>

</body>

</html>

为什么我在two那里设置了padding,整体没有发生变化,反而是内容缩小了

写回答

1回答

怎么都被占用了呢

2017-12-05

因为two元素没有固定的宽度,所以padding和内容会自适应在父元素内的大小,你给two元素设置一个宽度,例如width:100%,就能看出来差别了

0
hq_找回我丢失的记忆_0
h 非常感谢!
h017-12-05
共1条回复

0 学习 · 36712 问题

查看课程

相似问题

4-4案例应用

回答 1

4-4案例应用

回答 2

4-4案例应用

回答 1

4-4案例应用

回答 1

4-4案例应用

回答 1