私はRuby-on-Rails3.2.1に取り組んでいます。私はDOM構造に従っています。
更新:Gaby</img>
が言及したタグを削除しました。問題はまだ解決していません。
<div class="frame">
<img src='SOME_PATH' class="frame-image">
</div>
そしてCSSをフォローする
.frame { position:relative;border:1px solid #CCC;border-radius:2px;-moz-border-radius:2px; }
.frame:before
{
position:absolute;
content:'';
border:2px solid #F2F2F2;
height:100%;width:100%;
box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
}
img.frame-image /* IT WON't BE APPLIED?! */
{
min-width:30px;min-height:30px;
max-width:200px;max-height:200px;
}
私が直面している問題は、適用されたCSSが機能しimg.frame-image
ていない/適用されていないことです。Chrome18とFireFox12を試してみました。Chromeの要素インスペクターまたはFireBugにスタイルが表示されません。また、他のCSSによって上書きされることもありません。
デモでは、このためにjsfiddleを作成しようとしました。そこで動作します!
しかし、驚くべきことに、img.frame-image
CSSの上に.frame:before
CSSを書くと、うまくいきます!!
.frame { position:relative;border:1px solid #CCC;border-radius:2px;-moz-border-radius:2px; }
img.frame-image /* NOW IT WILL BE APPLIED */
{
min-width:30px;min-height:30px;
max-width:200px;max-height:200px;
}
.frame:before
{
position:absolute;
content:'';
border:2px solid #F2F2F2;
height:100%;width:100%;
box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
}
なぜそれが起こっているのか考えていますか?フレームワーク(RoR)関連の問題ですか、それともCSSセマンティクスですか?