【发布时间】:2011-05-16 18:10:22
【问题描述】:
我想设置一个动态获取背景的单一 CSS 样式 来自一些 django 变量。
我认为增加的困难在于它与 a:hover 有关。
原来的静态 style.css 代码运行如下:
.titles-button h2 a {
margin-left: 4em;
margin-right: 4em;
margin-top: 1em;
margin-bottom: 1em;
display: block;
width: 240px;
height: 80px;
/* background: transparent url(../logos/djangoVX_logo.png) center left no-repeat; */
text-indent: -999em;
border: 1px dashed green;
}
.titles-button h2 a:hover {
/* background: transparent url(../logos/djangoVX_logo2.png) center left no-repeat; */
}
注意背景现在被注释了。
我想在 DIV 中使用这种样式并动态更新背景。
喜欢:
{% if the_apps_list %}
{% for apps in the_apps_list %}
<div class="titles-button">
<h2><a href="/{{ apps.app_name }}/" style="X">{{ apps.app_name }}</a></h2>
</div>
{% endfor %}
{% else %}
<p>No APPS are available. Internal Error.</p>
{% endif %}
我为“X”尽了最大努力,但没有结果。
除了: - 重写 X 中的完整样式 - 使用一些javascript花哨的东西(on_mouse_over ...) - 我什至见过一个类:inheritALL
这个解决方案都不符合我使用 django 的想法。
我可能会从错误的一方得到公牛......
..哪个是右边?
干杯 F
【问题讨论】:
-
请解释您试图实现的行为。为什么你原来的 css 不能工作?
-
原始 CSS 有效。我想做的是让 django 动态更新/刷新/覆盖背景部分。 IE。除了更新背景之外,保留样式中的所有内容。我有一个使用“onmouseover”和朋友的解决方案。但是我仍然有继承的问题。