我在 wordpress 上做一个主题,创建了一个名为 newpage-template.php 的页面模板,代码如下:
<div class="akmos">
<img src="<?php echo get_bloginfo('template_url') ?>/imagens/banner-akmos.png">
</div>
但是左边和上面有一个空隙(但右边没有),就像你在这里看到的:
我的这个页面的 CSS 是:
<?php /* Template Name: Stuff */ ?>
.akmos {
height: 500px;
}
.akmos img {
width:100%
}
我已经设置了 margin:0,但它不起作用。
body {
margin:0 !important;
}
最奇怪的是我不能通过css改变图像的大小,它不起作用。例如,如果我尝试将它的宽度设置为 400px,它就不会改变。这让我相信问题出在 php 上,但我不确定。如何解决?
最佳答案
.akmos img
的 width:100%
不起作用的原因是您没有在父 div 中声明宽度,即.akmos
。我建议在 .akmos
中设置维度并告诉 .akmos img
遵循父属性:
.akmos {
position:fixed;
top:0;margin-top:0px;
left:0;margin-left:0px;
width:100%;
height:500px;
}
.akmos img {
width:100%;
height:100%;
}
看看这是否有效:)
关于php - 页面左侧和顶部有一个空白,背景在 wordpress 上没有改变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56613329/