我不确定为什么我会在右侧显示一个空格。这是我的简单代码
<body>
<div data-role="page" id="splash">
<div data-role="content">
<p class="loading">loading...</p>
</div><!-- /content -->
</div><!-- /page -->
</body>
的CSS
#splash {
background: #9d0104 url(../images/logo.png) no-repeat center 30%;
background-size: 182px;
}
#splash .loading {
text-align: center;
color: #fff;
width: 100%;
position: absolute;
top: 75%;
background: #ff0000 url(../images/loading.png) no-repeat center top;
padding-top: 20px;
}
这是屏幕截图
最佳答案
您将必须在左右两侧设置相等的边距:
#splash .loading { margin:0 20px; }
上方将
20px
边距设置为左侧和右侧。或者由于使用的是
absolute
位置,因此可以使用right
属性将其向左移动一点,以满足您的需求,例如:#splash .loading { right:10px; }
关于css - 为什么在段落的右侧有多余的空间?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9408331/