Skip to content

Instantly share code, notes, and snippets.

@mattymil
Last active December 13, 2017 02:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattymil/b7b793bf90399f7c2f5b10f33ddcae6e to your computer and use it in GitHub Desktop.
Save mattymil/b7b793bf90399f7c2f5b10f33ddcae6e to your computer and use it in GitHub Desktop.
Background image in Polymer component example
<link rel="import" href="../../bower_components/polymer/polymer.html">
<dom-module id="tester-app">
<template>
<style>
:host {
display: block;
}
img.bg {
/* Stick it to the upper left hand corner */
position: fixed;
top: 0;
left: 0;
/* Make it stretch to any screen size */
width: 100%;
height: auto;
min-height: 100%;
/* set min-width to image width to maintain scale */
min-width: 1024px;
/* Make the deepest layer */
z-index: -999;
}
@media screen and (max-width: 1024px) { /* recenter the image on smaller screens */
img.bg {
left: 50%;
margin-left: -512px; /* 50% */
}
}
</style>
<img class="bg" src="../images/seigaiha.png" alt="">
<h1>Test</h1>
</template>
<script>
Polymer({
is: 'tester-app',
properties: {
prop1: {
type: String,
value: 'tester-app',
},
},
});
</script>
</dom-module>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment