This help page is a how-to guide. It explains concepts or processes used by the Wikipedia community. It is not one of Wikipedia's policies or guidelines, and may reflect varying levels of consensus. |
This is an easy method to add full-width images to userpages that stretch to the maximum width of any screen, be it in mobile or desktop view. For an example, see User:Chlod (or User:Chlod/Gallery).
/* [[w:en:User:Chlod/Full-width image]] */
.userpage_image {
/**
Example:
/* Backlink: [[File:Burgoyne Bridge guardrails.jpg]] * /
background-image: url("//upload.wikimedia.org/wikipedia/commons/3/34/Burgoyne_Bridge_guardrails.jpg")
**/
/* Backlink: [[<image name here (with File: prefix)>]] */
background-image: url("<image link here>");
background-size: cover;
background-position: center;
/* The image will take up 75% of the window height as set below. You can change this */
/* value to a different percentage, or use "px" (pixels) instead of "vh" (viewport height). */
height: 75vh;
/* If you don't want the image to take up 75% of the page height on portrait phones, uncomment the following line. */
/* max-height: 500px */
}
Special:MyPage
is your userpage, e.g. User:Example
).Special:MyPage/userpage.css
is where you moved the CSS file.
<templatestyles src="Special:MyPage/userpage.css"/><div class="userpage_image mw-no-invert"></div>
<div>
tags in Step 3. You may also want to watchlist this page for updates.