0

How to apply style before child element with some specific class? What i want is something like:

<div class="parent">
   <div></div>
   <!-- Here should be pseudo  element -->
   <div class="apply-me"></div>
   <div></div>
</div>

here style should be applied to :before pseudo element of div with class "apply-me".

Update: I want to apply styles before div, not before content of the div. This is not what I want to get in final:

<div class="parent">
   <div></div>

   <div class="apply-me">
     ::before
     <span>Content</span>
   </div>
   <div></div>
</div>
Rayz
  • 523
  • 1
  • 4
  • 19
  • You want to apply the style on the piece of text "::before"?? And not on the children?? Do I understand correctly? – GreyRoofPigeon Jul 10 '15 at 09:43
  • Well :before pseudo elements inserted into content. Is there way to apply some styling before element, not its content? – Rayz Jul 10 '15 at 09:46
  • What do you mean by "before element"??? What is before the element? The other div?? – GreyRoofPigeon Jul 10 '15 at 09:47
  • Sorry but your question is misunderstood. What exactly are you trying to style? – m4n0 Jul 10 '15 at 09:49
  • With .apply-me::before the style will be applied for element before the content of the div, is there any way to apply the styles with the same way but for the div, not the content. – Rayz Jul 10 '15 at 09:59
  • You can't just add a div before the required class? – m4n0 Jul 10 '15 at 09:59
  • 2
    You cannot apply style to previous element unless it is CSS4. – m4n0 Jul 10 '15 at 10:02
  • I find *style should be applied to :before pseudo element of div with class "apply-me"* and *I want to apply styles before div, not before content of the div* a bit contradictory. Can you maybe show an example of what you are trying to achieve? – Harry Jul 10 '15 at 11:19

0 Answers0