Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculating an element's position within a <p>

Tags:

css

Is it possible to calculate if an element is at the start of a new line within a <p>? For example take a look at this screenshot:

enter image description here

You'll see that the Twitter button has a slight margin to it. This is fine when it's following a word, but I was wondering if there was a hidden CSS gem that'd allow me to say "if you're the first 'thing' on a line then lose your margin-left".

like image 443
Ahmed Nuaman Avatar asked May 15 '26 04:05

Ahmed Nuaman


1 Answers

Edit: The answer was p button:first-child or p > button, but neither work. See the comments.

You might want to set the margin to 0 all the time and then make sure the button always has a space before it. (Edit: won't work either, since a space is not enough. Again, see the comments.)

like image 129
Mr Lister Avatar answered May 19 '26 02:05

Mr Lister



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!