pseudo-element

Is it possible to write one CSS rule for several prefixed selectors?

前提是你 提交于 2019-12-04 04:10:24
问题 See answer for this question. I write CSS rule: ::-webkit-input-placeholder,:-moz-placeholder,::-moz-placeholder,:-ms-input-placeholder { color: #999; } So firefox can not recognize its elements (-moz-placeholder and -moz-placeholder). Why? It is possible to write all this pseudo element in one CSS rule? 回答1: Short answer: no. This behaviour is accordance with the W3C spec (see 4.1). That is if any selector list contains one or more selectors that are invalid, the entire selector list is

What is the ::before or ::after expression, and why is it shown in the browser developer tools?

十年热恋 提交于 2019-12-04 04:09:11
问题 I have read ::before is used to add content before the element you use it with, e.g. p::before { content: "Read this: "; } but most of the times I have seen (peeking at web pages through developer tools) they use them without any element, e.g. <div class="btn-toolbar" role="toolbar"> ::before <div class="btn-group"> <button type="button" class="btn btn-default"><span class="glyphicon glyphicon-align-left"></span></button> <button type="button" class="btn btn-default"><span class="glyphicon

On hovering one pseudo element, make the other pseudo element appear?

一世执手 提交于 2019-12-04 03:19:21
I was trying to generate a screen in which utilises the :before and :after pseudo elements, but I'm wondering if such functionality is actually possible. I have a wrapper div which is wrapped around an input (allowing for pseudo element s on this wrapper). something like: +-----------------------------------+ | +-------------------------------+ | | | | | <-- wrapper div | +-------------------------------+ <-- input element +-----------------------------------+ However, I was looking to have a pseudo element positioned after the div. +-----------------------------------++-------+ | +-----------

Same specificity, after taking placement into consideration, :first-letter always wins?

梦想与她 提交于 2019-12-04 02:21:19
Take a look at this jsfiddle: http://jsfiddle.net/ZNddz/ .intro:first-letter { font-size: 130px; } span.letter { background-color: red; font-size: 30px; } p { font-size: 80px; } The first rule consist of one class selector and one pseudo-element selector = 11 The second rule consist of one class selector .letter and one tag selector span = 11 Both rules have same specificity so it is reasonably to believe that the winner should be the last style. Obviously it is not the case. So I decided to add a background-color property to the second rule and as you can see it has a height of 30px. I deduce

How can the pseudo element detect the height of the non-pseudo element?

时光毁灭记忆、已成空白 提交于 2019-12-04 00:16:40
Please see http://jsfiddle.net/ZWw3Z/ <p>Text text text text text text text...</p> p { background-color: blue; } p:before { content: ''; position: absolute; width: 10px; height: 100%; background-color: red; } Essentially, the height of the pseudo element is too big. I want it to have the same height as the p element. How can I do that? To future readers, the effect was to have a bar appear over text on the left-hand side. To accomplish this, the OP was using position: absolute; on the psuedo element ( p:before ). The error OP was encountering was because the psuedo-element was treating the

CSS ::before ::after pseudo-element of class not working

旧街凉风 提交于 2019-12-04 00:07:37
I am trying to add a ::before and ::after pseudo-element to a menu heading. The pseudo-elements work fine for a regular link outside of the menu. However, when I am trying to apply them to a menu item, the background property is set, but the ::before and ::after properties are not. Here is the relevant CSS: #cssmenu { background-color: #FFFFCC; clear: both; display: inline; float: left; list-style: none; overflow: hidden; text-align: center; text-transform: uppercase; width: 100%; } #cssmenu li { display: inline-block; } #cssmenu li a { display: inline-block; } #cssmenu li ul { /*margin-top:

Add onclick with css pseudo-element after

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 22:06:13
Is it possible in my css file to do something like that?: .myclass:after{ content:"click me"; onclick:"my_function()"; } I want to add after all instances of myclass a clickable text, in the css style sheet. Is it possible in my css file to do something like [see code above]? No The important question to ask is why . HTML has control of the data within the webpage. Any CSS or JS is specified via the HTML. It's the Model . CSS has control of the styles , there is no link between CSS and HTML or JavaScript. It's the View . JavaScript has control of the interactions within the webpage, and has

How to get a DOM element's ::before content with JavaScript?

扶醉桌前 提交于 2019-12-03 17:00:38
问题 I want to know whether it is possible to get a DOM element's ::before content, which was set by CSS3. I have tried some ways, but I still can't make it, so it's very confusing to me! // https://rollbar.com/docs/ const links = document.querySelectorAll(`ul.image-list a`); links[0]; // <a href="/docs/notifier/rollbar-gem/" class="ruby">::before Ruby</a> links[0]; // links[0].textContent; //"Ruby" links[0].innerText; // "Ruby" links[0].innerHTML; // "Ruby" // ??? links[0]::before; This is the

Transition only for the border on hover, but not for background

我只是一个虾纸丫 提交于 2019-12-03 16:26:59
问题 Here I have some CSS: #image-edges-beneath:hover{ background-color: blue; } #image-edges:hover{ background-color: blue; } #image-edges-beneat:hover:after{ -webkit-transition: all 1s ease; -moz-transition: all 1s ease; -o-transition: all 1s ease; -ms-transition: all 1s ease; transition: all 1s ease; border: 2px solid #F1FD6D; } #image-edges:hover:after{ -webkit-transition: all 1s ease; -moz-transition: all 1s ease; -o-transition: all 1s ease; -ms-transition: all 1s ease; transition: all 1s

Why do I need an empty `content` property on an ::after pseudo-element? [duplicate]

丶灬走出姿态 提交于 2019-12-03 14:48:56
问题 This question already has answers here : Why do the :before and :after pseudo-elements require a 'content' property? (4 answers) Closed 3 years ago . I got http://jsfiddle.net/8p2Wx/2/ from a previous question I asked and I see these lines: .cf:before, .cf:after { content:""; display:table; } .cf:after { clear:both; } If I take away content:"" , it ruins the effect, and I don't understand why it's necessary. Why is it needed to add an empty content to :after and :before pseudo-elements? 回答1: