CSS - Align element to the right of the page - html

I have a problem with aligning elements to the right of the page as I did use several methods such as float, flex, but none of them work. For easier to understand, I included the picture so that it can describe what I mean. I don't know is there any wrong with my code so can someone help me to solve the problem? Thank you for your help
Home.js:
import React from 'react';
import "./homeStyle.css";
import { Navbar, NavItem, NavDropdown, MenuItem, Nav, Form, FormControl, Button } from 'react-bootstrap';
import "./components/containers/Menu.css";
import "./homeScript";
import { Widget } from '#typeform/embed-react'
import logo from "./components/img/logo.png";
export default function Home() {
return(
<div>
<div className='App tc f3'>
<Navbar bg='dark' expand='lg'>
<Navbar.Brand href="">
<img src={logo}/>
</Navbar.Brand>
<Navbar.Toggle aria-controls="basic-navbar-nav" />
<Navbar.Collapse id="basic-navbar-nav">
<Nav className='ml-auto'>
<Nav.Link href="#home"><button type="button">Login</button></Nav.Link>
</Nav>
</Navbar.Collapse>
</Navbar>
</div>
<section id="home">
<div className="inner-width">
<div className="content">
<h1 />
<div className="buttons">
<button>Not Prepare to Part Yet? Click to Learn More</button>
</div>
</div>
</div>
</section>
</div>
)
}
CSS:
*{
margin: 0;
padding:0;
text-decoration: none;
font-family: 'Montserrat', sans-serif;
box-sizing: border-box;
}
#home .inner-width {
display: flex;
align-items: center;
justify-content: right;
height: 100%;
text-align: center;
}
#home .content {
width: 100%;
color: white;
float: right;
}
#home .content h1 {
font-size: 60px;
margin-bottom: 60px;
}
#home .content h1::after {
content: " Family ";
animation: textAnim 10s linear infinite;
}
#keyframes textAnim {
25% {
content: " If not Now, When ? ";
}
50% {
content: " Just in case. ";
}
75% {
content: " For your loved one.";
}
}

Try using css properties position: relative and position: absolute for aligning item.
Short explanation. Position relative is assigned to parent, in this case you can assign to section home. Then, position absolute is assigned to child that want to be aligned. After that, for child element you can use positioning properties like right, top, bottom and left to adjust the positioning.
For example
#home {
position: relative;
width: 100%;
height: 90vh;
}
.content {
position: absolute;
top: 50%;
right: 0;
transform: translateY(-50%);
-webkit-transform: translateY(-50%);
}

Related

I can't get an image to appear when hovering on another image, Cargo

I'm having issues trying to make an image {image 16} appear when hovering on another image with a link {image 15}. I'm building my website on Cargo, as I don't know much about coding. This site-builder is limiting my options to only place my images in grids, and as these grids already have a div class each, i can't get Cargo to accept the div classes im making for each image- probably because i'm doing it wrong. To top it all off, Cargo doesn't allow me to see all of the HTML, just specific parts. Any help would be super welcomed, thank you in advance!
HTML:
<div class="image-gallery" gid="21">
<div class="hover-image">{image 16}</div>
</div> <br>
<br><br>
<br>
<div grid-row="" grid-pad="0" grid-gutter="0" grid-responsive="">
<div grid-col="x12" grid-pad="0"></div>
</div><br>
<div grid-row="" grid-pad="0" grid-gutter="0" grid-responsive="">
<div grid-col="x12" grid-pad="0"><div style="text-align: left"><div class="image-gallery" gid="22">
<div class="hover-title">
<a rel="history" href="enlightened-type" class="image-link">{image 15}</a>
</div>
{image 5}
{image 13}
{image 14}
{image 12}
{image 11}
</div><br></div>
</div>
</div>
<br><div class="image-gallery" gid="23">
{image 17}
</div>2
CSS:
.hover-title {
display: inline;
pointer-events: auto;
cursor: pointer;
}
.hover-image {
visibility: hidden;
}
body:not(.mobile) .hover-title:hover + .hover-image {
visibility: visible;
pointer-events: none;
}
.hover-image {
display: flex;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: -1;
pointer-events: none;
flex-direction: column;
align-items: center;
justify-content: center;
/* Change width and height to scale images */
width: 90vw;
height: 90vh;
}
.hover-image img {
max-width: 100% !important;
max-height: 100% !important;
width: auto !important;
height: auto !important;
margin-bottom: 0;
}
You're going to need some javascript.
Add an id to image16
<div class="hover-image" id="myhoverimage">{image 16}</div>
Add some event listeners to image15
<a rel="history" href="enlightened-type" onmouseover="showImg()" onmouseout="hideImg()" class="image-link">{image 15}</a>
The Javascript. (Put at the bottom of your html)
<script>
var hoverImg = document.getElementById("myhoverimage");
function showImg(x) {
hoverImg.style.visibility = "visible";
}
function hideImg(x) {
hoverImg.style.visibility = "hidden";
}
</script>
You can do the document. calls inline. 👍
<img src="./icon-off.png" name="MyImage">

