OPA5 Testing trigger custom action - integration-testing

I've list of custom tiles container I want to match some specific text and then trigger remove action.
<custom:CustomTileWithCount id="overviewCard" press=".onPressOverviewCard" remove=".onRemoveCard" tooltip="{i18n>overviewCardTooltip}"
visible="{parts:[{path:'name'},{path:'/overviewSearchFilter'},{path:'addSupplierCardFlag'}], formatter:'.tileVisibility'}"
count="{numberOfNewNotifications}" isPlainCard="{addSupplierCardFlag}" busyIndicatorDelay="0" >
<custom:content>
..........contents............
</custom:content>
</custom:CustomTileWithCount>
I'm doing some thing else on press button. but for remove how i'll find the text and trigger the remove action
Element Html
<div class="sapMCustomTileContent"><section role="form" aria-labelledby="samhengiMainView--panelInOverviewTile-samhengiMainView--overviewTileContainer-0-header" id="samhengiMainView--panelInOverviewTile-samhengiMainView--overviewTileContainer-0" data-sap-ui="samhengiMainView--panelInOverviewTile-samhengiMainView--overviewTileContainer-0" data-sap-ui-fastnavgroup="true" class="overviewCardPanel sapMPanel" style="width:100%;height:100%"><div class="sapMPanelBGSolid sapMPanelContent" style="height: 240px;"><div id="samhengiMainView--__layout0-samhengiMainView--overviewTileContainer-0" data-sap-ui="samhengiMainView--__layout0-samhengiMainView--overviewTileContainer-0" style="width:100%" class="sapUiVlt sapuiVlt"><div class="sapUiVltCell sapuiVltCell"><span id="samhengiMainView--__text0-samhengiMainView--overviewTileContainer-0" data-sap-ui="samhengiMainView--__text0-samhengiMainView--overviewTileContainer-0" class="sapMText sapMTextBreakWord sapMTextMaxWidth sapUiSelectable" style="text-align:left">Oracle</span></div><div class="sapUiVltCell sapuiVltCell"><span id="sap-ui-invisible-samhengiMainView--__icon1-samhengiMainView--overviewTileContainer-0" class="sapUiHiddenPlaceholder" data-sap-ui="sap-ui-invisible-samhengiMainView--__icon1-samhengiMainView--overviewTileContainer-0" style="display: none;" aria-hidden="true"></span></div></div><span id="sap-ui-invisible-samhengiMainView--noDataTextOverviewTile-samhengiMainView--overviewTileContainer-0" class="sapUiHiddenPlaceholder" data-sap-ui="sap-ui-invisible-samhengiMainView--noDataTextOverviewTile-samhengiMainView--overviewTileContainer-0" style="display: none;" aria-hidden="true"></span><div id="samhengiMainView--supplierOverviewViz-samhengiMainView--overviewTileContainer-0" data-sap-ui="samhengiMainView--supplierOverviewViz-samhengiMainView--overviewTileContainer-0" data-sap-ui-fastnavgroup="true" class="overviewCardVizFrame sapVizFrame" style="width:100%;height:80%"><div class="ui5-viz-controls-app" data-sap-ui-preserve="true"><div class="ui5-viz-controls-viz-frame"><div style="width: 100%; height: 100%;"><div id="UIComp_0" class="v-info" style="height: 165px; width: 287px; position: relative; font-size: 10px; box-sizing: border-box; -webkit-user-select: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);" tabindex="0"><svg class="v-m-root" style="left: 0px; top: 0px; height: 100%; width: 100%; display: block; cursor: default;" aria-labelledby="title desc" focusable="false" tabIndex="-1" width="100%" height="100%"><defs></defs><g class="v-m-desc-title"><title>An Interactive Combined Column Line Chart with 2 Y-Axes </title></g><g class="v-m-action-layer-group"></g><g class="v-m-decoration-layer-group"></g><g class="v-m-background"><rect class="v-background-body viz-plot-background v-morphable-background" x="0" y="0" width="287" height="165" style="fill:transparent"></rect></g><g class="v-m-title" transform="translate(39.3, 7)"><rect class="v-bound" width="171.36" height="18.171875" fill="transparent"></rect></g><g class="v-m-legendGroup" transform="translate(6, 159)"><g class="v-m-legend" transform="translate(0,0)"><rect class="v-bound" width="0" height="0" fill="transparent"></rect></g></g><g class="v-m-main" transform="translate(6, 7)"><g class="v-m-plot" transform="translate(33.3, 0)"><rect class="v-background-body viz-plot-background v-morphable-background" x="0" y="0" width="208.39999999999998" height="114.84" style="fill:transparent"></rect><clipPath id="plot_main_clipPath_f172776f-aeac-458c-bf76-3a09181a5dfd"><rect y="-1" width="209.39999999999998" height="115.84"></rect></clipPath><rect class="v-plot-bound v-bound v-zoom-plot" width="208.39999999999998" height="114.84" fill="transparent"></rect><g clip-path="url(#plot_main_clipPath_f172776f-aeac-458c-bf76-3a09181a5dfd)"><g class="v-plot-main" role="list" transform="translate(0, 0)"><g class="v-datapoint-group"><g><g data-id="0" data-datapoint-id="295" class="v-datapoint v-morphable-datapoint v-datapoint-default" combination-column="true" transform="translate(1.353246753246753, 114.84)"><rect width="27.06493506493506" height="0" fill="#27a3dd" stroke="#ffffff" stroke-width="1"></rect></g><g data-id="1" data-datapoint-id="296" class="v-datapoint v-morphable-datapoint v-datapoint-default" combination-column="true" transform="translate(31.12467532467532, 60.15428571428572)"><rect width="27.06493506493506" height="54.68571428571428" fill="#27a3dd" stroke="#ffffff" stroke-width="1"></rect></g><g data-id="2" data-datapoint-id="297" class="v-datapoint v-morphable-datapoint v-datapoint-default" combination-column="true" transform="translate(60.89610389610389, 65.12571428571428)"><rect width="27.06493506493506" height="49.714285714285715" fill="#27a3dd" stroke="#ffffff" stroke-width="1"></rect></g><g data-id="3" data-datapoint-id="298" class="v-datapoint v-morphable-datapoint v-datapoint-default" combination-column="true" transform="translate(90.66753246753245, 114.84)"><rect width="27.06493506493506" height="0" fill="#27a3dd" stroke="#ffffff" stroke-width="1"></rect></g><g data-id="4" data-datapoint-id="299" class="v-datapoint v-morphable-datapoint v-datapoint-default" combination-column="true" transform="translate(120.43896103896101, 114.84)"><rect width="27.06493506493505" height="0" fill="#27a3dd" stroke="#ffffff" stroke-width="1"></rect></g><g data-id="5" data-datapoint-id="300" class="v-datapoint v-morphable-datapoint v-datapoint-default" combination-column="true" transform="translate(150.21038961038957, 114.84)"><rect width="27.06493506493505" height="0" fill="#27a3dd" stroke="#ffffff" stroke-width="1"></rect></g><g data-id="6" data-datapoint-id="301" class="v-datapoint v-morphable-datapoint v-datapoint-default" combination-column="true" transform="translate(179.98181818181814, 114.84)"><rect width="27.06493506493507" height="0" fill="#27a3dd" stroke="#ffffff" stroke-width="1"></rect></g></g></g></g></g><g class="v-referenceline-group" clip-path="url(#plot_main_clipPath_f172776f-aeac-458c-bf76-3a09181a5dfd)"></g></g><g class="v-m-categoryAxis v-m-xAxis" transform="translate(33.3, 114.84)" role="listbox"><rect class="v-bound" width="208.39999999999998" height="37.16" fill="transparent"></rect><g class="v-axis"><g class="v-m-axisScrollbar" transform="translate(0,25.16)"><g><rect class="v-m-scrollbarTrack" visibility="hidden" fill="transparent" stroke-width="0" stroke="#f2f2f2" width="208.39999999999998" height="12"></rect><rect class="v-m-scrollbarThumb" visibility="hidden" fill="#ababab" width="208.39999999999998" height="8" transform="translate(2, 2)"></rect></g></g><g class="v-m-axisTitle" transform="translate(0,0)"></g><g class="v-m-axisBody" transform="translate(0,0)" clip-path="url(#clip-path-bc27e17b-0315-40e4-9a92-1f7fa17af6e8)"><clipPath class="v-clippath" id="clip-path-bc27e17b-0315-40e4-9a92-1f7fa17af6e8"><rect x="-1" y="-1" width="210.39999999999998" height="27.16"></rect></clipPath><g class="v-line-group"><line class="v-valueaxisline v-line" shape-rendering="crispEdges" stroke="#cccccc" stroke-width="1" x1="-0.5" y1="0" x2="208.89999999999998" y2="0" style="pointer-events: none;"></line></g><g class="v-label-group"><g class="v-label v-morphable-label viz-axis-label v-axis-item index_0" fill="#333333" font-size="11.8px" font-weight="normal" font-family=""72-Web",Arial,Helvetica,sans-serif" font-style="normal" categorylabel-id="0" transform="translate(0,0)"><rect class="viz-axis-label-rect" fill="transparent" x="1" y="1" width="27.77142857" height="23.16"></rect><g class="v-axis-label-wrapper"><text x="5.9923045550000005" y="17.44125" text-anchor="start">We</text></g></g><g class="v-label v-morphable-label viz-axis-label v-axis-item index_0" fill="#333333" font-size="11.8px" font-weight="normal" font-family=""72-Web",Arial,Helvetica,sans-serif" font-style="normal" categorylabel-id="1" transform="translate(29.77142857,0)"><rect class="viz-axis-label-rect" fill="transparent" x="1" y="1" width="27.77142857" height="23.16"></rect><g class="v-axis-label-wrapper"><text x="7.885714285000001" y="17.44125" text-anchor="start">Th</text></g></g><g class="v-label v-morphable-label viz-axis-label v-axis-item index_0" fill="#333333" font-size="11.8px" font-weight="normal" font-family=""72-Web",Arial,Helvetica,sans-serif" font-style="normal" categorylabel-id="2" transform="translate(59.54285714,0)"><rect class="viz-axis-label-rect" fill="transparent" x="1" y="1" width="27.77142857" height="23.16"></rect><g class="v-axis-label-wrapper"><text x="9.385714285" y="17.44125" text-anchor="start">Fr</text></g></g><g class="v-label v-morphable-label viz-axis-label v-axis-item index_0" fill="#333333" font-size="11.8px" font-weight="normal" font-family=""72-Web",Arial,Helvetica,sans-serif" font-style="normal" categorylabel-id="3" transform="translate(89.31428571,0)"><rect class="viz-axis-label-rect" fill="transparent" x="1" y="1" width="27.77142857" height="23.16"></rect><g class="v-axis-label-wrapper"><text x="7.385714285000001" y="17.44125" text-anchor="start">Sa</text></g></g><g class="v-label v-morphable-label viz-axis-label v-axis-item index_0" fill="#333333" font-size="11.8px" font-weight="normal" font-family=""72-Web",Arial,Helvetica,sans-serif" font-style="normal" categorylabel-id="4" transform="translate(119.08571429,0)"><rect class="viz-axis-label-rect" fill="transparent" x="1" y="1" width="27.77142857" height="23.16"></rect><g class="v-axis-label-wrapper"><text x="7.385714285000001" y="17.44125" text-anchor="start">Su</text></g></g><g class="v-label v-morphable-label viz-axis-label v-axis-item index_0" fill="#333333" font-size="11.8px" font-weight="normal" font-family=""72-Web",Arial,Helvetica,sans-serif" font-style="normal" categorylabel-id="5" transform="translate(148.85714286,0)"><rect class="viz-axis-label-rect" fill="transparent" x="1" y="1" width="27.77142857" height="23.16"></rect><g class="v-axis-label-wrapper"><text x="6.385714285000001" y="17.44125" text-anchor="start">Mo</text></g></g><g class="v-label v-morphable-label viz-axis-label v-axis-item index_0" fill="#333333" font-size="11.8px" font-weight="normal" font-family=""72-Web",Arial,Helvetica,sans-serif" font-style="normal" categorylabel-id="6" transform="translate(178.62857143,0)"><rect class="viz-axis-label-rect" fill="transparent" x="1" y="1" width="27.77142857" height="23.16"></rect><g class="v-axis-label-wrapper"><text x="8.104655020000001" y="17.44125" text-anchor="start">Tu</text></g></g></g></g></g></g><g class="v-m-valueAxis v-m-yAxis" transform="translate(0, 0)"><rect class="v-bound" width="33.3" height="114.84" fill="transparent"></rect><g class="v-axis"><g class="v-m-axisTitle" transform="translate(-3.552713678800501e-15,0)"><g class="v-title viz-axis-title" fill="#1b7eac" font-size="14px" font-weight="bold" font-family=""72-Web",Arial,Helvetica,sans-serif" font-style="normal"><text dominant-baseline="auto" text-anchor="start" x="-15.414847564697265" y="57.42" transform="rotate(-90,14.065625,57.42)"><tspan class="v-title viz-axis-title" dominant-baseline="auto"># Tweets</tspan></text></g></g><g class="v-m-axisBody" transform="translate(22.299999999999997,0)"><rect class="v-bound" width="11" height="114.84" fill="transparent"></rect></g></g></g><g class="v-m-valueAxis2 v-m-yAxis2" transform="translate(241.7, 0)"><rect class="v-bound" width="33.3" height="114.84" fill="transparent"></rect><g class="v-axis"><g class="v-m-axisScrollbar" transform="translate(0,0)"></g><g class="v-m-axisTitle" transform="translate(16.5,0)"><g class="v-title viz-axis-title" fill="#759422" font-size="14px" font-weight="bold" font-family=""72-Web",Arial,Helvetica,sans-serif" font-style="normal"><text dominant-baseline="auto" text-anchor="start" x="-24.116191101074218" y="57.42" transform="rotate(-90,14.065625,57.42)"><tspan class="v-title viz-axis-title" dominant-baseline="auto">Stock Price</tspan></text></g></g><g class="v-m-axisBody" transform="translate(0,0)"><rect class="v-bound" width="11" height="114.84" fill="transparent"></rect></g></g></g></g></svg><div class="v-m-tooltip-container" actualwidth="287" actualheight="165" style="left: 0px; top: 0px; height: 0px; width: 0px; position: absolute;"></div></div></div><div></div></div><div class="ui5-viz-controls-viz-description" style="display: none;"><div class="ui5-viz-controls-viz-description-title"></div><div class="ui5-viz-controls-viz-description-detail"></div></div></div></div></div></section></div>

