html - Adding clip-path to svg image element that has extra vertical space -
html - Adding clip-path to svg image element that has extra vertical space -
i'm having problem controlling clip-path coordinates on image element in responsive inline svg. here code illustration (jsfiddle: http://jsfiddle.net/tbbtester/4xp4w/): css:
ul{margin:0;padding:0;list-style:none;height:510px;position: relative;width:1140px;} li{margin:0;padding:0;position:absolute;background:blue;width:40.1754386%;height:52.15686275%;overflow:hidden;top:0;left:0;} svg{height: 100%;display:block;width: 100%;position: absolute;top:0;left:0;} image{clip-path: url(#promo5-1-image);} html:
<ul> <li> <svg viewbox='0 0 100 87.59398496' preserveaspectratio="xmidymid slice" xml:space="preserve"> <defs> <clippath id="promo5-1-image"> <polygon points="0,0 100,0 100,70 0,87.59398496" /> </clippath> </defs> <image preserveaspectratio="xminymid meet" x="0" y="0" width="100" height="87.59398496" xlink:href="http://svgtest.tbb.dev.novicell.dk/test.jpg" src="http://svgtest.tbb.dev.novicell.dk/test.jpg" overflow="visible" /> </svg> </li> </ul> the entire image visible, nil has been cutting off. image element larger displayed area - seems unnecessary space added above , below image, , causes problems when want add together clip-path since point 0,0 starts outside visible area. (you can see space if click image element in dom in browsers developer tools)
ok, found solution. problem used wrong way of calculating coordinates of svg , elements. solution fiddle: http://jsfiddle.net/tbbtester/4xp4w/1/
css:
ul{margin:0;padding:0;list-style:none;width:100%;height:510px;position: relative;width:1140px;} li{margin:0;padding:0;position:absolute;background:blue;width:40.1754386%;height:52.15686275%;overflow:hidden;top:0;left:0;} svg{height: 100%;display:block;width: 100%;position: absolute;top:0;left:0;overflow:hidden;} image{clip-path: url(#promo5-1-image);} html:
<ul> <li> <svg viewbox='0 0 100 58.07860262' preserveaspectratio="none"> <defs> <clippath id="promo5-1-image"> <polygon points="0,0 100,0 100,50.87336245 0,58.07860262" /> </clippath> </defs> <image x="0" y="0" width="100" height="58.07860262" xlink:href="http://svgtest.tbb.dev.novicell.dk/test.jpg" src="http://svgtest.tbb.dev.novicell.dk/test.jpg" /> </svg> </li> </ul> html css svg
Comments
Post a Comment