<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>内联块状元素</title>
<style type="text/css">
div,p{background:pink;}
div1{display:block;}
</style>
</head>
<body>
<div>div1</div>
<div>div2</div>
<p>段落1段落1段落1段落1段落1</p>
</body>
</html>
p本身就是块状元素啊 为什么要改变。
我的理解是设置的不应该是文本内容,而是标签名<div1>,代码如下
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>内联块状元素</title>
<style type="text/css">
div,p,div1{background:pink;}
div1{display:block;]
</style>
</head>
<body>
<div>div1</div>
<div>div2</div>
<div1>div3</div1>
<p>段落1段落1段落1段落1段落1</p>
</body>
</html>
1、css选择器没有选中div;
2、改正后代码如下:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>内联块状元素</title>
<style type="text/css">
div,p{background:pink;}
#div1{display:block;}
</style>
</head>
<body>
<div id="div1">div1</div>
<div>div2</div>
<p>段落1段落1段落1段落1段落1</p>
</body>
</html>