2013-08-27 32 views
0

考慮下面的代碼:調整在CSS中reccuring數字財產的價值,而不是覆蓋它的

[example.htm] 
<link rel="stylesheet" src="myStyle.css" /> 
<style> 
    div {margin-left: 100px} /* let's assume this margin value is dynamically generated in PHP/ASP/JSP and we dont't have control over it */ 
</style> 
<body> 
    <div>foo</div> 
    <div class="indent-me-more-please">bar</div> <!-- let's assume we don't have control over this part, either --> 
</body> 

[myStyle.css] 
.indent-me-more-please {margin-left: * !important} 

是否有可能設定臨界值(標記爲*)總是比僅在<style>標籤中設置的值的值大50px或例如在元素屬性?在這種情況下:100px + 50px = 150px。像「margin-left += 50px;」這樣的東西打電話,我不知道,相對增值?

是否有可能在純CSS中做到這一點?

+0

您提到'margin-left + = 50px;',這可以與jQuery一起使用,並且會被認爲是正確的方法。 – Vector

回答

0

CSS不支持。

在您的特定示例中,您可以使用padding-left添加更多空間。

0

這需要不同類型的語言像上海社會科學院http://sass-lang.com/在青菜,你可以添加變量,例如

$margin-left: 50px; 
#container{ 
margin = $margin-left + 10px; 
} 

而是要用你需要準備你的服務器爲它青菜......