How can I make my navigation bar links(About, Services, Projects) "stop running off the screen"-make it stop?

When I try to size down my desktop screen navigation size of 1440px(90em) to any lower width screen, my navigation bar links start dropping off the screen. I have tried using some media query combinations, but nothing to show for it.I haven't got much experience with frontend, so I am a little bit thin on this side. Any long-term fixes to this one?Any hint on this one will be highly appreciated.
HTML header code:
<!--header-->
<header>
<nav class="nav__bar">
<a href="#" class="logo">
<img src="./images/logo.svg" alt="Sunnyside logo">
</a>
<ul class="nav__links">
<li class="nav__item">
About
</li>
<li class="nav__item">
Services
</li>
<li class="nav__item">
Project
</li>
Contact
</ul>
<img src="./images/icon-hamburger.svg" alt="toggle menu icon" class="toggle__menu">
</nav>
</header>
CSS header styles:
header {
height: 5em;
position: absolute;
left: 0;
right: 0;
}
.nav__bar {
height: 100%;
width: 90em;
margin: auto;
display: flex;
justify-content: space-between;
align-items: center;
flex: 1 1 auto;
padding: 0 2em;
}
.nav__links {
height: 100%;
display: flex;
justify-content: center;
align-items: center;
list-style: none;
}
.nav__item {
margin: 1em;
}
.nav__link {
text-decoration: none;
font-size: 1.125em;
color: hsl(0, 0%, 100%);
font-family: 'Barlow', sans-serif;
transition: all 350ms ease-in-out;
}
.nav__link:hover {
color: hsl(232, 10%, 55%);
}
.toggle__menu {
cursor: pointer;
display: none;
}
In your example code, you set the color of the link text to white... it's white on white. But that's not fully the problem... you should also remove width:90em from the .nav_bar... it's unnecessary. see this codepen https://codepen.io/aequalsb/pen/jOmyJNp
Just simply allow the <nav> to "be itself"... which is a block level element and naturally attempts to stretch out to fit available width.
padding in CSS Sizes the margin inside a button or element. Try using margin: (how many 'px' it's going off the screen); and I've had this problem before:
SOLUTION 1:
use margin-*left or top*: *px is going off screen*
<style>
#button {
width: 100px; /* the width of the button */
position: absolute;
left: 50%; /* always 50% when centering */
margin-left: -50px; /* minus half the size of the element */
}
</style>
<button id="button">Center of page</button>
SOLUTION 2
i've had this problem before, and in best situations, use position: absolute instead of relative if you are positioning the element.
<head>
<style>
.background {
position: relative;
}
.overlap {
position: absolute;
left: 30px;
}
</style>
</head>
</style>
</head>
<body>
<!-- background-element -->
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/b/b4/Circle_Rufous_Solid.svg/1200px-Circle_Rufous_Solid.svg.png" class="background" width="10.5%" />
<!-- Overlap element -->
<img src="https://cdn.onlinewebfonts.com/svg/img_24930.png" class="overlap" width="10%" />
</body>
SOLUTION 3
if none of the above works, consider using javascript: device tester command and redirect to an error page with unsupported devices.
This example will detect a handful of mobile-devices, and if so, it'll redirect to 𝘩𝘵𝘵𝘱://𝘨𝘰𝘰𝘨𝘭𝘦.𝘤𝘰𝘮
<script>
if( /Android|webOS|iPhone|iPad|Mahc|Macintosh|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
window.location.href = "http://google.com";
} else {
}
</script>
NOTE: if there is big problem you cannot solve, and none of these work, its best to do research or find some articles to find your answer. Then consider using stackoverflow.

