[英]Margin works normally when inline but doesn't work in css rules
When I write something like: 当我写类似的东西时:
<table style="margin-left: 30px;" >
</table>
or: 要么:
<div style="margin-left: 30px;">
<h:commandButton value="add" action="a"></h:commandButton>
<h:commandButton value="cancel" action="b" immediate="true"></h:commandButton>
</div>
The margin shows up properly. 边距显示正确。
But when I write: 但是当我写:
<table class="marg" >
</table>
or: 要么:
<div class="marg">
<h:commandButton value="add" action="a"></h:commandButton>
<h:commandButton value="cancel" action="b" immediate="true"></h:commandButton>
</div>
With this rule: 使用此规则:
.marg {
margin-left: 50px;
margin-top: 30px;
}
HTML generated code: HTML生成的代码:
<table class="marg">
</table>
<div class="marg">
<input id="j_id1109917403_4227fec1:j_id1109917403_4227feb3" type="submit" value="add" name="j_id1109917403_4227fec1:j_id1109917403_4227feb3">
<input id="j_id1109917403_4227fec1:j_id1109917403_4227feae" type="submit" value="cancel" name="j_id1109917403_4227fec1:j_id1109917403_4227feae">
</div>
The table and button display without margin. 表格和按钮显示为无边距。 Why ?
为什么呢
Test if the CSS rule is applied by adding a background-color
: 通过添加
background-color
测试是否应用了CSS规则:
.marg { margin-left: 50px; margin-top: 30px; background-color: pink; }
If yes, then add !important
to your existing instruction for testing purpose: 如果是,则在您现有的说明中添加
!important
以进行测试:
.marg { margin-left: 50px !important; margin-top: 30px !important; background-color: pink; }
Is your CSS applied? CSS是否适用? Does
!important
change something? !important
更改吗? What do you see in Firebug? 您在Firebug中看到了什么? Come back with a fiddle (without CSS reset!) if you still have a problem: HTML and CSS code can help us to understand your problem;
如果您仍然有问题,请来个小提琴(无需重置CSS!):HTML和CSS代码可以帮助我们了解您的问题; back-end code that generates HTML doesn't
生成HTML的后端代码不会
Oh, please sorry, it was my very stupid mistake. 哦,对不起,这是我非常愚蠢的错误。 I forget to add in HTML :
我忘了添加HTML:
<link rel="stylesheet" type="text/css" href="style/myCSS.css" media="all" />
I thought that I added it. 我以为我添加了它。
.marg css类的左边距设置为50px,这与属性内部的设置为30px不同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.