Selecting first child within content

50 views
Skip to first unread message

Don Olmstead

unread,
Jun 22, 2014, 2:31:44 PM6/22/14
to polym...@googlegroups.com
I have a component where I have an image absolutely positioned in the upper right corner like the following.
    
+-----------------------+---+
|     :first-child      | I |
+-----------------------+---+
|  rest of the content      |
+---------------------------+

I'd like to be able to apply a margin on the right to the first child of the content area so it doesn't bleed into the area taken up by the image. I was trying the following CSS which doesn't give me the behavior I was hoping for.

polyfill-next-selector {
  content: ':first-child'; }

::content:first-child {
  margin-right: 44px; }

I can work around it by giving a different class to the first element, but I figured I'd ask if I'm doing something wrong or if there's even support for pseudo elements within the <content> tag.

Thanks!

Rob Dodson

unread,
Jun 22, 2014, 2:36:27 PM6/22/14
to Don Olmstead, polymer-dev
I think you need a space between ::content and :first-child

http://jsbin.com/jaluh/2/edit


Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/a39b7cf2-05e9-4de6-81ae-429637f176c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Don Olmstead

unread,
Jun 22, 2014, 2:45:25 PM6/22/14
to polym...@googlegroups.com, don.j.o...@gmail.com
Hey Rob. I had given that a go earlier but it ends up going into the tree.

<p>Bar<span>Test<span></p>

So if you modify your example to look like this. Then Test will also be red.

Rob Dodson

unread,
Jun 22, 2014, 3:04:50 PM6/22/14
to Don Olmstead, polymer-dev
Hm, maybe I'm not understanding the issue. In the example you just shared, Test will be red because it's inheriting the color of its parent element.

Here's a more fleshed out example based on your diagram:
http://jsbin.com/waxis/3/edit

Is that closer to what you're trying to achieve?


Follow Polymer on Google+: plus.google.com/107187849809354688692

---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages