You can certainly set the size in the css.
// css code
.z10_icon img {
width: 12px;
height: 12px;
opacity: 0.96;
}
.z11_icon img {
width: 13px;
height: 13px;
opacity: 0.96;
}
// js code
// d refers to a particular data pt in my data array, e.g.
// {"loc":[100,100], "html":'<div><img src="icons/x.png" alt=""></div>', "css":"z10_icon"},
// when creating the marker, load in some default html and css for a particular data pt
var marker = new L.marker(map.unproject(d.loc, zoom_level),
{icon: L.divIcon({
className: d.css,
html: d.html}),
opacity: 1.0,
html: d.html
});
// notice that I have two "html" attributes - one is for the divIcon and one is for the marker
// I'm storing the "html" attribute for marker because I want to re-use it later (since the img src shouldn't change)
// later on, let's say you want to re-draw the marker,
// you have to remove it from map, set the icon, then add it back to the map
// here's only the code for setting the icon
// notice I retrieved the "html" attribute for the marker via marker.options and conveniently put it into the divIcon declaration
// and changed the css to z11_icon instead
marker.setIcon(L.divIcon({
className: "z11_icon",
html: marker.options.html}));
// I employed a similar technique to render text markers differently using css, according to my current zoom level for the map. I could even change the text of the markers by loading in another html.