So actually you have two problems: find an element and triger an action ?.
First you need to decide how to recognize the element you want to find. You could match by property:
var sTitle = "The Great App"
return new Opa5().waitFor({
controlType : "sap.m.ObjectHeader",
matchers : new sap.ui.test.matchers.PropertyStrictEquals({
name : "title",
value: sTitle
}),
errorMessage: "Could not find the tile with title: " + sTitle
...
Or you could select with code, have a look at the examples for matcher function here:
OPA5 cookbook.
Trigering an action boild down to sending a click to an element. So select the element and do:
return new Opa5().waitFor({
...
actions: new Press(),
errorMessage: "Could not click the tile"
});
Hope this helps

Related

How to correctly place an image outside the container, and make them adaptive, HTML/CSS?

Maket link: https://www.figma.com/file/hYoPHDHOzzgzEPo4crMmy1/UH15U7CD4WZkbhcW?node-id=2%3A334
Project link: https://plupiks.github.io/Real-Estate-LandingPage/
I have a layout, it has an image of a building. This image is outside of the container. I was able to take the image out of the container, but I can’t adapt it anymore. If I give the image width: 100%; height: auto; , its dimensions no longer correspond to those specified in the layout.
The question is, how to move images outside the container so that they can then be adapted without changing the original image dimensions?
Worked with preprocessor SCSS.
<div class="hero">
<div class="container">
<div class="hero--wrapper">
<div class="hero--blok-left">
<div class="hero--descr">Welcome to Besnik Agency</div>
<h1 class="hero--title">Discover a place you’ll love to live.</h1>
<p class="hero--subtitle">
Get the best real estate deals first, before they hit the mass market! hot foreclosure deals with one simple search
</p>
<button class="button hero--button">More About Us</button>
</div>
<div class="hero--block-right">
<div class="hero--img">
<svg width="584" height="620" viewBox="0 0 584 620" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M241.032 610.998L231.713 201.367L58.0327 201.367L60.5743 610.998H241.032Z" fill="#F1F6FF" />
<path d="M302.879 608.881V337.77L512.566 343.89V608.881H302.879Z" fill="#FEFCED" />
<path d="M58.033 201.367L60.5747 610.998H159.276L154.616 201.367H58.033Z" fill="#7398F7" />
<path d="M182.997 159.855H110.983V201.369H182.997V159.855Z" fill="#1F1D42" />
<path d="M110.983 159.855V201.369H159.698C136.315 196.285 129.057 171.575 128.351 159.855H110.983Z" fill="#1F1717" />
<path
d="M152.498 89.1111L144.026 88.2639C141.908 87.4167 141.484 77.6737 149.533 79.7917C155.971 81.4861 154.192 86.7107 152.498 89.1111Z"
fill="#0E173D"
/>
<path d="M152.498 89.112L144.026 88.2648V100.549L152.498 101.397V89.112Z" fill="#0E173D" />
<path d="M144.025 100.548L152.497 101.396L183.845 123.847H110.56L144.025 100.548Z" fill="#1F1D42" />
<path d="M323.636 403.007H316.859V451.298H313.893V456.381H326.602V449.604H323.636V403.007Z" fill="#1B2A63" />
<path d="M512.566 612.269H302.879V473.325L512.566 476.385V612.269Z" fill="#A3BDFF" />
<path d="M448.177 242.458L221.546 235.257L302.879 337.77L520.614 344.124L448.177 242.458Z" fill="#063183" />
<path d="M302.879 337.77L520.614 344.124L316.011 238.258L221.546 235.257L302.879 337.77Z" fill="#7087FB" />
<path
d="M221.546 235.257L302.879 337.77V605.915L152.921 613.117V476.291V337.77L193.164 284.819H184.268L221.546 235.257Z"
fill="#CFDEF3"
/>
<path d="M250.776 297.527H206.297V350.902H250.776V297.527Z" fill="#0C183F" />
<rect x="211.38" y="303.033" width="15.2499" height="18.6388" fill="#1F326B" />
<rect x="232.56" y="303.033" width="15.2499" height="18.6388" fill="#1F326B" />
<rect x="232.56" y="328.451" width="15.2499" height="18.6388" fill="#1F326B" />
<path d="M110.562 123.846H183.846H188.929V125.964H104.631V123.846H110.562Z" stroke="black" />
<path d="M150.804 378.012H303.727H512.99" stroke="black" stroke-width="4" />
<path d="M151.652 486.457H301.186H511.297" stroke="black" stroke-width="5" />
<path d="M151.652 486.457H301.186" stroke="#5267FA" stroke-width="6" />
<rect x="211.38" y="328.451" width="15.2499" height="18.6388" fill="#1F326B" />
<path d="M113.525 289.901H91.0741V350.901H115.22L113.525 289.901Z" fill="#0E173D" />
<path d="M113.525 395.381H91.0741V456.381H115.22L113.525 395.381Z" fill="#0C193F" />
<path d="M114.797 267.027H91.9224V220.43C97.3446 205.18 106.325 214.076 110.138 220.43L114.797 267.027Z" fill="#1F1D42" />
<path
d="M352.019 247.118H327.873L306.693 240.763V201.368V199.25L327.873 198.677L353.714 197.979L353.597 201.368L352.019 247.118Z"
fill="#1F326B"
/>
<path d="M352.019 247.118H327.874V201.368V198.677L353.714 197.979L353.597 201.368L352.019 247.118Z" fill="#FEFDE8" />
<path d="M306.693 199.25L327.873 198.677L353.714 197.979L353.597 201.368H327.873H306.693V199.25Z" fill="#112F7F" />
<rect x="180.881" y="125.966" width="1.69444" height="33.8888" fill="#0C1942" />
<rect x="241.032" y="166.632" width="1.69444" height="189.777" transform="rotate(90 241.032 166.632)" fill="#0C1942" />
<rect x="241.032" y="199.673" width="1.69444" height="189.777" transform="rotate(90 241.032 199.673)" fill="#0C1942" />
<path d="M58.0009 231.867H155.855H232.501" stroke="#18265D" stroke-width="4" />
<rect x="241.032" y="186.118" width="1.69444" height="189.777" transform="rotate(90 241.032 186.118)" fill="#081334" />
<rect x="110.56" y="125.966" width="1.69444" height="33.8888" fill="#132355" />
<rect x="128.352" y="131.895" width="1.69444" height="27.9582" fill="#132355" />
<rect x="131.741" y="131.895" width="1.69444" height="27.9582" fill="#132355" />
<rect x="136.824" y="131.895" width="1.69444" height="27.9582" fill="#132355" />
<path
d="M221.546 235.257L227.259 244.153M302.879 337.77L296.72 330.145M227.259 244.153L453.308 249.66M227.259 244.153L237.524 256.861M237.524 256.861L462.061 261.944M237.524 256.861L248.816 270.84M248.816 270.84L470.813 274.229M248.816 270.84L257.976 282.18M257.976 282.18L479.566 286.514M257.976 282.18L269.004 295.833M269.004 295.833L488.42 298.939M269.004 295.833L278.243 307.27M278.243 307.27L497.739 312.019M278.243 307.27L290.561 322.52M290.561 322.52H505.221M290.561 322.52L296.72 330.145M296.72 330.145L512.918 333.322"
stroke="#A3BDFF"
stroke-width="4"
/>
<rect x="83.4506" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
<rect x="51.2557" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
<rect x="239.338" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
<path d="M377.436 511.026H363.88V579.651H377.436V511.026Z" fill="#0C183F" />
<path d="M363.88 579.651H377.436V545.339H363.88V579.651Z" fill="#17275F" />
<path d="M489.691 548.304H467.24V580.499H489.691V548.304Z" fill="#17275F" />
<path d="M148.687 79.7914L146.992 1" stroke="black" stroke-width="3" />
<rect x="210.534" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
<rect x="151.227" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
<rect x="77.5193" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
<rect x="204.602" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
<rect x="204.602" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
<rect x="145.298" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
<rect x="158.853" y="131.895" width="1.69444" height="27.9582" fill="#121B3A" />
<rect x="162.241" y="131.895" width="1.69444" height="27.9582" fill="#121B3A" />
<rect x="152.921" y="131.895" width="1.69444" height="27.9582" fill="#121B3A" />
<path d="M467.24 580.499H489.691V564.402H467.24V580.499Z" fill="#0F1C49" />
<path d="M503.67 556.353H495.198V574.145L503.67 573.721V556.353Z" fill="#FAF2E2" />
<path
d="M200.365 511.449V548.727H204.601V604.643H211.803V546.185H207.143V517.803H248.657V546.185H241.879V604.643H246.115V548.727H254.164V511.449H200.365Z"
fill="#0D0808"
/>
<path d="M241.881 546.186V604.644H211.805V546.186H207.145V517.804H248.659V546.186H241.881Z" fill="#17275F" />
<path d="M584 611.421H0V620H584V611.421Z" fill="#091D39" />
<path
d="M571.873 611.422V576.686M510.026 576.686V611.422M446.485 576.686V611.422M385.909 576.686V611.422M323.214 576.686V611.422M259.249 576.686V611.422M201.638 576.686V611.422M136.826 576.686V611.422M74.132 576.686V611.422M14.4031 576.686V611.422"
stroke="black"
stroke-width="4"
/>
<path
d="M571.873 582C558.6 593.579 527.648 609.789 510.026 582C495.623 590.755 462.751 602.78 446.485 581.769C433.776 590.241 403.869 603.288 385.908 587.699C373.341 593.489 343.209 601.594 323.214 587.699C305.705 591.371 268.399 596.511 259.249 587.699C247.388 591.371 219.26 596.511 201.638 587.699C184.553 591.371 147.67 596.511 136.826 587.699C118.752 593.912 89.8057 602.102 74.1318 587.699C57.0807 591.371 23.3695 597.311 13.5004 588.5"
stroke="black"
stroke-width="3"
/>
<circle cx="571.965" cy="574.965" r="2.96527" fill="#06162A" />
<circle cx="510.026" cy="574.568" r="2.96527" fill="#06162A" />
<circle cx="446.484" cy="575.416" r="2.96527" fill="#06162A" />
<circle cx="385.965" cy="574.965" r="2.96527" fill="#06162A" />
<circle cx="322.965" cy="574.965" r="2.96527" fill="#06162A" />
<circle cx="259.249" cy="575.416" r="2.96527" fill="#06162A" />
<circle cx="201.638" cy="574.568" r="2.96527" fill="#06162A" />
<circle cx="136.965" cy="574.568" r="2.96527" fill="#06162A" />
<circle cx="73.9653" cy="576.262" r="2.96527" fill="#06162A" />
<circle cx="13.9653" cy="577.965" r="2.96527" fill="#06162A" />
<path d="M56.7639 45.479L69.4722 56.4928L82.1805 45.479" stroke="black" stroke-width="4" />
<path d="M8.47162 38.7016L21.1799 49.7154L33.8882 38.7016" stroke="black" stroke-width="4" />
<path d="M63.5413 16.675L76.2496 27.6889L88.9579 16.675" stroke="black" stroke-width="4" />
<path d="M133.014 20.9098L145.722 31.9236L158.431 20.9098" stroke="black" stroke-width="4" />
<path d="M255.86 390.298H210.11L211.805 458.076H255.86V390.298Z" fill="#0F1F4C" />
<path d="M244.847 401.736H221.125V446.638H244.847V401.736Z" fill="#142553" />
</svg>
</div>
</div>
</div>
</div>
</div>
.hero {
position: relative;
background-color: $blueElis;
font-size: 16px;
}
.hero--wrapper {
display: flex;
column-gap: 4.1875em;
padding-top: 7.125em;
}
.hero--blok-left {
flex: 0 0 50.37%;
margin-top: 5.6875em;
}
.hero--descr {
margin-bottom: 0.444em;
#include SWCL(1.125em, 500, $pigeonBlue, 1.6875);
}
.hero--title {
margin-bottom: 0.46875em;
#include SWCL(4em, 700, $darkBlue, 1.1875);
}
.hero--subtitle {
#include SWCL(1.125em, 400, $marengo, 2);
margin-bottom: 2.222em;
}
.hero--button {
}
.hero--block-right {
display: flex;
align-items: flex-end;
}
.hero--img {
width: 36.5em;
height: auto;
& svg {
max-width: 100%;
height: auto;
}
}
// Adaptive
#media only screen and (max-width: 1024px) {
.header {
font-size: 14px;
}
}
.hero--img {
width: 100%;
height: auto;
max-width: 36.5em;
}
.hero {
position: relative;
background-color: $blueElis;
font-size: 16px;
}
.hero--wrapper {
display: flex;
column-gap: 4.1875em;
padding-top: 7.125em;
}
.hero--blok-left {
flex: 0 0 50.37%;
margin-top: 5.6875em;
}
.hero--descr {
margin-bottom: 0.444em;
#include SWCL(1.125em, 500, $pigeonBlue, 1.6875);
}
.hero--title {
margin-bottom: 0.46875em;
#include SWCL(4em, 700, $darkBlue, 1.1875);
}
.hero--subtitle {
#include SWCL(1.125em, 400, $marengo, 2);
margin-bottom: 2.222em;
}
.hero--button {}
.hero--block-right {
display: flex;
align-items: flex-end;
}
svg {
width: 100%;
height: 100%;
max-width:584px;
max-height:620px;
}
// Adaptive
#media only screen and (max-width: 1024px) {
.header {
font-size: 14px;
}
}
<div class="hero">
<div class="container">
<div class="hero--wrapper">
<div class="hero--blok-left">
<div class="hero--descr">Welcome to Besnik Agency</div>
<h1 class="hero--title">Discover a place you’ll love to live.</h1>
<p class="hero--subtitle">
Get the best real estate deals first, before they hit the mass market! hot foreclosure deals with one simple search
</p>
<button class="button hero--button">More About Us</button>
</div>
<div class="hero--block-right">
<div class="heroimg">
<svg width="584" height="620" viewBox="0 0 584 620" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M241.032 610.998L231.713 201.367L58.0327 201.367L60.5743 610.998H241.032Z" fill="#F1F6FF" />
<path d="M302.879 608.881V337.77L512.566 343.89V608.881H302.879Z" fill="#FEFCED" />
<path d="M58.033 201.367L60.5747 610.998H159.276L154.616 201.367H58.033Z" fill="#7398F7" />
<path d="M182.997 159.855H110.983V201.369H182.997V159.855Z" fill="#1F1D42" />
<path d="M110.983 159.855V201.369H159.698C136.315 196.285 129.057 171.575 128.351 159.855H110.983Z" fill="#1F1717" />
<path
d="M152.498 89.1111L144.026 88.2639C141.908 87.4167 141.484 77.6737 149.533 79.7917C155.971 81.4861 154.192 86.7107 152.498 89.1111Z"
fill="#0E173D"
/>
<path d="M152.498 89.112L144.026 88.2648V100.549L152.498 101.397V89.112Z" fill="#0E173D" />
<path d="M144.025 100.548L152.497 101.396L183.845 123.847H110.56L144.025 100.548Z" fill="#1F1D42" />
<path d="M323.636 403.007H316.859V451.298H313.893V456.381H326.602V449.604H323.636V403.007Z" fill="#1B2A63" />
<path d="M512.566 612.269H302.879V473.325L512.566 476.385V612.269Z" fill="#A3BDFF" />
<path d="M448.177 242.458L221.546 235.257L302.879 337.77L520.614 344.124L448.177 242.458Z" fill="#063183" />
<path d="M302.879 337.77L520.614 344.124L316.011 238.258L221.546 235.257L302.879 337.77Z" fill="#7087FB" />
<path
d="M221.546 235.257L302.879 337.77V605.915L152.921 613.117V476.291V337.77L193.164 284.819H184.268L221.546 235.257Z"
fill="#CFDEF3"
/>
<path d="M250.776 297.527H206.297V350.902H250.776V297.527Z" fill="#0C183F" />
<rect x="211.38" y="303.033" width="15.2499" height="18.6388" fill="#1F326B" />
<rect x="232.56" y="303.033" width="15.2499" height="18.6388" fill="#1F326B" />
<rect x="232.56" y="328.451" width="15.2499" height="18.6388" fill="#1F326B" />
<path d="M110.562 123.846H183.846H188.929V125.964H104.631V123.846H110.562Z" stroke="black" />
<path d="M150.804 378.012H303.727H512.99" stroke="black" stroke-width="4" />
<path d="M151.652 486.457H301.186H511.297" stroke="black" stroke-width="5" />
<path d="M151.652 486.457H301.186" stroke="#5267FA" stroke-width="6" />
<rect x="211.38" y="328.451" width="15.2499" height="18.6388" fill="#1F326B" />
<path d="M113.525 289.901H91.0741V350.901H115.22L113.525 289.901Z" fill="#0E173D" />
<path d="M113.525 395.381H91.0741V456.381H115.22L113.525 395.381Z" fill="#0C193F" />
<path d="M114.797 267.027H91.9224V220.43C97.3446 205.18 106.325 214.076 110.138 220.43L114.797 267.027Z" fill="#1F1D42" />
<path
d="M352.019 247.118H327.873L306.693 240.763V201.368V199.25L327.873 198.677L353.714 197.979L353.597 201.368L352.019 247.118Z"
fill="#1F326B"
/>
<path d="M352.019 247.118H327.874V201.368V198.677L353.714 197.979L353.597 201.368L352.019 247.118Z" fill="#FEFDE8" />
<path d="M306.693 199.25L327.873 198.677L353.714 197.979L353.597 201.368H327.873H306.693V199.25Z" fill="#112F7F" />
<rect x="180.881" y="125.966" width="1.69444" height="33.8888" fill="#0C1942" />
<rect x="241.032" y="166.632" width="1.69444" height="189.777" transform="rotate(90 241.032 166.632)" fill="#0C1942" />
<rect x="241.032" y="199.673" width="1.69444" height="189.777" transform="rotate(90 241.032 199.673)" fill="#0C1942" />
<path d="M58.0009 231.867H155.855H232.501" stroke="#18265D" stroke-width="4" />
<rect x="241.032" y="186.118" width="1.69444" height="189.777" transform="rotate(90 241.032 186.118)" fill="#081334" />
<rect x="110.56" y="125.966" width="1.69444" height="33.8888" fill="#132355" />
<rect x="128.352" y="131.895" width="1.69444" height="27.9582" fill="#132355" />
<rect x="131.741" y="131.895" width="1.69444" height="27.9582" fill="#132355" />
<rect x="136.824" y="131.895" width="1.69444" height="27.9582" fill="#132355" />
<path
d="M221.546 235.257L227.259 244.153M302.879 337.77L296.72 330.145M227.259 244.153L453.308 249.66M227.259 244.153L237.524 256.861M237.524 256.861L462.061 261.944M237.524 256.861L248.816 270.84M248.816 270.84L470.813 274.229M248.816 270.84L257.976 282.18M257.976 282.18L479.566 286.514M257.976 282.18L269.004 295.833M269.004 295.833L488.42 298.939M269.004 295.833L278.243 307.27M278.243 307.27L497.739 312.019M278.243 307.27L290.561 322.52M290.561 322.52H505.221M290.561 322.52L296.72 330.145M296.72 330.145L512.918 333.322"
stroke="#A3BDFF"
stroke-width="4"
/>
<rect x="83.4506" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
<rect x="51.2557" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
<rect x="239.338" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
<path d="M377.436 511.026H363.88V579.651H377.436V511.026Z" fill="#0C183F" />
<path d="M363.88 579.651H377.436V545.339H363.88V579.651Z" fill="#17275F" />
<path d="M489.691 548.304H467.24V580.499H489.691V548.304Z" fill="#17275F" />
<path d="M148.687 79.7914L146.992 1" stroke="black" stroke-width="3" />
<rect x="210.534" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
<rect x="151.227" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
<rect x="77.5193" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
<rect x="204.602" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
<rect x="204.602" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
<rect x="145.298" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
<rect x="158.853" y="131.895" width="1.69444" height="27.9582" fill="#121B3A" />
<rect x="162.241" y="131.895" width="1.69444" height="27.9582" fill="#121B3A" />
<rect x="152.921" y="131.895" width="1.69444" height="27.9582" fill="#121B3A" />
<path d="M467.24 580.499H489.691V564.402H467.24V580.499Z" fill="#0F1C49" />
<path d="M503.67 556.353H495.198V574.145L503.67 573.721V556.353Z" fill="#FAF2E2" />
<path
d="M200.365 511.449V548.727H204.601V604.643H211.803V546.185H207.143V517.803H248.657V546.185H241.879V604.643H246.115V548.727H254.164V511.449H200.365Z"
fill="#0D0808"
/>
<path d="M241.881 546.186V604.644H211.805V546.186H207.145V517.804H248.659V546.186H241.881Z" fill="#17275F" />
<path d="M584 611.421H0V620H584V611.421Z" fill="#091D39" />
<path
d="M571.873 611.422V576.686M510.026 576.686V611.422M446.485 576.686V611.422M385.909 576.686V611.422M323.214 576.686V611.422M259.249 576.686V611.422M201.638 576.686V611.422M136.826 576.686V611.422M74.132 576.686V611.422M14.4031 576.686V611.422"
stroke="black"
stroke-width="4"
/>
<path
d="M571.873 582C558.6 593.579 527.648 609.789 510.026 582C495.623 590.755 462.751 602.78 446.485 581.769C433.776 590.241 403.869 603.288 385.908 587.699C373.341 593.489 343.209 601.594 323.214 587.699C305.705 591.371 268.399 596.511 259.249 587.699C247.388 591.371 219.26 596.511 201.638 587.699C184.553 591.371 147.67 596.511 136.826 587.699C118.752 593.912 89.8057 602.102 74.1318 587.699C57.0807 591.371 23.3695 597.311 13.5004 588.5"
stroke="black"
stroke-width="3"
/>
<circle cx="571.965" cy="574.965" r="2.96527" fill="#06162A" />
<circle cx="510.026" cy="574.568" r="2.96527" fill="#06162A" />
<circle cx="446.484" cy="575.416" r="2.96527" fill="#06162A" />
<circle cx="385.965" cy="574.965" r="2.96527" fill="#06162A" />
<circle cx="322.965" cy="574.965" r="2.96527" fill="#06162A" />
<circle cx="259.249" cy="575.416" r="2.96527" fill="#06162A" />
<circle cx="201.638" cy="574.568" r="2.96527" fill="#06162A" />
<circle cx="136.965" cy="574.568" r="2.96527" fill="#06162A" />
<circle cx="73.9653" cy="576.262" r="2.96527" fill="#06162A" />
<circle cx="13.9653" cy="577.965" r="2.96527" fill="#06162A" />
<path d="M56.7639 45.479L69.4722 56.4928L82.1805 45.479" stroke="black" stroke-width="4" />
<path d="M8.47162 38.7016L21.1799 49.7154L33.8882 38.7016" stroke="black" stroke-width="4" />
<path d="M63.5413 16.675L76.2496 27.6889L88.9579 16.675" stroke="black" stroke-width="4" />
<path d="M133.014 20.9098L145.722 31.9236L158.431 20.9098" stroke="black" stroke-width="4" />
<path d="M255.86 390.298H210.11L211.805 458.076H255.86V390.298Z" fill="#0F1F4C" />
<path d="M244.847 401.736H221.125V446.638H244.847V401.736Z" fill="#142553" />
</svg>
</div>
</div>
</div>
</div>
</div>
Like the above?(run snippet)
Idea:
Use percentage (100%) as width,height of svg
As an easy workaround you could set your background-size using a relative unit like %, vw, vmin or vmax like so:
/* small devices */
.hero{
background-size: 50%;
}
/* large devices */
#media (min-width:1024px){
.hero{
background-size: 36.5em 38.75em;
}
}
You original background size will be applied for viewports larger than 1024px.
You will of course need to tweak the values to get your desired results.

