Pure CSS Animated 3D Molecules (alpha)
Tags: codepen
Published: 2022-08-31 13:28:10

<p>If the work I've been putting out since early 2012 has helped you in any way or you just like it and you wish me to be able to continue putting out stuff, please consider one of the following:</p>

<ul>
<li>being a cool cat 😼🎩 and becoming a patron on Patreon</li>
</ul>

<p><a href="https://www.patreon.com/anatudor"><img src="https://assets.codepen.io/2017/btn_patreon.png" alt="become a patron button"></a></p>

<ul>
<li>making a one time donation via Ko-fi</li>
</ul>

<p><a href="https://ko-fi.com/anatudor"><img src="https://assets.codepen.io/2017/btn_kofi.svg" alt="ko-fi"></a></p>

<ul>
<li>getting me something off my Amazon WishList </li>
</ul>

<p><a href="https://www.amazon.com/gp/registry/wishlist/2Y3C4722GXH0I/">🎁 🇺🇸</a> / <a href="https://www.amazon.co.uk/gp/registry/wishlist/2I25W7U0KADSR/">🎁 🇬🇧</a></p>

<ul>
<li>or at least sharing this to show the rest of the world what can be done with CSS these days</li>
</ul>

<p>Thank you!</p>

<hr>

<p>Hover the molecules (scroll to see all). Quick and dirty. Code could have looked better. </p>

<p>Uses nested 3D transformed elements (<code>transform-style: preserve-3d</code>) ➾ does not work in IE10. Uses animations on pseudo-elements ➾ does not work in Safari, Chrome 25 or older and IE9. </p>

<p>That's the theoretical support. Practical support... </p>

<p>Tested and works in Chrome 27, Firefox 22 on Windows 7, Chrome 26 on Linux. Does not seem to work in Chrome 27 on Windows XP. </p>

<p>Issues: </p>

<ul>
<li>Annoying flickering on hover in Chrome, as if it tried to get back to its original position. </li>
<li>Wrong molecules on top problem in Firefox. Hmmm, this one seems to happen only in full page or live view. No problem in Editor or Details.</li>
</ul>

<p>I would be really grateful if anyone could help with these. </p>

<p>There are workarounds for both IE10 and Safari. </p>

<p>For IE10, I could chain the transforms on one level, but that would also involve one set of keyframes per atom and it is not a solution I would use with so many molecules on one page. </p>

<p>For Safari, I could simply use an inner element instead of a pseudo-element. Again, something I was not going to do with so many elements on the page. </p>

<p>I do plan to create separate demos for individual molecules in order to better explain how this was done and implement these workarounds. </p>

<p><strong>Edit</strong>: Did <a href="http://codepen.io/thebabydino/pen/kbesd">a simplified demo</a> which also works in Safari and IE10. However, for more complicated molecules, taking care of IE might get really hairy.</p>

<p>Yes, the molecules represented here really exist. The structures and the bond angles are mostly real (excepting maybe some computational errors and data I was not able to find on the internet so I used the values of a typical structure of the kind). Everything is computed from the data (either well documented or just assumed) for each molecule. </p>

<p>Feel free to ask for other molecules if you can provide a visual 3D model and bond angles.</p>

<p>Inspired by </p>

<p><img src="http://s.cdpn.io/2017/di-mol.jpg" alt="image"> </p>

{% codepen https://codepen.io/harunpehlivan/pen/BaxBzNV %}