amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

How to horizontally aligned responsive amp-component?

Open jitendravyas opened this issue 10 years ago • 6 comments

I'm using https://github.com/ampproject/amphtml/blob/master/extensions/amp-twitter/amp-twitter.md

And facing difficulties to make in center aligned. Can anyone help?

<div class="tweet-box">
<amp-twitter 
width="390" 
height="330" 
layout="responsive" 
data-tweetid="585110598171631616">
</amp-twitter>
</div>

If I use layout="responsive" it doesn't add width to output and also doesn't stretch the tweet to full width. If I remove layout="responsive" and give width, lets say 400px then it will give horizontal scrollbar in case of below 400px width.

Same problem is with Facebook embed but Instagram embed works fine

jitendravyas avatar Apr 25 '16 08:04 jitendravyas

@jitendravyas How are you trying to center-align it now? The current definition uses responsive layout which will resize the twitter embed to fill all of the available width. If this is not what you want - you can provide more styling via CSS or sizes attribute. The centering itself is probably best done using a flexbox CSS.

dvoytenko avatar Apr 25 '16 21:04 dvoytenko

@dvoytenko That's the problem responsive layout layout="responsive" doesn't resize the twitter embed to fill all of the available width. You can test it here https://ampbyexample.com/components/amp-twitter/

jitendravyas avatar Apr 26 '16 04:04 jitendravyas

I see. The amp-twitter element itself is sized to available space, but the Twitter implementation is not using all of this space.

@cramforce what do you think if we added display: flex; justify-content: center to the <div id="tweet"> in 3p/twitter.js?

dvoytenko avatar Apr 26 '16 18:04 dvoytenko

@dvoytenko Is this special to Twitter? Fine by me if it works.

cramforce avatar Apr 26 '16 18:04 cramforce

In the current implementation - yes.

dvoytenko avatar Apr 26 '16 21:04 dvoytenko

@dvoytenko is there a way to override this justify-content: center for amp-twitter you guys added here? I need to left align my twitter embed and I'm not able to figure out how to do it with this 🤔

jessanastasio avatar Mar 20 '18 19:03 jessanastasio