How to make a star or a cross using an svg ellipse?

I am creating an ellipse in svg. In this ellipse I am trying to give a shape like a star or cross. I can not use anything else other than ellipse. This is what I have done so far.
<ellipse cx="96" cy="126" rx="5" ry="5" fill="#EF4444" stroke="#EF4444" stroke-width="19" stroke-dasharray="4" opacity="1" transform="translate(139 50)"></ellipse>
All I did is, added the stroke-dasharray="4" and it became like a cross. But it is not proper yet. Can anyone help me on this please.
This is how it looks like now. Which is not a star or a cross.
I am not entirely sure what you mean by
I can not use anything else other than ellipse
If you strictly follow that restriction, then your request would seem close to impossible.
Your first attempt is a nice idea, but unfortunately it may have issues. Creating circles or ellipses with stroke widths that are greater than the radius (technically, more than double the radius), can not always be trusted to render correctly.
The approach that Robert suggested is better and more flexible, but will require the use of SVG elements other than <ellipse>
For example take the following design.
svg {
width: 400px;
}
<svg viewBox="0 0 100 70">
<ellipse cx="50" cy="35" rx="40" ry="28"
fill="none" stroke="black" stroke-width="1"/>
<g class="cross">
<rect x="0" y="20" width="100" height="30" transform="rotate(35, 50,35)"/>
<rect x="0" y="20" width="100" height="30" transform="rotate(-35, 50,35)"/>
</g>
</svg>
If we turn the ellipse into a clip path, and apply it to the cross, we get this:
svg {
width: 400px;
}
<svg viewBox="0 0 100 70">
<defs>
<clipPath id="oval">
<ellipse cx="50" cy="35" rx="40" ry="28"/>
</clipPath>
</defs>
<g class="cross" clip-path="url(#oval)">
<rect x="0" y="20" width="100" height="30" transform="rotate(35, 50,35)"/>
<rect x="0" y="20" width="100" height="30" transform="rotate(-35, 50,35)"/>
</g>
</svg>
You can make the cross part look however you like, and still clip it with the ellipse.
Another idea. Cut a cross from a circle using four ellipses
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
width="400" height="400" viewBox="0 0 400 400" >
<circle cx="200" cy="200" r="100" fill="crimson" />
<circle cx="200" cy="200" r="40" fill="none" stroke="black" />
<circle cx="200" cy="200" r="2" fill="black" />
<polyline fill="none" stroke="black" points="0,0 400,400" />
<polyline fill="none" stroke="black" points="0,400 400,0" />
<ellipse transform="rotate(45 100 125)" cx="80" cy="107" rx="102" ry="50" fill="gold" opacity="0.5" />
<ellipse transform="translate(125 -20) rotate(135 100 125)" cx="45" cy="80" rx="100" ry="50" fill="gold" opacity="0.5" />
<ellipse transform="translate(125 -20) rotate(225 100 125)" cx="-90" cy="40" rx="100" ry="50" fill="gold" opacity="0.5" />
<ellipse transform="translate(125 -20) rotate(315 100 125)" cx="-125" cy="175" rx="100" ry="50" fill="gold" opacity="0.5" />
</svg>
Then you can use these ellipses as a mask.
.container {
width:75vw;
height:auto;
}
<div class="container">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
viewBox="0 50 400 400" preserveAspectRatio="xMinYMin meet">
<defs>
<mask id="msk">
<rect width="100%" height="100%" fill="white" />
<g id="group" fill="black">
<ellipse transform="rotate(45 100 125)" cx="80" cy="107" rx="102" ry="50" />
<ellipse transform="translate(125 -20) rotate(135 100 125)" cx="45" cy="80" rx="100" ry="50" />
<ellipse transform="translate(125 -20) rotate(225 100 125)" cx="-90" cy="40" rx="100" ry="50" />
<ellipse transform="translate(125 -20) rotate(315 100 125)" cx="-125" cy="175" rx="100" ry="50" />
</g>
</mask>
</defs>
<image href="https://upload.wikimedia.org/wikipedia/commons/thumb/f/fc/Foro_Romano.jpg/1200px-Foro_Romano.jpg "
width="100%" height="100%" />
<circle mask="url(#msk)" cx="200" cy="200" r="100" fill="crimson" opacity="0.7" />
</svg>
</div>

