【发布时间】:2021-12-21 01:48:06
【问题描述】:
元素不会以我的 div 为中心,尽管我已经尝试了所有可能的方法(或者至少我决定最终创建一个 Stack Overflow 帐户)方法来修复它
它们以 PC 为中心,但不适用于移动设备。我已经在 CSS 中定义了这个
.page_content {
background: linear-gradient(90deg, rgba(94, 182, 86, 1) 48%, rgba(121, 230, 111, 1) 100%);
padding: 20px;
width: 100%;
height: 100%;
text-align: center;
margin: auto;
justify-content: center;
top: 0;
bottom: 0;
right: 0;
left: 0;
position: fixed;
}
<body style="color: #efefef">
<div class="page_content">
<h1>Home page</h1>
<button class="button" onclick="testFunction()">Example</button>
<h1>Buttons</h1>
<button class="button" onclick="testFunction1()">btn 1</button>
<br>
<br>
<button class="button" onclick="testFunction2()">btn 2</button>
</div>
</div>
</body>
提前谢谢你
【问题讨论】:
-
尝试删除
padding: 20px;或将其设置为padding: 20px 0;