Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why does twitter implement a full screen image like this

Tags:

css

There is a full screen image in the front page of twitter.In the source code,they do something like this:

HTML:

<div class="front-bg">
<img class="front-image" src="xxx.jpg">
</div>

CSS:

.front-bg {
position: fixed;
width: 200%;
height: 200%;
left: -50%;
}
.front-bg img {
margin: auto;
min-width: 50%;
min-height: 50%;
top: 0;
left: 0;
right: 0;
bottom: 0;
}

Why do they set top/left property to the ".front-bg img"? And if I change something like this:

.front-bg {
position: fixed;
width: 100%;
height: 100%;
}
.front-bg img {
min-width: 100%;
min-height: 100%;
}

It works as well. Why do they set width 200% instead?

like image 529
Chef Avatar asked Feb 22 '13 14:02

Chef


People also ask

Why does my Twitter feed look big?

After testing it out over the last couple of months, Twitter is now rolling out its new tweet image display format, which will mean that full-sized previews of attached tweet images are now shown within user timelines, as opposed to the current cropping down to fit your picture into a specific tweet image frame.

Why is my Twitter layout different?

First off, the updated Twitter format now utilizes Twitter's custom 'Chirp' font, which it introduced back in January within its branding update. So your tweet test will now look a little different, while all Western-language text now aligns left, making it easier to read as you scroll.

Does Twitter display square images?

In 2017, Twitter switched from square to round profile pictures. Now, the standard aspect ratio of 2:1 is no longer acceptable on Twitter. Your avatar should now follow a 1:1 aspect ratio. The recommended size is still 400px X 400px and permissible formats are JPG, PNG, and GIF.


1 Answers

{ top: 0; left: 0; right: 0; bottom: 0; }

This part is not used on desktop at all as this image does not have position property set, perhaps it's used on different devices with additional media queries?

I'd say the reason behind 200%/200% and positioning margin has to do something with the preffered way for centering the image. With %100/%100 scenario image would be always left aligned to the left border of browser window on smaller screens. By applying

margin: 0 auto; min-width: 50%;

they make it as wide as browser window and always centered.

like image 194
Chris Danek Avatar answered Sep 19 '22 18:09

Chris Danek