How to create a blurred label background with SVG filters?

I would like to have a good working approach for the following problem:
On a bar chart with bars filled with different but unknown colors, I would like to put labels with a fixed black color such that they are readable.
The approach I am searching for should look such as in the title bar of the window in the image. The label is black, it resides on top of a blurred white background which sits on top of the bar of any color.
Is there a way to do it with SVG filters?
Below are some approaches I tried:
.black {
fill: black;
}
.blue {
fill: blue;
}
.red {
fill: red;
}
.yellow {
fill: yellow;
}
.label{
fill: black;
font-size: 14px;
}
.label-background{
fill: white;
font-size: 16px;
}
.text-background{
paint-order: stroke;
stroke: #fff;
fill: black;
stroke-width: 5px;
}
.header{
font-size: 20px;
}
.background{
fill: white;
opacity: 0.6;
}
<svg width="500" height="500">
<defs>
<filter x="-0.05" y="-0.1" width="1.08" height="1.2" id="solid">
<feFlood flood-color="lightgrey"/>
<feComposite in="SourceGraphic" operator="xor" />
</filter>
</defs>
<g class="row-1" transform="translate(0,30)">
<text class="header" x="20" y="-10">text label on top of bar </text>
<g>
<rect class="black" width=100 height=30></rect>
<text class="label" x="20" y="20">my text label</text>
</g>
<g transform="translate(120,0)">
<rect class="blue" width=100 height=30></rect>
<text class="label" x="20" y="20">my text label</text>
</g>
<g transform="translate(240,0)">
<rect class="red" width=100 height=30></rect>
<text class="label" x="20" y="20">my text label</text>
</g>
<g transform="translate(360,0)">
<rect class="yellow" width=100 height=30></rect>
<text class="label" x="20" y="20">my text label</text>
</g>
</g>
<g class="row-2" transform="translate(0,100)">
<text class="header" x="20" y="-10">text label on top of rect.background on top of bar </text>
<g>
<rect class="black" width=100 height=30></rect>
<rect class="background" x=17 y=6 width=78 height=19></rect>
<text class="label" x="20" y="20">my text label</text>
</g>
<g transform="translate(120,0)">
<rect class="blue" width=100 height=30></rect>
<rect class="background" x=17 y=6 width=78 height=19></rect>
<text class="label" x="20" y="20">my text label</text>
</g>
<g transform="translate(240,0)">
<rect class="red" width=100 height=30></rect>
<rect class="background" x=17 y=6 width=78 height=19></rect>
<text class="label" x="20" y="20">my text label</text>
</g>
<g transform="translate(360,0)">
<rect class="yellow" width=100 height=30></rect>
<rect class="background" x=17 y=6 width=78 height=19></rect>
<text class="label" x="20" y="20">my text label</text>
</g>
</g>
<g class="row-3" transform="translate(0, 170)">
<text class="header" x="20" y="-10">text label with filter #solid on top of bar </text>
<g>
<rect class="black" width=100 height=30></rect>
<text class="label" filter="url(#solid)" x="20" y="20">my text label</text>
</g>
<g transform="translate(120,0)">
<rect class="blue" width=100 height=30></rect>
<text class="label" filter="url(#solid)" x="20" y="20">my text label</text>
</g>
<g transform="translate(240,0)">
<rect class="red" width=100 height=30></rect>
<text class="label" filter="url(#solid)" x="20" y="20">my text label</text>
</g>
<g transform="translate(360,0)">
<rect class="yellow" width=100 height=30></rect>
<text class="label" filter="url(#solid)" x="20" y="20">my text label</text>
</g>
</g>
<g class="row-4" transform="translate(0, 240)">
<text class="header" x="20" y="-10">text label on top of larger text label with background color on top of bar </text>
<g>
<rect class="black" width=100 height=30></rect>
<text class="label-background" x="18" y="22">my text label</text>
<text class="label" x="20" y="20">my text label</text>
</g>
<g transform="translate(120,0)">
<rect class="blue" width=100 height=30></rect>
<text class="label-background" x="18" y="22">my text label</text>
<text class="label" x="20" y="20">my text label</text>
</g>
<g transform="translate(240,0)">
<rect class="red" width=100 height=30></rect>
<text class="label-background" x="18" y="22">my text label</text>
<text class="label" x="20" y="20">my text label</text>
</g>
<g transform="translate(360,0)">
<rect class="yellow" width=100 height=30></rect>
<text class="label-background" x="18" y="22">my text label</text>
<text class="label" x="20" y="20">my text label</text>
</g>
</g>
<g class="row-5" transform="translate(0, 310)">
<text class="header" x="20" y="-10">text label with paint-order: stroke on top of bar </text>
<g>
<rect class="black" width=100 height=30></rect>
<text class="label text-background" x="20" y="20">my text label</text>
</g>
<g transform="translate(120,0)">
<rect class="blue" width=100 height=30></rect>
<text class="label text-background" x="20" y="20">my text label</text>
</g>
<g transform="translate(240,0)">
<rect class="red" width=100 height=30></rect>
<text class="label text-background" x="20" y="20">my text label</text>
</g>
<g transform="translate(360,0)">
<rect class="yellow" width=100 height=30></rect>
<text class="label text-background" x="20" y="20">my text label</text>
</g>
</g>
</svg>
Since you're asking for an SVG filter solution:
Start with SourceAlpha, which gives you a black silhouette of the element (i.e. the text), and then blur it with feGaussianBlur to create a soft shadow.
This shadow will be black, so use feColorMatrix to make it white.
Finally, put the original text on top of the shadow using feBlend.
References:
SVG Drop Shadows (see Example 3)
Finessing feColorMatrix
.black {
fill: black;
}
.blue {
fill: blue;
}
.red {
fill: red;
}
.yellow {
fill: yellow;
}
.label {
fill: black;
font-size: 14px;
}
<svg width="500" height="80" color-interpolation-filters="sRGB">
<defs>
<filter id="shadow">
<feGaussianBlur in="SourceAlpha" stdDeviation="3" result="blur" />
<feColorMatrix in="blur" type="matrix" values="0 0 0 0 1
0 0 0 0 1
0 0 0 0 1
0 0 0 8 0" result="white" />
<feColorMatrix in="white" type="matrix" values="1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 .8 0" result="dim" />
<feBlend in="SourceGraphic" in2="dim" mode="normal" />
</filter>
</defs>
<g class="row-1" transform="translate(10,30)">
<text class="header" x="0" y="-10">feGaussianBlur on SourceAlpha</text>
<g>
<rect class="black" width=100 height=30></rect>
<text class="label" x="20" y="20" filter="url(#shadow)">my text label</text>
</g>
<g transform="translate(120,0)">
<rect class="blue" width=100 height=30></rect>
<text class="label" x="20" y="20" filter="url(#shadow)">my text label</text>
</g>
<g transform="translate(240,0)">
<rect class="red" width=100 height=30></rect>
<text class="label" x="20" y="20" filter="url(#shadow)">my text label</text>
</g>
<g transform="translate(360,0)">
<rect class="yellow" width=100 height=30></rect>
<text class="label" x="20" y="20" filter="url(#shadow)">my text label</text>
</g>
</g>
</svg>
Not thoroughly tested, but building up text-shadow with multiple values has the desired effect :
svg text {
text-shadow: 0px 0px 2px white,
0px 0px 4px white,
0px 0px 6px white,
0px 0px 8px white,
0px 0px 10px white;
}
Working example :
.black {
fill: black;
}
.blue {
fill: blue;
}
.red {
fill: red;
}
.yellow {
fill: yellow;
}
.label{
fill: black;
font-size: 14px;
}
svg g.row-1 text {
text-shadow: 0px 0px 2px white,
0px 0px 4px white,
0px 0px 6px white,
0px 0px 8px white,
0px 0px 10px white;
}
<svg width="500" height="500">
<defs>
<filter x="-0.05" y="-0.1" width="1.08" height="1.2" id="solid">
<feFlood flood-color="lightgrey"/>
<feComposite in="SourceGraphic" operator="xor" />
</filter>
</defs>
<g class="row-1" transform="translate(0,30)">
<g>
<rect class="black" width=100 height=30></rect>
<text class="label" x="20" y="20">my text label</text>
</g>
<g transform="translate(120,0)">
<rect class="blue" width=100 height=30></rect>
<text class="label" x="20" y="20">my text label</text>
</g>
<g transform="translate(240,0)">
<rect class="red" width=100 height=30></rect>
<text class="label" x="20" y="20">my text label</text>
</g>
<g transform="translate(360,0)">
<rect class="yellow" width=100 height=30></rect>
<text class="label" x="20" y="20">my text label</text>
</g>
</g>
</svg>

