Polymer background-color of host element - css

I'm using Polymer for a new version of my website and I'm having some issues with displaying a data-bound background-color in all browsers.
Here is a live example. In Chrome it works as one would expect, with a red background-color showing up (depicted in the image below)
Now, in Firefox and IE 11 the background-color does not show up, resulting in something like this:
Now, I expect this has something to do with the polyfill, since Chrome is the only browser to natively support custom elements as shown in the browser compatibility page
Here's my code (same as in live example):
<polymer-element name="leiding-card" attributes="bgColor">
<template>
<style>
:host{
display: block;
position: relative;
padding: 20px;
border-radius: 2px;
background-color: {{bgColor}};
}
.profilePic{
width: 50px;
height: 50px;
border-radius: 25px;
margin: 10px;
background-size: 50px 50px;
}
</style>
<link rel="stylesheet" href="default_styles.css">
<paper-shadow z="1" animated="true"></paper-shadow>
<div class="white">
<content select="h1"></content>
<template repeat="{{p in people}}">
<div layout horizontal wrap around-justfied>
<div class="profilePic" center style="background-image: url({{p.profilePic}});"></div>
<div style="margin-right: 10px;">
<p>{{p.name}} {{p.lastname}}</p>
<h4>{{p.email}}</h4>
</div>
</div>
</template>
</div>
</template>
<script>
Polymer('leiding-card',{
ready: function(){
this.people = [
{name: "John", lastname: "Snow", profilePic: "http://lorempixel.com/output/cats-q-c-640-480-3.jpg", email: "john.snow#john.snow"},
{name: "Other", lastname: "Bastard", profilePic: "http://lorempixel.com/output/cats-q-c-640-480-8.jpg", email: "other.bastard#other.bastard"}
]
}
});
</script>
</polymer-element>
I've already tried doing stuff like polyfill-next-selector { content: ':host'; }, but I can't really find an example of it online and usually I don't see any issues with directly applying styles to the :host.

There's an open bug around bindings not working in style tags under the polyfill - https://github.com/Polymer/polymer/issues/270. Looks like there's a workaround provided in the bug notes, see http://jsbin.com/pelon/1/edit

Related

Vuejs - Svgs partially missing once a third is added

Not really sure how to ask this question to be honest, but recently I've started using VueJS and it's incredible!
That being said, with all the learning of Vue, I perhaps have lost a bit of my CSS skills; particularly when it comes to flex. I don't recall ever having this issue previously, but once I added a third SVG to my page, the two previous almost completely disappear, but the newest is fully visible.
Any ideas of what the heck could actually be happening here?
I'm not using SVG loader or anything, but rather a v-else-if to show svgs based on names; perhaps that's the issue? (though if that were, the two previously shown were fine until I added the third.)
Cheers!
NOTE: I'm not adding the SVG code, since I didn't want to have too much code showing in this question, but it's a simple hamburger menu svg, a search svg and the top nav stuff for an iphone.
App.vue
<template>
<div id="app">
<div class="container">
<top-nav-bar></top-nav-bar>
</div>
</div>
</template>
<script>
import TopNavBar from './components/molecules/TopNavBar.vue'
export default {
name: 'App',
components: { TopNavBar },
}
</script>
<style lang="sass">
#app
font-family: Avenir, Helvetica, Arial, sans-serif
-webkit-font-smoothing: antialiased
-moz-osx-font-smoothing: grayscale
text-align: center
color: #2c3e50
.container
position: relative
margin: 0 auto
border: 2px solid black
background-color: white
border-radius: 40px
width: 414px
height: 896px
</style>
Component:
<template>
<div class="container">
<icons name="nav-info" />
<icons name="hamburger" />
<icons name="search" />
</div>
</template>
<script>
import Icons from '../atoms/Icons.vue'
export default {
components: { Icons },
}
</script>
<style lang="sass" scoped>
.container
display: flex
flex-direction: column
align-items: center
margin: 0
</style>

Sticky footer in ember

