scale background image without div (on body) - background-image

Any way to do this without using a div?
Acting only on the body alone?

There is a new property is css3 called background-size. This will do what you want to do but it isn't supported in all browsers yet
http://www.css3.info/preview/background-size/

Related

Flutter svg animation and manipulation

I have an SVG asset of a map, in which I have to change the color of some cities depending on the results of a network call. On the web, one normally would add a class to each path, give it some CSS, and toggle that class using JavaScript.
How can I achieve the same effect in flutter?
This can be done with the new version of jovial_svg. It supports embedded stylesheets, so you can use CSS exactly as suggested. Of course, you'd need to re-parse the SVG whenever there's a change, but that's not a big deal here.
Alternately, if it's just one set of cities, you could use SVG's currentColor, and set that value in the appropriate ScalableImage factory. But for your use case, CSS seems like the better way to go.
NOTE: At this exact moment, CSS support is in pre-release, but it should be formally released as 1.1.4 within a couple of days. In the meantime, see https://pub.dev/packages/jovial_svg/versions/1.1.4-rc.3

Html2canvas does not support svg format file. Html2canvas does not support some css3 properties, such as the transform property

My company USES the html2canvas screenshot framework, but it does not support SVG format and is not friendly to the new CSS properties, such as transform, and the shape of the ellipse can sometimes be inconsistent with the original image.
There is no new open source framework to support these requirements. There is no framework to replace the html2canvas framework with the functionality of the screenshot.
My English is not good, I use the translation, thank you
i have the same problem, but here's the think you should consider:
html2canvas is only support this CSS Property.
the developers themselves say "It's not suitable for production".
But if you still want to use it, you can try to make work around by changing the CSS before render and change it back after render.
Also for the SVG issue, you can use plugin canvg, replace the svg with the canvas that canvg provide before render.
But it's still unstable, the image sometime is off the image.
i suggest to use server side capture with phantomjs, here's the example for that:
var page = require('webpage').create();
page.open('http://github.com/', function() {
page.render('github.png');
phantom.exit();
});
it's quite fast i would say.
Hope it could help.

How can I maintain image class when using mc:edit in a MailChimp template?

I'm trying to create a MailChimp template where an image is editable using mc:edit
Here's the code:
<img class="flexibleImage" mc:edit="top_image">
This seems all good, but once I edit this image using the MailChimp editor, I lose the original class "flexibleImage" and all other class and style info related to that img element.
How can I create a template with an editable image and maintain (or add) that class?
For anyone else with the problme, this answer is based on a response from MailChimp support:
It looks like it isn't possible to keep a custom class attached to an
editable image. What you could do instead though is apply the class
to the image's containing element. So if the image is in a <div>, add
flexibleImage to the div, and then update your CSS rules to point to
.flexibleImage>img.
This happens because the image you want to edit is inside an mc:repeatable block that in turn is inside another mc:repeatable block
Even four years later this is still an issue.
The other route is to put mc:edit on the parent container, and have images managed through there, but you lose the Image uploader box, which is poor user experience.
You can go into Settings when you have uploaded a new image and put the sizes in there. Not ideal, but Mailchimp is to blame here (no such issue on Campaign Monitor templates).

Callback on widget attached and all images are loaded

I want execute some logic after the moment when widget is attached and all images inside this widget are loaded. This widget show a block of html prepared in CMS (so the number of images is dynamic).
What have I tried:
override Widget.onAttach() or Widget.onLoad(). Unfortunately both of them are executed before the moment when all images are loaded.
I found gwt-image-loader library which can add a callback per image. I wan't use it due to dynamic nature of the content.
In JavaScript there is this option which works great:
$('selector').waitForImages(function() {
// do some logic
});
Maybe I missed some GWT way to do the same thing?
You can try GWT's Image.addLoadHandler()
onLoad and onAttach methods are there to inform you that the <img> tag is attached to your document and that is it. This helps in setting image attributes such as height, width, position and so on. What you are asking is, after the image is attached to document you want an handler after the image is rendered. This is not possible with the current version of GWT as per my experience. Further rendering of image depends on the network you are in, the server you are connected and so on. So instead of wanting for a render callback, try to do the work in onLoad or onAttach methods or add a loadHandler for the same

Copying the background color of an HTML element

I'd like to set the background color of an HTML element to the background color of another HTML element. This needs to happen at runtime using Javascript. I tried the following but it fails silently (the background color remains unaltered):
DOM.setElementProperty(element, "backgroundColor", "document.getElementById('country').style.backgroundColor");
Any ideas?
This is untested, but I would try
element.getStyle().setBackgroundColor(DOM.getElementById("country").getStyle().getBackgroundColor());
If you happen to be using a JS framework (jQuery, MooTools, etc), it should be as simple as something like (all code untested):
$("div2").attr("background") = $("div1").attr("background")
I normally just run with a framework (because I'm already using it elsewhere), but basic JavaScript should also be pretty simple as well, something along the lines of:
getElementByID("div2").setAttribute('background') = getElementByID("div1").getAttribute('background')
or
getElementByID("div2").Attribute('background') = getElementByID("div1").Attribute('background')
One thing I noticed in a quick reference search, though, is that the basic JavaScript method isn't consistent across browsers (IE seems to be quirky). Just something to keep in mind on that front.