How do I add a Google One style multi-color border to a circular image?

I am creating a website for the Google DSC club at my University, and I wanted to add a Google One style border to the circular portfolio images on the site.
I was wondering how to accomplish this using CSS, but pre-rendered Photoshop or Illustrator tricks would also do.
I tried to modify some the code as given in this answer, but I wasn't able to achieve the perfect effect.
.test {
margin: 25px 0;
width: 200px;
height: 200px;
border-radius: 50%;
border: 12px solid transparent;
background-size: 100% 100%, 50% 50%, 50% 50%, 50% 50%, 50% 50%;
background-repeat: no-repeat;
background-image: linear-gradient(white, white),
linear-gradient(30deg, #ea4335 36%, #4285f4 30%),
linear-gradient(120deg, #4285f4 36%, #34a853 30%),
linear-gradient(300deg, #fbbc04 36%, #ea4335 30%),
linear-gradient(210deg, #34a853 36%, #fbbc04 30%);
background-position: center center, left top, right top, left bottom, right bottom;
background-origin: content-box, border-box, border-box, border-box, border-box;
background-clip: content-box, border-box, border-box, border-box, border-box;
transform: rotate(90deg);
}
<div class="test"></div>
As you can see, the border colors are not aligned correctly.
Is there any way to accomplish this using an easier method?
Thank you!
SVG option
To create multi-colored sectors of a circle, use stroke-dasharray
Calculation of lengths of lines and spaces:
For the radius R = 100px circumference = 2 * 3.1415 * 100 = 628.3 px
To get the line equal to one fourth of the circle, we calculate the attributes stroke-dasharray
628.3 / 4 = 157.075 Space will be 3/4 of the circle length = 471px
But since the length of the blue, red and green sectors is a little more than a quarter of a circle, we add this difference. stroke-dasharray = "183.255 445.045"
stroke-dashoffset = "78.54" shifts the beginning of the sector by 1/8 of the circumference
Example for one sector
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
width="250" height="250" viewBox="0 0 250 250" >
<circle cx="125" cy="125" r="100" fill="none" stroke="#d3d3d3" stroke-width="8" />
<circle id="blue" cx="125" cy="125" r="100" fill="none" stroke="#4285F4" stroke-width="8" stroke-dasharray="183.255 445.045" stroke-dashoffset="78.54" />
</svg>
And also we set attributes for other color sectors.
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
width="250" height="250" viewBox="0 0 250 250" >
<circle id="blue" cx="125" cy="125" r="100" fill="none" stroke="#4285F4" stroke-width="8" stroke-dasharray="183.255 445.045" stroke-dashoffset="78.54" />
<circle id="red" cx="125" cy="125" r="100" fill="none" stroke="#EA4335" stroke-width="8" stroke-dasharray="203.255 425.045" stroke-dashoffset="281.9" />
<circle id="gold" cx="125" cy="125" r="100" fill="none" stroke="#FABB04" stroke-width="8" stroke-dasharray="78.54 549.76" stroke-dashoffset="340 " />
<circle id="green" cx="125" cy="125" r="100" fill="none" stroke="#34A852" stroke-width="8" stroke-dasharray="183.255 445.045" stroke-dashoffset="525.225 " />
</svg>
Add an image and cut it using a mask to fit the circles
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
width="40%" height="40%" viewBox="0 0 250 250" >
<defs>
<mask id="msk1">
<rect width="100%" height="100%" fill="black" />
<circle cx="125" cy="125" r="100" fill="white" stroke-width="20" stroke="black" />
</mask>
</defs>
<image xlink:href="https://i.stack.imgur.com/UsGg5.jpg" x="0" y="23" width="100%" height="100%" mask="url(#msk1)" />
<circle id="blue" cx="125" cy="125" r="100" fill="none" stroke="#4285F4" stroke-width="8" stroke-dasharray="183.2 445.1" stroke-dashoffset="78.54" />
<circle id="red" cx="125" cy="125" r="100" fill="none" stroke="#EA4335" stroke-width="8" stroke-dasharray="203.3 425.1" stroke-dashoffset="281.9" />
<circle id="gold" cx="125" cy="125" r="100" fill="none" stroke="#FABB04" stroke-width="8" stroke-dasharray="80 549.7" stroke-dashoffset="345 " />
<circle id="green" cx="125" cy="125" r="100" fill="none" stroke="#34A852" stroke-width="8" stroke-dasharray="183.2 445.1" stroke-dashoffset="525.2 " />
</svg>
The solution is adaptive and works the same in all modern browsers, including IE11,Edge
UPDATE
OP did not ask, but perhaps this supplement will be useful to him or someone else.
SVG+CSS animation
To spice up your application I add animation options.
#1. Animation of rotation of the stroke around the image
Wrap all the circles that form a multicolored line with the group tag
<g>
fill ="none" replace with fill ="transparent" for the
animation to work when you hover over the whole circle
.student {
background: rgb(238,174,202);
background: linear-gradient(90deg, rgba(238,174,202,1) 0%, rgba(148,208,233,1) 100%);
}
.container {
display: inline-block;
width:25%;
}
#gr1 {
transform-origin:125px 125px;
-webkit-transition: -webkit-transform 1s ease-in-out;
transition: transform 1s ease-in-out;
}
#gr1:hover {
-webkit-transform: rotate(720deg);
transform: rotate(720deg);
}
<div class="student">
<div class="container">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
viewBox="0 0 250 250" >
<defs>
<mask id="msk1">
<rect width="100%" height="100%" fill="black" />
<circle cx="125" cy="125" r="100" fill="white" stroke-width="20" stroke="black" />
</mask>
</defs>
<image id="img" xlink:href="https://i.stack.imgur.com/IzNqO.jpg" x="0" y="24" width="100%" height="100%" mask="url(#msk1)" />
<g id="gr1">
<circle id="blue" cx="125" cy="125" r="100" fill="transparent" stroke="#4285F4" stroke-width="8" stroke-dasharray="183.2 445.1" stroke-dashoffset="78.54" />
<circle id="red" cx="125" cy="125" r="100" fill="none" stroke="#EA4335" stroke-width="8" stroke-dasharray="203.3 425.1" stroke-dashoffset="281.9" />
<circle id="gold" cx="125" cy="125" r="100" fill="none" stroke="#FABB04" stroke-width="8" stroke-dasharray="80 549.7" stroke-dashoffset="345 " />
<circle id="green" cx="125" cy="125" r="100" fill="none" stroke="#34A852" stroke-width="8" stroke-dasharray="183.2 445.1" stroke-dashoffset="525.2 " />
</g>
</svg>
</div>
<div class="container">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
viewBox="0 0 250 250" >
<defs>
<mask id="msk1">
<rect width="100%" height="100%" fill="black" />
<circle cx="125" cy="125" r="100" fill="white" stroke-width="20" stroke="black" />
</mask>
</defs>
<image id="img" xlink:href="https://i.stack.imgur.com/d4AlZ.jpg" x="0" y="25" width="100%" height="100%" mask="url(#msk1)" />
<g id="gr1">
<circle id="blue" cx="125" cy="125" r="100" fill="transparent" stroke="#4285F4" stroke-width="8" stroke-dasharray="183.2 445.1" stroke-dashoffset="78.54" />
<circle id="red" cx="125" cy="125" r="100" fill="none" stroke="#EA4335" stroke-width="8" stroke-dasharray="203.3 425.1" stroke-dashoffset="281.9" />
<circle id="gold" cx="125" cy="125" r="100" fill="none" stroke="#FABB04" stroke-width="8" stroke-dasharray="80 549.7" stroke-dashoffset="345 " />
<circle id="green" cx="125" cy="125" r="100" fill="none" stroke="#34A852" stroke-width="8" stroke-dasharray="183.2 445.1" stroke-dashoffset="525.2 " />
</g>
</svg>
</div>
<div class="container">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
viewBox="0 0 250 250" >
<defs>
<mask id="msk1">
<rect width="100%" height="100%" fill="black" />
<circle cx="125" cy="125" r="100" fill="white" stroke-width="20" stroke="black" />
</mask>
</defs>
<image id="img" xlink:href="https://i.stack.imgur.com/YG6VN.png" x="0" y="25" width="100%" height="100%" mask="url(#msk1)" />
<g id="gr1">
<circle id="blue" cx="125" cy="125" r="100" fill="transparent" stroke="#4285F4" stroke-width="8" stroke-dasharray="183.2 445.1" stroke-dashoffset="78.54" />
<circle id="red" cx="125" cy="125" r="100" fill="none" stroke="#EA4335" stroke-width="8" stroke-dasharray="203.3 425.1" stroke-dashoffset="281.9" />
<circle id="gold" cx="125" cy="125" r="100" fill="none" stroke="#FABB04" stroke-width="8" stroke-dasharray="80 549.7" stroke-dashoffset="345 " />
<circle id="green" cx="125" cy="125" r="100" fill="none" stroke="#34A852" stroke-width="8" stroke-dasharray="183.2 445.1" stroke-dashoffset="525.2 " />
</g>
</svg>
</div>
</div>
2.# Animation of image rotation when hovering
CSS rules are used to implement rotation of images
#img {
transform-origin:125px 125px;
-webkit-transition: -webkit-transform 1s ease-in-out;
transition: transform 1s ease-in-out;
}
#img:hover {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
.student {
background: rgb(238,174,202);
background: linear-gradient(90deg, rgba(238,174,202,1) 0%, rgba(148,208,233,1) 100%);
}
.container {
display: inline-block;
width:25%;
}
#img {
transform-origin:125px 125px;
-webkit-transition: -webkit-transform 1s ease-in-out;
transition: transform 1s ease-in-out;
}
#img:hover {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
<div class="student">
<div class="container">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
viewBox="0 0 250 250" >
<defs>
<mask id="msk1">
<rect width="100%" height="100%" fill="black" />
<circle cx="125" cy="125" r="100" fill="white" stroke-width="20" stroke="black" />
</mask>
</defs>
<image id="img" xlink:href="https://i.stack.imgur.com/IzNqO.jpg" x="0" y="24" width="100%" height="100%" mask="url(#msk1)" />
<circle id="blue" cx="125" cy="125" r="100" fill="none" stroke="#4285F4" stroke-width="8" stroke-dasharray="183.2 445.1" stroke-dashoffset="78.54" />
<circle id="red" cx="125" cy="125" r="100" fill="none" stroke="#EA4335" stroke-width="8" stroke-dasharray="203.3 425.1" stroke-dashoffset="281.9" />
<circle id="gold" cx="125" cy="125" r="100" fill="none" stroke="#FABB04" stroke-width="8" stroke-dasharray="80 549.7" stroke-dashoffset="345 " />
<circle id="green" cx="125" cy="125" r="100" fill="none" stroke="#34A852" stroke-width="8" stroke-dasharray="183.2 445.1" stroke-dashoffset="525.2 " />
</svg>
</div>
<div class="container">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
viewBox="0 0 250 250" >
<defs>
<mask id="msk1">
<rect width="100%" height="100%" fill="black" />
<circle cx="125" cy="125" r="100" fill="white" stroke-width="20" stroke="black" />
</mask>
</defs>
<image id="img" xlink:href="https://i.stack.imgur.com/d4AlZ.jpg" x="0" y="25" width="100%" height="100%" mask="url(#msk1)" />
<circle id="blue" cx="125" cy="125" r="100" fill="none" stroke="#4285F4" stroke-width="8" stroke-dasharray="183.2 445.1" stroke-dashoffset="78.54" />
<circle id="red" cx="125" cy="125" r="100" fill="none" stroke="#EA4335" stroke-width="8" stroke-dasharray="203.3 425.1" stroke-dashoffset="281.9" />
<circle id="gold" cx="125" cy="125" r="100" fill="none" stroke="#FABB04" stroke-width="8" stroke-dasharray="80 549.7" stroke-dashoffset="345 " />
<circle id="green" cx="125" cy="125" r="100" fill="none" stroke="#34A852" stroke-width="8" stroke-dasharray="183.2 445.1" stroke-dashoffset="525.2 " />
</svg>
</div>
<div class="container">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
viewBox="0 0 250 250" >
<defs>
<mask id="msk1">
<rect width="100%" height="100%" fill="black" />
<circle cx="125" cy="125" r="100" fill="white" stroke-width="20" stroke="black" />
</mask>
</defs>
<image id="img" xlink:href="https://i.stack.imgur.com/YG6VN.png" x="0" y="25" width="100%" height="100%" mask="url(#msk1)" />
<circle id="blue" cx="125" cy="125" r="100" fill="none" stroke="#4285F4" stroke-width="8" stroke-dasharray="183.2 445.1" stroke-dashoffset="78.54" />
<circle id="red" cx="125" cy="125" r="100" fill="none" stroke="#EA4335" stroke-width="8" stroke-dasharray="203.3 425.1" stroke-dashoffset="281.9" />
<circle id="gold" cx="125" cy="125" r="100" fill="none" stroke="#FABB04" stroke-width="8" stroke-dasharray="80 549.7" stroke-dashoffset="345 " />
<circle id="green" cx="125" cy="125" r="100" fill="none" stroke="#34A852" stroke-width="8" stroke-dasharray="183.2 445.1" stroke-dashoffset="525.2 " />
</svg>
</div>
</div>
tiny svg solution with masks
<svg viewbox="-5 -5 10 10" height="90vh">
<defs>
<mask id="mask1">
<circle r="4.5" stroke="white" fill="black" stroke-width="0.5"></circle>
</mask>
<mask id="mask2">
<circle r="4"fill="white"></circle>
</mask>
</defs>
<g mask="url(#mask1)" transform="rotate(-45)">
<rect width="7" height="7" fill="#fabb04" x="-7" y="-6"></rect>
<rect width="7" height="7" fill="#34a852" x="-5" y="-1"></rect>
<rect width="7" height="7" fill="#ea4335" x="-2" y="-5"></rect>
<rect width="7" height="7" fill="#4285f4" x="0" y="-1"></rect>
</g>
<image x="-4" y="-4" width="8" height="8" mask="url(#mask2)"
xlink:href="https://i.stack.imgur.com/3q67w.gif"></image>
</svg>