SVG image within an absolutely positioned div is different on Firefox than Chrome

I have the following web page:
http://designsystem.foamfactory.io/current/components/preview/main.html
It's basically a set of text, along with a couple of SVG images. In order to get the effect that I want (the hex bolts should be overlaid in a specific position on the text), I use absolute positioning within a relatively positioned container.
The actual HTML code and CSS are fairly simple, and outlined in this codepen:
https://codepen.io/jwir3/pen/ZEzRKyz
The associated HTML is:
<div class="lockup">
<img class="lockup-logo logo-medium" src="http://designsystem.foamfactory.io/current/dist/assets/logos/Logo.svg" />
<div class="textmark textmark-medium">
<div id="hex-bolt-f-top">
<img src="http://designsystem.foamfactory.io/current/dist/assets/misc/Hex%20Bolt.svg" />
</div>
<div id="hex-bolt-f-bottom">
<img src="http://designsystem.foamfactory.io/current/dist/assets/misc/Hex%20Bolt.svg" />
</div>
<div id="hex-bolt-y-middle">
<img src="http://designsystem.foamfactory.io/current/dist/assets/misc/Hex%20Bolt.svg" />
</div>
<div id="hex-bolt-y-bottom">
<img src="http://designsystem.foamfactory.io/current/dist/assets/misc/Hex%20Bolt.svg" />
</div>
<div class="textmark-text">Foamfactor<span class="last-letter">y</span></div>
</div>
<div class="empty"></div>
</div>
and CSS:
.lockup {
display: -ms-flexbox;
display: flex;
-ms-flex-align: center;
align-items: center;
-ms-flex-pack: start;
justify-content: flex-start;
}
.lockup .empty {
-ms-flex-positive: 4;
flex-grow: 4;
}
.lockup-logo {
display: inline;
}
.textmark {
display: inline-block;
box-sizing: border-box;
position: relative;
padding: 0;
-ms-flex: 1 1 0px;
flex: 1 1 0;
margin-left: .2em;
}
.textmark .textmark-text {
display: block;
color: black !important;
box-sizing: border-box;
font-family: "Staatliches";
line-height: 1.0;
letter-spacing: -.04em;
}
.textmark.textmark-large {
font-size: 200pt;
}
.textmark.textmark-large .textmark-text::first-letter,
.textmark.textmark-large .textmark-text .last-letter {
font-size: 300pt;
}
.textmark.textmark-large .textmark-text .last-letter {
margin-left: -.04em;
}
.textmark.textmark-medium {
font-size: 80pt;
}
.textmark.textmark-medium .textmark-text::first-letter,
.textmark.textmark-medium .textmark-text .last-letter {
font-size: 120pt;
}
.textmark.textmark-medium .textmark-text .last-letter {
margin-left: -.04em;
}
.textmark.textmark-small {
font-size: 40pt;
}
.textmark.textmark-small .textmark-text::first-letter,
.textmark.textmark-small .textmark-text .last-letter {
font-size: 60pt;
}
.textmark.textmark-small .textmark-text .last-letter {
margin-left: -.04em;
}
.textmark.textmark-tiny {
font-size: 24pt;
}
.textmark.textmark-tiny .textmark-text::first-letter,
.textmark.textmark-tiny .textmark-text .last-letter {
font-size: 36pt;
}
.textmark.textmark-tiny .textmark-text .last-letter {
margin-left: -.04em;
}
.textmark #hex-bolt-f-top img,
.textmark #hex-bolt-f-bottom img,
.textmark #hex-bolt-y-bottom img,
.textmark #hex-bolt-y-middle img {
width: .08em;
}
.textmark #hex-bolt-f-top {
position: absolute;
top: -.6em;
left: .1em;
}
.textmark #hex-bolt-f-bottom {
position: absolute;
bottom: .1em;
left: .1em;
}
.textmark #hex-bolt-y-bottom {
position: absolute;
bottom: .1em;
right: .2282em;
}
.textmark #hex-bolt-y-middle {
position: absolute;
top: -.1em;
right: .2282em;
}
In Chrome, this always looks how I would expect. In Firefox (I'm using Nightly, but I have tried it on the latest release as well), however, the hex bolts on the far right of the div (the "Y") are too far to the right. Even stranger, most of the time it looks fine in Firefox, too, but when I inspect it using dev tools, it changes the width of the box or something, and it gets screwed up until I shift-refresh (a simple refresh won't fix the issue).
I'm fairly certain that the problem lies with the fact that the outermost div for this entire text/logo combination is a flexible box. The reason I have it that way is to center it on the page. Perhaps there is another way to achieve the results I want without this?
More to the point, I'm unclear on why the behavior is different between the two browsers. Have I hit on an area where the specification isn't well defined?
this solves the issue but you need to correct the first letter
.textmark .textmark-text {
display: inline;
}
I think the easiest way would be to center it with this:
.centered {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
That way you only have something like:
<body class="frontmatter index">
<div class="centered">
<div>
<div class="lockup">
<img class="lockup-logo logo-medium" src="../../dist/assets/logos/Logo.svg">
<div class="textmark textmark-medium">
<div id="hex-bolt-f-top">
<img src="../../dist/assets/misc/Hex Bolt.svg">
</div>
<div id="hex-bolt-f-bottom">
<img src="../../dist/assets/misc/Hex Bolt.svg">
</div>
<div id="hex-bolt-y-middle">
<img src="../../dist/assets/misc/Hex Bolt.svg">
</div>
<div id="hex-bolt-y-bottom">
<img src="../../dist/assets/misc/Hex Bolt.svg">
</div>
<div class="textmark-text">Foamfactor<span class="last-letter">y</span></div>
</div>
<div class="empty"></div>
</div>
</div>
<h2>An elegant brewery management system for a more civilized age</h2>
</div>
....
</body>
Flexbox might be a little overkill for this in my opinion.
I think you need check this website:
https://validator.w3.org
and scan your website there that web will tell you where to fix your web struct as I check there is many attribute and tag are missing from your web. you may think this is not the problem that cause your website struct error. So please go to that website and fix what is the error left in your web structure.

Basic vertical center in CSS behaving strangely on floated element

So i've come to live by these 3 CSS rules that almost always vertically center any block level element:
.vertically-center {
position: relative;
top: 50%;
transform: translateY( -50% );
}
It works often. But in the case of this particular layout I'm building it is pushing the elements too high ( partially off the screen ) and I don't know why.
This is how the webpage looks before adding my vertically-center class to my portrait-container div:
And this code snippet is how it appears after adding the vertically-center class to the portrait-container div:
.clearfix:after {
content: "";
display: block;
clear: both;
}
.vertically-center {
position: relative;
top: 50%;
transform: translateY( -50% );
}
body {
overflow: hidden;
}
main {
padding-top: 50px;
background: #fafafa;
text-align: left;
}
.portrait-container {
float: left;
}
img {
width: 150px;
border-radius: 50%;
}
.about-container {
width: 70%;
float: right;
}
<main class="clearfix">
<div class="portrait-container vertically-center">
<img src="http://i.imgur.com/Eb5sRZr.jpg" alt="Portrait of John Lesko">
</div>
<div class="about-container">
<h3>About</h3>
<p>
Hi, I'm John Lesko! This is my art portfolio where I share all
of my favorite work. When I'm not creating things, I enjoy excercising,
playing video games, drinking good Kool Aid, and more.
<br><br> If you'd like to follow me on Twitter, my username is
#jletsgo.
</p>
</div>
</main>
I just want the image container to be vertically-centered regardless of the height of it's parent. Help? Inspecting elements gave me no insights.
Edit: Just to show how this has always worked for me in the past. Here is a jsfiddle: https://jsfiddle.net/9kyjt8ze/4/. Why does it work for me there and not here?
Related question: What does top: 50%; actually do on relatively positioned elements?
Your CSS was not bad but I didn't get along with it. So here is another approach on how you could solve it, maybe it helps also. It will always center the image vertically and does not matter how much text the box on the right will have. The colored borders are just there to help show the visual effect of the box sizes.
* {
box-sizing: border-box;
}
.portrait-container {
position: relative;
margin: 20px 0;
}
.portrait-container:after {
content: '';
display: block;
clear: both;
}
.portrait-container img {
position: absolute;
top: calc(50% - 80px); /* 50% from top minus half img height*/
width: 150px;
height: 160px;
border-radius: 50%;
float: left;
}
.portrait-container {
border: solid 2px orange;
}
.portrait-container .about-container {
border: solid 2px green;
padding: 0 50px;
margin-left: 150px; /* this elements should be at least 150px away from left side */
width: calc(100% - 150px); /* the max width this element should have to be placed */
/* next to the image is the total width(100%) - the image width */
}
<main>
<div class="portrait-container">
<img src="http://i.imgur.com/Eb5sRZr.jpg" alt="Portrait of John Lesko">
<div class="about-container">
<h3>About</h3>
<p>
Hi, I'm John Lesko! This is my art portfolio where I share all
of my favorite work. When I'm not creating things, I enjoy excercising,
playing video games, drinking good fruit punch, and more.
<br><br> If you'd like to follow me on Twitter, my username is
#jletsgo.
</p>
</div>
</div>
</main>
<main>
<div class="portrait-container">
<img src="http://i.imgur.com/Eb5sRZr.jpg" alt="Portrait of John Lesko">
<div class="about-container">
<h3>About</h3>
<p>
Hi, I'm John Lesko! This is my art portfolio where I share all
of my favorite work. When I'm not creating things, I enjoy excercising,
playing video games, drinking good fruit punch, and more.
<br><br> If you'd like to follow me on Twitter, my username is
#jletsgo.
</p>
<p>
Hi, I'm John Lesko! This is my art portfolio where I share all
of my favorite work. When I'm not creating things, I enjoy excercising,
playing video games, drinking good fruit punch, and more.
<br><br> If you'd like to follow me on Twitter, my username is
#jletsgo.
</p>
</div>
</div>
</main>
UPDATE
Edit: Just to show how this has always worked for me in the past. Here is a jsfiddle: https://jsfiddle.net/9kyjt8ze/4/. Why does it work for me there and not here?
The black circle is the only element there in the Fiddle, there's no obstructions. In the code you are having trouble with, you have many elements either in the way or wrapped around other elements trapping them. Your ruleset will work if you start stripping away the layers. Or you can just add a property and change another property as per Snippet 1.
One important note a relative element is actually occupying the original spot, so if given a left:40px it appears to be moved 40px to the left, but in reality it still occupies the space 40px to the right of where it appears to be. So relative elements are not really in a flow different from static elements. Therefore they are affected by and affect static layout, it's just not noticeable normally because they stack with z-index.
Snippet 2 is an interactive demo, I figured maybe that'll help explain things better.
The 3 CSS ruleset is a common way to vertically align elements, but it was originally position: absolute instead of position:relative and it had to be in another positioned element if I remember correctly.
REFERENCE
Specific Ruleset
W3Schools
MDN
SOLUTION
.vertically-center {
/* Changed to absolute from relative */
position: absolute;
top: 50%;
transform: translateY( -50% );
}
main {
/* Added position: relative */
position: relative;
padding-top: 50px;
background: #fafafa;
text-align: left;
}
SNIPPET 1
.vertically-center {
position: relative;
top: 50%;
transform: translateY( -50%);
}
body {}
main {
padding-top: 50px;
overflow: scroll;
background: #fafafa;
text-align: left;
}
img {
width: 150px;
border-radius: 50%;
float: left;
}
.about {
width: calc(100% - 150px);
float: right;
}
<main class="clearfix">
<img src="http://i.imgur.com/Eb5sRZr.jpg" alt="Portrait of John Lesko" class="vertically-center">
<article class="vertically-center about">
<h3>About</h3>
<p>
Hi, I'm John Lesko! This is my art portfolio where I share all of my favorite work. When I'm not creating things, I enjoy excercising, playing video games, drinking good Kool Aid, and more.</p>
<p>If you'd like to follow me on Twitter, my username is
#jletsgo.
</p>
</article>
</main>
SNIPPET 2
$('#b1').click(function() {
$('body').toggleClass('R S');
});
$('#b2').click(function() {
$('#N1,#N2,#N3').toggleClass('N M');
});
$('input[id$="2"]').on('input', function() {
var grp = "." + $(this).attr('class');
var num = parseInt($(this).val(), 10);
grp !== '.S' ? $('section' + grp).css('left', num + '%') : $('section.S').css('margin-left', num + '%');
});
$('input[id$="3"]').on('input', function() {
var grp = "." + $(this).attr('class');
var num = parseInt($(this).val(), 10);
grp !== '.S' ? $('section' + grp).css('top', num + '%') : $('section.S').css('margin-top', num + '%');
});
html,
body {
height: 100%;
width: 100%;
}
body {
overflow: scroll;
font: 400 12px/1.2 Consolas;
}
section {
width: 50px;
height: 150px;
border: 2px dashed grey;
text-align: center;
color: white;
}
.R {
position: relative;
background: rgba(0, 0, 255, .3)
}
.A {
position: absolute;
background: rgba(255, 0, 0, .3)
}
.F {
position: fixed;
background: rgba(0, 255, 0, .3)
}
.S {
position: static;
background: rgba(122, 122, 0, .3)
}
.N {
position: absolute;
background: yellow;
color: blue;
}
.M {
position: relative;
background: black;
color: yellow;
}
#R1 {
left: 20%;
top: 3%;
z-index: 1;
}
#A1 {
left: 42%;
top: 44%;
z-index: 2;
}
#F1 {
right: 20%;
top: 44%;
z-index: 3;
}
#S1 {
margin-left: 0;
margin-top: -28%;
}
#N1 {
bottom: 0;
right: 0;
width: 25px;
height: 80px;
z-index: 4;
}
input {
width: 6ex;
position: static !important;
}
button {
font: inherit;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body class='S'>
<fieldset>
<button id='b1'>Body Relative/Static</button>
<button id='b2'>Nested Absolute/Relative</button>
<br><br> RLeft
<input id='R2' class='R' type='number' value='20'> RTop
<input id='R3' class='R' type='number' value='3'> ALeft
<input id='A2' class='A' type='number' value='44'> ATop
<input id='A3' class='A' type='number' value='44'><br> FLeft
<input id='F2' class='F' type='number' value='64'> FTop
<input id='F3' class='F' type='number' value='44'> SLeft
<input id='S2' class='S' type='number' value='0'> STop
<input id='S3' class='S' type='number' value='-28'><br> NLeft
<input id='N2' class='N' type='number' value='45'> NTop
<input id='N3' class='N' type='number' value='45'>
</fieldset>
<section id='R1' class='R'>RELATIVE
<section id='N1' class='N'>N<br>E<br>S<br>T<br>E<br>D</section>
</section>
<section id='A1' class='A'><br><br><br>ABSOLUTE</section>
<section id='F1' class='F'><br><br>FIXED</section>
<section id='S1' class='S'><br><br><br><br><br>STATIC</section>
</body>
You can achieve this by using flexboxwith a lot less code. The below code will do the trick.
.clearfix {
display: flex;
align-items: center;
}
img {
width: 150px;
border-radius: 50%;
}
.about-container {
width: 70%;
padding-left: 30px;
}
Check it out in codepen http://codepen.io/anon/pen/OWYxrb

How Polymer Hero Transition works

First off I'm having a tough time understanding the fundamentals of the hero-transition within Polymer. I am attempting to build a hero transition card like the one in the example provided by them, which can be found here.
Below I've built the mini card and I'm just trying to understand the transition and how the larger card works with the smaller one.
My specific question is, how does the transition bind to each element? Do I need to complete the CSS for both before I can begin playing with the core-animated-pages? Does having an embedded template matter?
Any guidance would be extremely helpful.
<script src="../components/webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../components/core-animated-pages/core-animated-pages.html">
<link rel="import" href="../components/core-animated-pages/transitions/hero-transition.html">
<link rel="import" href="../components/paper-button/paper-button.html">
<link rel="import" href="../components/core-image/core-image.html">
<link rel="import" href="../components/paper-shadow/paper-shadow.html">
<polymer-element name="chip-card">
<template>
<style>
#page2 {
width: 100%;
height: 100%;
}
#paper_shadow {
position: relative;
display: inline-block;
font-family:'Roboto', sans-serif;
font-size: 12px;
color: white;
}
#chip_body {
height: 400px;
width: 300px;
background-color: aqua;
color: black;
}
#chip_top {
background-color: deeppink;
background-image: url();
background-size: cover;
background-position: center center;
width: 100%;
position: relative;
}
#chip_bottom {
background-color: #fbfbfb;
width: 100%;
height: 20%;
position: relative;
font-size: 1.2em;
word-wrap: break-word;
}
#text {
padding-left: 5%;
padding-right: 2.5%;
overflow: hidden;
}
#coreImage {
display: block;
}
#card_container {
width: 70%;
height: 600px;
background-color: aqua;
color: black;
}
#card_right {
height: 100%;
width: 30%;
}
#card_left {
background-color: darkblue;
height: 100%;
width;
70%;
}
#card_left_top {
padding-right: 20px;
padding-top: 20px;
background-color: skyblue;
}
#circle {
width: 30px;
height: 30px;
border-radius: 50%;
background-color: red;
}
#header_text {
}
#card_content {
width:100%;
background-color: lightcoral;
}
</style>
<core-animated-pages transitions="hero-transition" selected={{page}}>
<section>
<paper-shadow z="1" id='paper_shadow' on-mouseover="{{raise}}" on-mouseout="{{lower}}" animated=true; hero-p="" on-tap="{{transition}}">
<div id="chip_body" hero-id="chip_body" vertical layout center justified>
<div id="chip_top" flex>
<div id="coreImage">
<content select="#core-image"></content>
</div>
</div>
<div id="chip_bottom" vertical layout start-justified>
<div id='text'>
<content select="#chip_bottom"></content>
</div>
</div>
</div>
</paper-shadow>
</section>
<section id="page2">
<div id="card_container" hero-id="chip_body" on-tap="{{transition}}" hero=""></div>
</section>
</core-animated-pages>
</template>
<script>
Polymer('chip-card', {
page: 0,
raise: function() {
this.$.paper_shadow.setZ(2);
},
lower: function() {
this.$.paper_shadow.setZ(1);
},
transition: function(e) {
if (this.page === 0) {
this.$.paper_shadow = e.currentTarget;
this.page = 1;
} else {
this.page = 0;
}
}
});
</script>
</polymer-element>
you are actually very close to a working transition with the code you have.
I've implemented a more complicated hero transition on my website and took some code from there to get yours to work.
<core-animated-pages transitions="hero-transition" selected={{page}}>
<section>
<paper-shadow z="1" id='paper_shadow' on-mouseover="{{raise}}" on-mouseout="{{lower}}" hero-p on-tap="{{transition}}">
<div id="chip_body" hero-id="chip_body" hero vertical layout center justified>
<div id="chip_top" flex>
<div id="coreImage">
<content select="#core-image"></content>
</div>
</div>
<div id="chip_bottom" vertical layout start-justified>
<div id='text'>
<content select="#chip_bottom"></content>
</div>
</div>
</div>
</paper-shadow>
</section>
<section id="page2">
<div id="card_container" hero-id="chip_body" on-tap="{{transition}}" hero></div>
</section>
</core-animated-pages>
I've made but a few adjustments.
First off, any hero parent element, with the hero-p attribute, should contain just that attribute. So no need for the quotation marks :)
<paper-shadow hero-p .. >
Every element that's part of the Hero transition, needs a hero attribute.
Again, without the quotation marks. <div id="chip_body" .. hero .. >
And the same thing goes for the element you're transitioning to.
<div id="card_container" .. hero .. >
I've put a working version of your code on my website.
There's page containing the <chip-card> element and a second page containing the working template file.
Index page
Template file
Please note : I edited the reference to webcomponentsjs to conform with my folder structure.
Feel free to ask me if there's anything else!