沐雨尘枫 发表于 2022-9-9 15:58:12

为什么改px的数值没有

<!DOCTYPE html>
<html>
<head>
<link rel="shortcut icon" href="">



<title>无限资源</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="keywords" content="">
<meta name="description" content="最简易网站">
<meta name="author" content="">
<style>
div{display:inline;
                   }
.h1{height:600px;
             width: 500px;
                     border: 3px dotted green;}
.h2{background: url("   ")
         height:600px;
             width: 500px;
               border: 3px dotted green;}
</style>
</head>
<boby>
<div class="h1"><a href="   " target="      ">娱乐</a></div>
<div class="h1"><a href="   " target="      ">娱乐</a></div>
<div class="h1"><a href="   " target="      ">娱乐</a></div>
<br>
<div class="h1"><a href="   " target="      ">娱乐</a></div>
<div class="h1"><a href="   " target="      ">娱乐</a></div>
<div class="h1"><a href="   " target="      ">娱乐</a></div>
<br>
<div class="h1"><a href="   " target="      ">娱乐</a></div>
<div class="h1"><a href="   " target="      ">娱乐</a></div>
<div class="h1"><a href="   " target="      ">娱乐</a></div>
</boby>
</html>

Twilight6 发表于 2022-9-9 21:09:47



因为 div 这个块元素被你设置为 inline 行内元素了

行内元素不能设置宽高,它是通过内部内容来撑开的

沐雨尘枫 发表于 2022-9-10 14:16:40

Twilight6 发表于 2022-9-9 21:09
因为 div 这个块元素被你设置为 inline 行内元素了

行内元素不能设置宽高,它是通过内部内容来撑开 ...

有办法强制吗
做个九宫格而已

dolly_yos2 发表于 2022-9-10 16:22:04

沐雨尘枫 发表于 2022-9-10 14:16
有办法强制吗
做个九宫格而已

做九宫格可以考虑用 display: grid
详细可以到 MDN 上找参考和文档
页: [1]
查看完整版本: 为什么改px的数值没有