text-align:center+inlineblock 無效
vscode里面用text-align:center+inlineblock 無效,代碼如下,請(qǐng)問可以幫我看下問題在哪嗎?
<!DOCTYPE?html>
<html?lang="en">
<head>
????<meta?charset="UTF-8">
????<meta?name="viewport"?content="width=device-width,?initial-scale=1.0">
????<title>水平居中的布局方案1</title>
????<style>
????????#parent?{
????????????border:?1px?solid?red;
????????????border-radius:?0.5em;
????????????width:?200px;
????????????height:?200px;?text-align:?center;
????????}
????????#child?{
????????????background-color:?yellow;
????????????width:?50px;
????????????height:?50px;
????????????display:?inline-block;
????????}
????</style>
</head>
<body>
????<!--?1.text-align?center+inline?block實(shí)現(xiàn)?-->
????<div?id="parent">
????????<div?id="child">?123
????????</div>
????</div>
</body>
</html>
2020-05-19
我復(fù)制過來后,看到你的 #parent 的 height:200px后面的分號(hào)是錯(cuò)誤的,改成英文的分號(hào)就好了。