Hey I create Ember application , And I try to set Sticky Footer.
I try to do this by this tutorial Sticky Footer On CSS-Tricks , Cause it's work for me once.
But with Ember its dosen't work
My css:
.mainFooter {
height:100px;
color:white;
background-color: #0c2635;
text-align:center;
}
.wrapper {
min-height: 100%;
margin-bottom: -100px;
}
.wrapper:after {
content: "";
display: block;
}
.mainFooter, .wrapper:after {
height: 100px;
}
My HTML:
<footer class="mainFooter">
SOME TEXT
</footer>
As I said, it's dosent work.
I watch the source code via the Inspector and I saw that Ember added its own wrapper to content the I put in the application.hbs file, this wrapper have a class named ember-view so I try to do:
.ember-view {
min-height: 100%;
}
But it's dosent work either, the footer displayed in the middle of the page.
Someone maybe try this and successid?
I would like to know about a solution to this problem.
I don't know how to fake an Ember app in jsfiddle/codeopen so I upload the app to my server, url: http://drawyourgif.pe.hu/dist/
EDIT
According to the solution that kumkanillam sugest I did so:
Application.hbs:
{{outlet "modal"}}
{{partial "header"}}
<div id="gif" class="wrapper">
{{outlet}}
</div>
{{partial "footer"}}
app.js
App = Ember.Application.extend({
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix,
rootElement: '#gif',
Resolver
});
And I get this error in the console:
ember.debug.js:43272Uncaught TypeError: Cannot read property 'tagName' of undefined
What I did wrong?
.ember-view will be included for all ember component by default so it's not good to apply css property for this class.
there may be many ways but the below should help.
You can wrap your application.hbs to render inside your page-wrap div.
for this you need to include the below line in
index.html
<div id="app-name" class="wrapper">
{{content-for "body"}}
</div>
application.hbs
<h1> Content </h1>
{{outlet}}
<div id="footer">
<p>I'm the Sticky Footer. inside application.hbs</p>
</div>
Configure rootElement in app.js. that will force entire app to include it in app-name div.
app.js
App = Ember.Application.extend({
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix,
rootElement: '#app-name',
Resolver
});
app.css
#wrapper {
min-height: 100%;
overflow: auto;
}
#footer {
position: absolute;
bottom: -3px;
left: 2px;
right: 2px;
height: 50px;
background-color: rgba(0, 0, 0, 0.8);
color: #fff;
}
Final Update:
You don't need to change anything in app.js. just look at the sample twiddle. I think this will help you
SAMPLE TWIDDLE
Here is a solution that uses flexbox. You may not want to use flexbox because you're unfamiliar with it, but I'll submit this answer for later google searches.
Here's a codepen with very little content in the main body: http://codepen.io/anon/pen/KgXgjV
Here's the same css with much more content in the main area: http://codepen.io/anon/pen/dpVpBK
Here is an example of why position: absolute doesn't work: https://ember-twiddle.com/f620502b8172f4181c9d58503e02e39c?openFiles=templates.application.hbs%2C
HTML
<html>
<body>
<div id="root" class="ember-application">
<div id="ember332" class="ember-view">
<div class='main-content'>
<h1>Welcome to Ember Twiddle</h1>
<br />
<p>
this page has very little content
</p>
</div>
<div id="footer">
<p>I'm the Sticky Footer. inside application.hbs</p>
</div>
</div>
</div>
</body>
</html>
CSS
/* this is just to reset codepen */
/* probably not necessary on ember */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
/* end reset */
html, body, #root {
height: 100%;
}
.ember-view {
display: flex;
flex-direction: column;
min-height: 100vh;
background: lightblue;
}
.main-content {
flex: 1;
}
#footer {
width: 100%;
height: 50px;
background-color: grey;
}

ngDialog positioning and sizing

I am working on a popup window using ngDialog. Here is some code:
<style>
.ngdialog.dialogforpopup .ngdialog-content
{
width : 1100px;
margin-top:-100px;
padding-top:10px;
}
</style>
Template
<div style="height:800px;width:1040px;padding-left:5px;padding-top:5px;
padding-right:5px"
</div>
<div class="ngdialog-buttons" style="margin-top:10px">
<button type="button" class="ngdialog-button ngdialog-button-primary"
ng-click="cancel()">Cancel</button>
<button type="button" class="ngdialog-button ngdialog-button-primary"
ng-click="save()">Save</button>
</div>
Directive
ngDialog.open({
template: 'editor.html',
controller: 'editorController',
className: 'ngdialog-theme-default dialogforpopup',
closeByDocument: false,
disableAnimation: true
});
I have two questions.
How can center my popup on the screen? Currently I am using margin-top:-100px;
Is it possible to size ngDialog automatically to its content?
Thanks
One can center ngdialog by setting "table-like" styles:
.ngdialog{
padding:0 !important;
}
.ngdialog-content {
padding: 0 !important;
background: transparent !important;
display: table; /*table-like styles for vertical centering*/
width: 100% !important;
height:100%;
}
.ngdialog-holder {
display: table-cell;
vertical-align: middle;
width: 100%;
height:100%;
}
.ngdialog-content > .ngdialog-close{
display:none; /*hide original close button*/
}
.my-dialog{
width:400px;
background:#fff;
border:1px solid #000;
margin:0 auto; /*center dialog horizontally*/
position: relative;
}
Also one need to wrap content of dialog with ".ngdialog-holder" and ".my-dialog" blocks. And finally place ".ngdialog-close" button inside of it.
<div class="ngdialog-holder">
<div class="my-dialog">
Dialog content goes here
<div class="ngdialog-close"></div>
</div>
</div>
Here is live example: ngdialog plunk
I downloaded ngDialog package using bower. so ngDilaog related CSS and JS files are in bower_components.
I added the following CSS and JS files to my html page.
<link rel="stylesheet" href="../bower_components/ng-dialog/css/ngDialog.css">
<link rel="stylesheet" href="../bower_components/ng-dialog/css/ngDialog-theme-default.css">
<link rel="stylesheet" href="../bower_components/ng-dialog/css/ngDialog-theme-plain.css">
<script src="../bower_components/ng-dialog/js/ngDialog.js"></script>
In my own JS file I am opening the dialog in the following way:
ngDialog.open({ template : 'dialog' ,scope : $scope , className: 'ngdialog-theme-default', plain: false,
showClose: true,
closeByDocument: true,
closeByEscape: true,
appendTo: false});
here is the html code:
<script type="text/ng-template" id='dialog'>
<div class="ngdialog-message">
Hello!!
</div>
</script>
With the above changes I am able to show the pop up on the center of the screen.
can use of the following class for pop up.
className: 'ngdialog-theme-plain'
className: 'ngdialog-theme-default'
I hope this will help!