SVG stroke-linecap at one end only

Is it possible to add a linecap to only one end of a stroke? Not both ends as is the default shown in the sample below.
<?xml version="1.0"?>
<svg width="120" height="120" viewBox="0 0 120 120" version="1.1" xmlns="http://www.w3.org/2000/svg">
<line stroke-linecap="butt"
x1="30" y1="30" x2="30" y2="90"
stroke="teal" stroke-width="20"/>
<line stroke-linecap="round"
x1="60" y1="30" x2="60" y2="90"
stroke="teal" stroke-width="20"/>
<path d="M30,30 L30,90 M60,30 L60,90 M90,30 L90,90"
stroke="white" />
</svg>
You could do this with two lines, one on top of the other.
<?xml version="1.0"?>
<svg width="120" height="120" viewBox="0 0 120 120" version="1.1" xmlns="http://www.w3.org/2000/svg">
<line stroke-linecap="butt"
x1="30" y1="30" x2="30" y2="90"
stroke="teal" stroke-width="20"/>
<line stroke-linecap="round"
x1="60" y1="30" x2="60" y2="70"
stroke="teal" stroke-width="20"/>
<line stroke-linecap="butt"
x1="60" y1="40" x2="60" y2="90"
stroke="teal" stroke-width="20"/>
<path d="M30,30 L30,90 M60,30 L60,90 M90,30 L90,90"
stroke="white" />
</svg>
Another flexible solution using a single line and markers/marker-ends as suggested by Paulie_D:
<svg width="120" height="120" viewBox="0 0 120 120" version="1.1" xmlns="http://www.w3.org/2000/svg">
<defs>
<marker id="round" viewBox="-1 -1 2 2" markerWidth="1" orient="auto">
<circle r="1" fill="teal"/>
</marker>
</defs>
<line x1="30" y1="90" x2="30" y2="30"
stroke="teal" stroke-width="20" marker-end="url(#round)"/>
<line stroke-linecap="round"
x1="60" y1="30" x2="60" y2="90"
stroke="teal" stroke-width="20"/>
<line x1="90" y1="30" x2="90" y2="90"
stroke="teal" stroke-width="20" marker-end="url(#round)"/>
<path d="M30,30 L30,90 M60,30 L60,90 M90,30 L90,90"
stroke="white"/>
</svg>

Resources