css-content

How did CSS `content` property work for `img` element in WebKit?

天涯浪子 提交于 2019-11-29 16:42:43
问题 Long time ago there was a draft of CSS3 Generated Content spec which allowed the content property for any HTML element (not only ::before/::after pseudo-elements), without any formal restriction for empty or replaced elements. It was once supported by Opera Presto (1, 2) and, at least to some extent, by WebKit (3). By the end of 2011, WebKit's implementation of content for img element seemed to effectively convert it from an empty replaced element to non-replaced element like span (even its

Cannot change the content of visited :before pseudo-elements

痴心易碎 提交于 2019-11-29 10:38:55
I was trying to add some effects for visited links, then I got this problem. Here is the code: http://dabblet.com/gist/5447894 Only Opera can successfully change the content of :before pseudo-elements. All other browsers are fail. Did I miss anything? Thanks The allowed (= not ignored) CSS properties of visited links are color , background-color , border-*-color , outline-color and, column-rule-color (more under certain circumstances). This is to prevent history stealing attacks. See this article for further details. So you can, technically, set a :before pseudo class for :visited links, but

Add HTML tag inside CSS Content property

匆匆过客 提交于 2019-11-29 06:07:39
I'm looking for a way to add an HTML tag for CSS content property inside :after and :before . Unlike this question which only discusses adding symbols like < . What I'm trying to add is something like: .breadcrumbs li a:before { content: '<i class="icon"></i>'; } Is there any possible way to do that? This is impossible. You cannot generate markup from CSS. It should also be unnecessary - stick your background image / icon font / whatever in the generated pseudo-element you have already. This is probably what you want, To put an image to the left of your breadcrumb li links: .breadcrumbs li a:

How can I get IE8 to accept a CSS :before tag?

狂风中的少年 提交于 2019-11-28 23:41:07
I have the following CSS code .editable:before { content: url(../images/icons/icon1.png); padding-right:5px; } this is used in conjunction with the following markup: <span class="editable"></span> In every other blessed browser in the world my icon is appearing, but IE8 seems to have a problem with this. Isn't the :before pseudo-element CSS2? isn't content: also a CSS2 command? what gives? Update: I misread the page! IE 8 does support :before with images, it just doesn't when it is in IE7 compatibility mode. IE8 supports :before , but not and also images as content when not in compatibility

CSS:after encoding characters in content

帅比萌擦擦* 提交于 2019-11-28 18:33:24
I am using the following CSS, which seems to be working: a.up:after{content: " ↓";} a.down:after{content: " ↑";} The characters however cannot seem to be encoded like this, as the output is literal and shows the actual string: a.up:after{content: " ↓";} a.down:after{content: " ↑";} If I can't encode it, it feels like I should use something such as .append() in jQuery, as that supports the encoding. Any ideas? To use encoded Unicode characters in content you need to provide either the characters themselves (as you do), or their UTF-8 escape sequences instead of HTML entities: a.up:after {

Vertically aligning CSS :before and :after content [duplicate]

扶醉桌前 提交于 2019-11-28 15:42:47
问题 This question already has answers here : How do I vertically center text with CSS? [duplicate] (38 answers) Closed last month . I am trying to centre the link with the image, but can't seem to move the content vertically in any way. <h4>More Information</h4> <a href="#" class="pdf">File Name</a> The icon is 22 x 22px .pdf { font-size: 12px; } .pdf:before { padding:0 5px 0 0; content: url(../img/icon/pdf_small.png); } .pdf:after { content: " ( .pdf )"; font-size: 10px; } .pdf:hover:after {

Is it possible to use CSS Custom Properties in values for the content property?

三世轮回 提交于 2019-11-28 05:49:31
问题 Example: :root { --PrimaryThemeColor: #3acfb6; /* with or without quotes */ } .ColorSwatch:after { content: var(--PrimaryThemeColor); } When this is rendered, the computed CSS is literally that value. content: var(--PrimaryThemeColor); Even if I'm using a post-processor that injects the computed value as a fallback, the value itself isn't a string, so it's invalid for content . .ColorSwatch:after { content: #3acfb6; content: var(--PrimaryThemeColor); } 回答1: The value of the custom property

Cannot change the content of visited :before pseudo-elements

不打扰是莪最后的温柔 提交于 2019-11-28 04:05:13
问题 I was trying to add some effects for visited links, then I got this problem. Here is the code: http://dabblet.com/gist/5447894 Only Opera can successfully change the content of :before pseudo-elements. All other browsers are fail. Did I miss anything? Thanks 回答1: The allowed (= not ignored) CSS properties of visited links are color , background-color , border-*-color , outline-color and, column-rule-color (more under certain circumstances). This is to prevent history stealing attacks. See

'content' attribute to inherit node value

若如初见. 提交于 2019-11-28 01:50:47
Is there a way to inherit node value into content attribute? Like, if <h2/> tag value is set to "Random title", can I get this value inside content attribute in CSS? I've tried content: inherit; , but it doesn't seem to work. An example of my theory: HTML: <h2>Random title</h2> CSS: h2:after { content: inherit; /* should be "Random title" */ } Thanks in advance! No, there's no way to do that. That's not what inherit is for . The closest you can get is this: <h2 data-title="Random title">Random title</h2> h2:after { content: attr(data-title); } ..which is obviously horrible because of the

after pseudo element not appearing in code [duplicate]

自古美人都是妖i 提交于 2019-11-27 15:29:44
This question already has an answer here: Why do the :before and :after pseudo-elements require a 'content' property? 4 answers I'm trying to use the after pseudo element to add some effects to a site. <div class="product-show style-show"> <ul> <li> .... <div class="..."> <div class="readMore less">...</div> <a href="3" class="readMoreLink" onclick="return false;">Read More</a> </div> .... </li> </ul> </div> And stylesheets: .product-show .readMore.less { max-height: 200px; height: 100%; overflow: hidden; } .product-show .readMore.less:after { background: rgba(255, 255, 255, 0); display: block