Percentages in css using meteor?

I'm just started making my first Meteor app and I wanted my div to to be the same height as the page, so logically I set the height to 100%. It didn't work. Then I set the width to 100%. That also didn't work. Is there a mistake in my code? Or maybe does Meteor parse css weirdly?
<head>
<title>Facer</title>
</head>
<body>
</body>
<template name="home">
<div id="face">
<img id="faceimg" src="http://raritea.com/raritea/images/logo.svg"/>
</div>
</template>
CSS:
body {
margin: 0px;
background-color: grey;
}
#face {
background-color: black;
width: 100%;
height: 100%;
}
JS:
Router.map(function(){
this.route('home', {path: '/'});
});
Or maybe does Meteor parse css weirdly? No, meteor works exactly like other web framework.
Try with this css.
#face {
background-color: black;
width: 100%;
height: 100%;
position: absolute;
}
Also in order to use iron:route and get off the <body> tag i recommend you to use the layout template, like this.
<template name="layout">
{{> yield}}
</template>
Router.configure({
layoutTemplate:'layout',
})
The {{> yield}} helper will take care of us to render the template home
Here is the MeteorPad with the div full width/height on the screen.
Tutorial iron:router
Check the Manuel Schoebel iron router tutorial is a good start point

Internet Explorer 8 doesn't apply display inline and block correctly

In short.
I have something like this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<style>
.vertical_panel > .fields > .item {
display: block;
background-color: #344;
}
.horizontal_panel > .fields > .item {
display: inline;
background-color: #FAE;
}
.item {
width: 100px;
height: 50px;
margin: 2px;
}
.fields {
margin: 0px;
padding: 0px;
}
#specialSpan {
display: table;
margin: 0px auto;
}
</style>
</head>
<body>
<div class="horizontal_panel" id = "specialSpan" style="width: 300px; height: auto;">
<fieldset class="fields">
<span class="vertical_panel item" style="width: 300px; height: auto;">
<fieldset class="fields">
<div class="item">
<span>text</span>
</div>
<div class="item">
<span>text</span>
</div>
</fieldset>
</span>
<div class="item">
<span>text</span>
</div>
<div class="item">
<span>text</span>
</div>
</fieldset>
</div>
</body>
</html>
It's an approximation to my code structure. There are more elements inside the fields. So, I have a javascript function which toggles class of panels.
The problem is: I have correct selectors, correct values of style are set(display), but Internet Explorer 8 does not apply it correctly. The items does not change their direction if I call that function. Under “does not change direction” I mean that items does no rendered as display: block or display: inline.
There is a key part: if I open debug tools and enter display: inline for instance manually for panels, almost everything looks fine. But if I have correct view before manual style changes and I have changed the style, I can't change view back to normal in ordinary way — with call of function.
The function is something like:
function SetPanelOrientation(panel) {
// this attribute doesn't exit in example but actually exist in project's code
// and always correct
var isVertical = panel.getAttribute("IsVertical");
if (isVertical == '0') {
$(panel)
.removeClass('vertical_panel')
.addClass('horizontal_panel');
} else {
$(panel)
.removeClass('horizontal_panel')
.addClass('vertical_panel');
}
};
I can see in debugger tools that class changed, but view doesn't change. I've tried many combinations with block and inline-block but have not found working combination.
Due to the doctype you are using, you are in quirks mode, and IE will perform as if it were 1998 all over again. New web pages should not be using that doctype since 1999.
The only way around this is to set the element's CSS properties to how you want them to be versus how other browsers are correctly displaying them.
There was nothing in doctype, nor in property values. Set styles with jquery instead of css file helps.

Resources