一个id的边距属性有效,但其他id的边距属性无效[重复] 。

问题描述 投票:0回答:1

Welcome-section id的所有属性都能正常工作。当我将同样的属性应用于另一个id,project1时,margin属性完全不起作用。请指导我做错了什么。

#main {}

#project1 {
  background-color: rgba(235, 232, 223, 1);
  margin-top: 1000px;
  height: 2500px;
}

#welcome-section {
  background-color: rgba(214, 210, 197, 0.7);
  margin: 25px 25px 25px 25px;
  text-align: center;
  height: 50px;
  font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
  vertical-align: middle;
  display: table-cell;
  width: 850px;
  font-size: 120%;
  font-weight: bold;
  color: ;
  border-style: dotted;
  border-color: blue;
  text-shadow: 2px 2px 5px powderblue;
}
<body id='main'>
  <header>
    <navbar id='nav-bar'></navbar><br>
    <h1 id='welcome-section'>
      How can I help your business grow?</h1>
  </header>
  <br>
  <projects id='projects'>
    <project1 id='project1'>
      <projectt id='prjctt'>Desalination in Balochistan</projectt>
      <proimg id='proimg'></proimg>
    </project1>
  </projects>
</body>

你可以在这里看到它。

https:/codepen.iowajierajapenLYpJLqY。

html css margin
1个回答
0
投票

在你的css中添加display:flex

 #project1 {
  background-color: rgba(235, 232, 223, 1);
  margin-top: 1000px;
  height: 2500px;
  display:flex;
}
© www.soinside.com 2019 - 2024. All rights reserved.