我试图找到一些有关content:css中各种可能的属性用途的最新信息 ,但只能找到2004年orso的网络古人地牢中的内容,所以我想我必须再次在2011年问这个:
p:before {
content: url(dingdong.png);
}
p:before {
content: "some text ";
}
Run Code Online (Sandbox Code Playgroud)
我对:before选择器和content:属性都很新,并且在这个问题上偶然听到了这个问题,一位可爱的女士非常有创意地回答了这个问题:
如何在不使用任何图像或span标签的情况下通过CSS在UL/LI html列表中设置Bullet颜色
只是发现有关内容的实际编码可能会出现一些问题:
li:在{content:"■"之前; 如何在电子邮件文具中将这个特殊字符编码为Bullit?
所以我的具体问题是:除了url()和"text",是疗法其他的可能性?
非常感谢您的建议和想法.
我拼凑了这个jQuery函数.它的目的是计算内部所有img元素的边距,div.article以便平衡图像的高度与文档的基线网格,为20像素.为了匹配我的基线网格,每个图像高度应为20的倍数.如果不是这种情况,例如一个图像的高度为154像素,则该函数会为img添加6 px的余量,以便与基线平衡网格已恢复.
该函数正常工作,所以我的实际问题是:由于我不是程序员,我想知道我的代码是否非常糟糕,虽然它正在工作,如果是这样,代码如何改进?
jQuery代码:
$('div.article img').each(function() {
// define line height of CSS baseline grid:
var line_height = 20;
// capture the height of the img:
var img_height = $(this).attr('height');
// divide img height by line height and round up to get the next integer:
var img_multiply = Math.ceil(img_height / line_height);
// calculate the img margin needed to balance the height with the baseline grid:
var img_margin = (img_multiply * line_height) - img_height;
// if …Run Code Online (Sandbox Code Playgroud)