- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个由 javascript 生成并内嵌在 HTML 页面中的 svg。在一些六边形(SVG 中定义的多边形)的顶部(上方,更高的 z-index)我想显示一个图像。
我能够添加一个 div,其中包含具有 css 绝对位置和顶部/左侧/宽度(以像素为单位)的图像。
但是,对于我必须显示的数据,这意味着为 39 个不同的图像添加 473 div(大约 10k 中的 473 个多边形需要一个图像、74 行和 134 列十六进制)。图像代表世界地图,六 Angular 形可以有大约 40 种不同的颜色。你可以看到here .
我想知道是否有解决方案可以使该图像出现在十六进制顶部,最好是在 svg 或 css 中?喜欢为多边形添加一个类,还是一个样式?
我曾尝试为多边形添加样式并为其提供背景图像,将图像包含在多边形内,但多边形的颜色优先于顶部。
这是代码:
.imageOnTop {
fill:orange;
stroke:black;
background-image: url('https://www.gravatar.com/avatar/4bd89893bb55d58180443e45eca3163e?s=64&d=identicon&r=PG&f=1');
background-size: contain;
z-index: -1;
position: relative;
}
<div id="main">
<div id="mapBody">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="300" height="150">
<polygon points="0,90 15,81 30,90 30,108 15,117 0,108" fill="rgb(150,183,243)" stroke="rgb(150,183,243)" stroke-width="1"></polygon>
<polygon points="30,90 45,81 60,90 60,108 45,117 30,108" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="60,90 75,81 90,90 90,108 75,117 60,108" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="90,90 105,81 120,90 120,108 105,117 90,108" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="120,90 135,81 150,90 150,108 135,117 120,108" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="150,90 165,81 180,90 180,108 165,117 150,108" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="180,90 195,81 210,90 210,108 195,117 180,108" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="210,90 225,81 240,90 240,108 225,117 210,108" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="15,63 30,54 45,63 45,81 30,90 15,81" fill="rgb(150,183,243)" stroke="rgb(150,183,243)" stroke-width="1"></polygon>
<polygon points="45,63 60,54 75,63 75,81 60,90 45,81" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="75,63 90,54 105,63 105,81 90,90 75,81" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="105,63 120,54 135,63 135,81 120,90 105,81" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="135,63 150,54 165,63 165,81 150,90 135,81" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="165,63 180,54 195,63 195,81 180,90 165,81" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="195,63 210,54 225,63 225,81 210,90 195,81" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="225,63 240,54 255,63 255,81 240,90 225,81" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="0,36 15,27 30,36 30,54 15,63 0,54" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="30,36 45,27 60,36 60,54 45,63 30,54" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="60,36 75,27 90,36 90,54 75,63 60,54" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="90,36 105,27 120,36 120,54 105,63 90,54" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="120,36 135,27 150,36 150,54 135,63 120,54" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="150,36 165,27 180,36 180,54 165,63 150,54" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="180,36 195,27 210,36 210,54 195,63 180,54" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<!-- LOOK AT THIS ONE --> <polygon points="210,36 225,27 240,36 240,54 225,63 210,54" fill="black" stroke="rgb(83,126,162)" stroke-width="1" class="imageOnTop"></polygon> <!-- LOOK AT THIS ONE -->
<polygon points="15,9 30,0 45,9 45,27 30,36 15,27" fill="rgb(150,183,243)" stroke="rgb(150,183,243)" stroke-width="1"></polygon>
<polygon points="45,9 60,0 75,9 75,27 60,36 45,27" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="75,9 90,0 105,9 105,27 90,36 75,27" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="105,9 120,0 135,9 135,27 120,36 105,27" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="135,9 150,0 165,9 165,27 150,36 135,27" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="165,9 180,0 195,9 195,27 180,36 165,27" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="195,9 210,0 225,9 225,27 210,36 195,27" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="225,9 240,0 255,9 255,27 240,36 225,27" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
</svg>
</div>
</div>
<div><img src="https://www.gravatar.com/avatar/4bd89893bb55d58180443e45eca3163e?s=64&d=identicon&r=PG&f=1" style="width: 20px; position: absolute; top: 15px; left: 25px;" /></div>
<defs><pattern ...><image ...>
提出解决方案。
.imageOnTop {
fill:orange;
fill:url(#img1);
stroke:black;
}
<div id="main">
<div id="mapBody">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="300" height="150">
<defs>
<pattern id="img1" patternUnits="userSpaceOnUse" width="34px" height="34px">
<image href="https://i.ibb.co/0XGwpPz/resource-bison.png" x="4px" y="-5px" width="34px" height="34px" />
</pattern>
</defs>
<polygon points="0,90 15,81 30,90 30,108 15,117 0,108" fill="rgb(150,183,243)" stroke="rgb(150,183,243)" stroke-width="1"></polygon>
<polygon points="30,90 45,81 60,90 60,108 45,117 30,108" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="60,90 75,81 90,90 90,108 75,117 60,108" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="90,90 105,81 120,90 120,108 105,117 90,108" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="120,90 135,81 150,90 150,108 135,117 120,108" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="150,90 165,81 180,90 180,108 165,117 150,108" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="180,90 195,81 210,90 210,108 195,117 180,108" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="210,90 225,81 240,90 240,108 225,117 210,108" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="15,63 30,54 45,63 45,81 30,90 15,81" fill="rgb(150,183,243)" stroke="rgb(150,183,243)" stroke-width="1"></polygon>
<polygon points="45,63 60,54 75,63 75,81 60,90 45,81" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="75,63 90,54 105,63 105,81 90,90 75,81" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="105,63 120,54 135,63 135,81 120,90 105,81" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="135,63 150,54 165,63 165,81 150,90 135,81" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="165,63 180,54 195,63 195,81 180,90 165,81" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="195,63 210,54 225,63 225,81 210,90 195,81" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="225,63 240,54 255,63 255,81 240,90 225,81" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="0,36 15,27 30,36 30,54 15,63 0,54" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="30,36 45,27 60,36 60,54 45,63 30,54" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="60,36 75,27 90,36 90,54 75,63 60,54" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="90,36 105,27 120,36 120,54 105,63 90,54" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="120,36 135,27 150,36 150,54 135,63 120,54" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="150,36 165,27 180,36 180,54 165,63 150,54" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="180,36 195,27 210,36 210,54 195,63 180,54" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<!-- LOOK AT THIS ONE --> <polygon points="210,36 225,27 240,36 240,54 225,63 210,54" fill="orange" stroke="rgb(83,126,162)" stroke-width="1" class="imageOnTop"></polygon> <!-- LOOK AT THIS ONE -->
<polygon points="15,9 30,0 45,9 45,27 30,36 15,27" fill="rgb(150,183,243)" stroke="rgb(150,183,243)" stroke-width="1"></polygon>
<polygon points="45,9 60,0 75,9 75,27 60,36 45,27" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="75,9 90,0 105,9 105,27 90,36 75,27" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="105,9 120,0 135,9 135,27 120,36 105,27" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="135,9 150,0 165,9 165,27 150,36 135,27" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="165,9 180,0 195,9 195,27 180,36 165,27" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="195,9 210,0 225,9 225,27 210,36 195,27" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="225,9 240,0 255,9 255,27 240,36 225,27" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
</svg>
</div>
</div>
<div><img src="https://i.ibb.co/0XGwpPz/resource-bison.png" style="width: 30px; position: absolute; top: 11px; left: 22px;" /></div>
.imageOnTop {
fill:orange;
fill:url(#img1);
stroke:black;
}
<div id="main">
<div id="mapBody">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="300" height="150">
<defs>
<pattern id="img1" patternUnits="userSpaceOnUse" width="34px" height="34px">
<image href="https://i.ibb.co/0XGwpPz/resource-bison.png" x="4px" y="-5px" width="34px" height="34px" />
<rect width="20" height="20" fill="orange">
</pattern>
</defs>
<polygon points="0,90 15,81 30,90 30,108 15,117 0,108" fill="rgb(150,183,243)" stroke="rgb(150,183,243)" stroke-width="1"></polygon>
<polygon points="30,90 45,81 60,90 60,108 45,117 30,108" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="60,90 75,81 90,90 90,108 75,117 60,108" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="90,90 105,81 120,90 120,108 105,117 90,108" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="120,90 135,81 150,90 150,108 135,117 120,108" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="150,90 165,81 180,90 180,108 165,117 150,108" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="180,90 195,81 210,90 210,108 195,117 180,108" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="210,90 225,81 240,90 240,108 225,117 210,108" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="15,63 30,54 45,63 45,81 30,90 15,81" fill="rgb(150,183,243)" stroke="rgb(150,183,243)" stroke-width="1"></polygon>
<polygon points="45,63 60,54 75,63 75,81 60,90 45,81" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="75,63 90,54 105,63 105,81 90,90 75,81" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="105,63 120,54 135,63 135,81 120,90 105,81" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="135,63 150,54 165,63 165,81 150,90 135,81" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="165,63 180,54 195,63 195,81 180,90 165,81" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="195,63 210,54 225,63 225,81 210,90 195,81" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="225,63 240,54 255,63 255,81 240,90 225,81" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="0,36 15,27 30,36 30,54 15,63 0,54" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="30,36 45,27 60,36 60,54 45,63 30,54" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="60,36 75,27 90,36 90,54 75,63 60,54" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="90,36 105,27 120,36 120,54 105,63 90,54" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="120,36 135,27 150,36 150,54 135,63 120,54" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="150,36 165,27 180,36 180,54 165,63 150,54" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="180,36 195,27 210,36 210,54 195,63 180,54" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<!-- LOOK AT THIS ONE --> <polygon points="210,36 225,27 240,36 240,54 225,63 210,54" fill="orange" stroke="rgb(83,126,162)" stroke-width="1" class="imageOnTop"></polygon> <!-- LOOK AT THIS ONE -->
<polygon points="15,9 30,0 45,9 45,27 30,36 15,27" fill="rgb(150,183,243)" stroke="rgb(150,183,243)" stroke-width="1"></polygon>
<polygon points="45,9 60,0 75,9 75,27 60,36 45,27" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="75,9 90,0 105,9 105,27 90,36 75,27" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="105,9 120,0 135,9 135,27 120,36 105,27" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="135,9 150,0 165,9 165,27 150,36 135,27" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="165,9 180,0 195,9 195,27 180,36 165,27" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="195,9 210,0 225,9 225,27 210,36 195,27" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="225,9 240,0 255,9 255,27 240,36 225,27" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
</svg>
</div>
</div>
<div><img src="https://i.ibb.co/0XGwpPz/resource-bison.png" style="width: 30px; position: absolute; top: 11px; left: 22px;" /></div>
最佳答案
其他一些解决方案走在正确的轨道上。您需要做的就是为您的 <pattern>
添加另一层用你想要的填充颜色。您可以将此颜色设为静态并在 SVG/HTML 或 CSS 中明确定义它。
如果您想要更大的灵活性,而不是添加 <rect>
到 <pattern>
,您可以将每个多边形与一个重复的多边形分组,将第一个用于 background-color
,第二个是模式 fill
.这允许所有这些属性( stroke
、 stroke-opacity
、 fill
等)独立。在此 #2 解决方案,我还添加了 preserveAspectRatio="xMidYMid slice"
到 <pattern>
确保背景图片始终居中,无需手动设置x
和 y
每次重新调整填充图像。
解决方案 #2 ,请向下滚动。
1. 为 <pattern>
添加静态填充颜色(下面#2)
.imageOnTop {
fill: url(#img1);
stroke: #000;
}
<div id="main">
<div id="mapBody">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="300" height="150">
<defs>
<pattern id="img1" patternUnits="userSpaceOnUse" width="34px" height="34px">
<rect width="100%" height="100%" fill="orange" />
<image href="https://i.ibb.co/0XGwpPz/resource-bison.png" x="4px" y="-5px" width="34px" height="34px" />
</pattern>
</defs>
<polygon points="0,90 15,81 30,90 30,108 15,117 0,108" fill="rgb(150,183,243)" stroke="rgb(150,183,243)" stroke-width="1"></polygon>
<polygon points="30,90 45,81 60,90 60,108 45,117 30,108" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="60,90 75,81 90,90 90,108 75,117 60,108" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="90,90 105,81 120,90 120,108 105,117 90,108" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="120,90 135,81 150,90 150,108 135,117 120,108" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="150,90 165,81 180,90 180,108 165,117 150,108" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="180,90 195,81 210,90 210,108 195,117 180,108" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="210,90 225,81 240,90 240,108 225,117 210,108" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="15,63 30,54 45,63 45,81 30,90 15,81" fill="rgb(150,183,243)" stroke="rgb(150,183,243)" stroke-width="1"></polygon>
<polygon points="45,63 60,54 75,63 75,81 60,90 45,81" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="75,63 90,54 105,63 105,81 90,90 75,81" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="105,63 120,54 135,63 135,81 120,90 105,81" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="135,63 150,54 165,63 165,81 150,90 135,81" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="165,63 180,54 195,63 195,81 180,90 165,81" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="195,63 210,54 225,63 225,81 210,90 195,81" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="225,63 240,54 255,63 255,81 240,90 225,81" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="0,36 15,27 30,36 30,54 15,63 0,54" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="30,36 45,27 60,36 60,54 45,63 30,54" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="60,36 75,27 90,36 90,54 75,63 60,54" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="90,36 105,27 120,36 120,54 105,63 90,54" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="120,36 135,27 150,36 150,54 135,63 120,54" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="150,36 165,27 180,36 180,54 165,63 150,54" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="180,36 195,27 210,36 210,54 195,63 180,54" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<!-- LOOK AT THIS ONE --> <polygon points="210,36 225,27 240,36 240,54 225,63 210,54" fill="orange" stroke="rgb(83,126,162)" stroke-width="1" class="imageOnTop"></polygon> <!-- LOOK AT THIS ONE -->
<polygon points="15,9 30,0 45,9 45,27 30,36 15,27" fill="rgb(150,183,243)" stroke="rgb(150,183,243)" stroke-width="1"></polygon>
<polygon points="45,9 60,0 75,9 75,27 60,36 45,27" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="75,9 90,0 105,9 105,27 90,36 75,27" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="105,9 120,0 135,9 135,27 120,36 105,27" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="135,9 150,0 165,9 165,27 150,36 135,27" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="165,9 180,0 195,9 195,27 180,36 165,27" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="195,9 210,0 225,9 225,27 210,36 195,27" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
<polygon points="225,9 240,0 255,9 255,27 240,36 225,27" fill="rgb(83,126,162)" stroke="rgb(83,126,162)" stroke-width="1"></polygon>
</svg>
</div>
</div>
.imageOnTop {
--blink-color: orange;
--animation-duration: 0.75s;
}
.imageOnTop > polygon:first-child {
animation: blink-fill ease-in-out var(--animation-duration) infinite alternate both;
}
.imageOnTop > polygon:last-child {
fill: url(#img1);
animation: blink-stroke ease-in-out var(--animation-duration) infinite alternate both;
}
@keyframes blink-fill {
from { fill: var(--start-color) }
to { fill: var(--blink-color) }
}
@keyframes blink-stroke {
from { stroke-opacity: 0 }
to { stroke-opacity: 1 }
}
<div id="main">
<div id="mapBody">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="300" height="150">
<defs>
<pattern id="img1" x="0" y="0" width="1" height="1" viewBox="0 0 30 36" preserveAspectRatio="xMidYMid slice">
<image width="30" height="36" xlink:href="https://i.ibb.co/0XGwpPz/resource-bison.png"/>
</pattern>
</defs>
<g class="imageOnTop" style="--blink-color: #f0f">
<polygon points="0,90 15,81 30,90 30,108 15,117 0,108" fill="rgb(150,183,243)" stroke="rgb(255,255,255)" stroke-opacity="0.5" stroke-width="1" style="--start-color: rgb(150,183,243)" />
<polygon points="0,90 15,81 30,90 30,108 15,117 0,108" fill="rgb(150,183,243)" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="1" />
</g><g>
<polygon points="30,90 45,81 60,90 60,108 45,117 30,108" fill="rgb(83,126,162)" stroke="rgb(255,255,255)" stroke-opacity="0.5" stroke-width="1" style="--start-color: rgb(83,126,162)" />
<polygon points="30,90 45,81 60,90 60,108 45,117 30,108" fill="rgb(83,126,162)" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="1" />
</g><g>
<polygon points="60,90 75,81 90,90 90,108 75,117 60,108" fill="rgb(83,126,162)" stroke="rgb(255,255,255)" stroke-opacity="0.5" stroke-width="1" style="--start-color: rgb(83,126,162)" />
<polygon points="60,90 75,81 90,90 90,108 75,117 60,108" fill="rgb(83,126,162)" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="1" />
</g><g>
<polygon points="90,90 105,81 120,90 120,108 105,117 90,108" fill="rgb(83,126,162)" stroke="rgb(255,255,255)" stroke-opacity="0.5" stroke-width="1" style="--start-color: rgb(83,126,162)" />
<polygon points="90,90 105,81 120,90 120,108 105,117 90,108" fill="rgb(83,126,162)" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="1" />
</g><g class="imageOnTop" style="--blink-color: #0f0">
<polygon points="120,90 135,81 150,90 150,108 135,117 120,108" fill="rgb(83,126,162)" stroke="rgb(255,255,255)" stroke-opacity="0.5" stroke-width="1" style="--start-color: rgb(83,126,162)" />
<polygon points="120,90 135,81 150,90 150,108 135,117 120,108" fill="rgb(83,126,162)" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="1" />
</g><g>
<polygon points="150,90 165,81 180,90 180,108 165,117 150,108" fill="rgb(83,126,162)" stroke="rgb(255,255,255)" stroke-opacity="0.5" stroke-width="1" style="--start-color: rgb(83,126,162)" />
<polygon points="150,90 165,81 180,90 180,108 165,117 150,108" fill="rgb(83,126,162)" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="1" />
</g><g>
<polygon points="180,90 195,81 210,90 210,108 195,117 180,108" fill="rgb(83,126,162)" stroke="rgb(255,255,255)" stroke-opacity="0.5" stroke-width="1" style="--start-color: rgb(83,126,162)" />
<polygon points="180,90 195,81 210,90 210,108 195,117 180,108" fill="rgb(83,126,162)" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="1" />
</g><g>
<polygon points="210,90 225,81 240,90 240,108 225,117 210,108" fill="rgb(83,126,162)" stroke="rgb(255,255,255)" stroke-opacity="0.5" stroke-width="1" style="--start-color: rgb(83,126,162)" />
<polygon points="210,90 225,81 240,90 240,108 225,117 210,108" fill="rgb(83,126,162)" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="1" />
</g><g>
<polygon points="15,63 30,54 45,63 45,81 30,90 15,81" fill="rgb(150,183,243)" stroke="rgb(255,255,255)" stroke-opacity="0.5" stroke-width="1" style="--start-color: rgb(150,183,243)" />
<polygon points="15,63 30,54 45,63 45,81 30,90 15,81" fill="rgb(150,183,243)" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="1" />
</g><g>
<polygon points="45,63 60,54 75,63 75,81 60,90 45,81" fill="rgb(83,126,162)" stroke="rgb(255,255,255)" stroke-opacity="0.5" stroke-width="1" style="--start-color: rgb(83,126,162)" />
<polygon points="45,63 60,54 75,63 75,81 60,90 45,81" fill="rgb(83,126,162)" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="1" />
</g><g>
<polygon points="75,63 90,54 105,63 105,81 90,90 75,81" fill="rgb(83,126,162)" stroke="rgb(255,255,255)" stroke-opacity="0.5" stroke-width="1" style="--start-color: rgb(83,126,162)" />
<polygon points="75,63 90,54 105,63 105,81 90,90 75,81" fill="rgb(83,126,162)" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="1" />
</g><g>
<polygon points="105,63 120,54 135,63 135,81 120,90 105,81" fill="rgb(83,126,162)" stroke="rgb(255,255,255)" stroke-opacity="0.5" stroke-width="1" style="--start-color: rgb(83,126,162)" />
<polygon points="105,63 120,54 135,63 135,81 120,90 105,81" fill="rgb(83,126,162)" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="1" />
</g><g>
<polygon points="135,63 150,54 165,63 165,81 150,90 135,81" fill="rgb(83,126,162)" stroke="rgb(255,255,255)" stroke-opacity="0.5" stroke-width="1" style="--start-color: rgb(83,126,162)" />
<polygon points="135,63 150,54 165,63 165,81 150,90 135,81" fill="rgb(83,126,162)" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="1" />
</g><g>
<polygon points="165,63 180,54 195,63 195,81 180,90 165,81" fill="rgb(83,126,162)" stroke="rgb(255,255,255)" stroke-opacity="0.5" stroke-width="1" style="--start-color: rgb(83,126,162)" />
<polygon points="165,63 180,54 195,63 195,81 180,90 165,81" fill="rgb(83,126,162)" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="1" />
</g><g>
<polygon points="195,63 210,54 225,63 225,81 210,90 195,81" fill="rgb(83,126,162)" stroke="rgb(255,255,255)" stroke-opacity="0.5" stroke-width="1" style="--start-color: rgb(83,126,162)" />
<polygon points="195,63 210,54 225,63 225,81 210,90 195,81" fill="rgb(83,126,162)" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="1" />
</g><g>
<polygon points="225,63 240,54 255,63 255,81 240,90 225,81" fill="rgb(83,126,162)" stroke="rgb(255,255,255)" stroke-opacity="0.5" stroke-width="1" style="--start-color: rgb(83,126,162)" />
<polygon points="225,63 240,54 255,63 255,81 240,90 225,81" fill="rgb(83,126,162)" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="1" />
</g><g>
<polygon points="0,36 15,27 30,36 30,54 15,63 0,54" fill="rgb(83,126,162)" stroke="rgb(255,255,255)" stroke-opacity="0.5" stroke-width="1" style="--start-color: rgb(83,126,162)" />
<polygon points="0,36 15,27 30,36 30,54 15,63 0,54" fill="rgb(83,126,162)" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="1" />
</g><g>
<polygon points="30,36 45,27 60,36 60,54 45,63 30,54" fill="rgb(83,126,162)" stroke="rgb(255,255,255)" stroke-opacity="0.5" stroke-width="1" style="--start-color: rgb(83,126,162)" />
<polygon points="30,36 45,27 60,36 60,54 45,63 30,54" fill="rgb(83,126,162)" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="1" />
</g><g>
<polygon points="60,36 75,27 90,36 90,54 75,63 60,54" fill="rgb(83,126,162)" stroke="rgb(255,255,255)" stroke-opacity="0.5" stroke-width="1" style="--start-color: rgb(83,126,162)" />
<polygon points="60,36 75,27 90,36 90,54 75,63 60,54" fill="rgb(83,126,162)" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="1" />
</g><g>
<polygon points="90,36 105,27 120,36 120,54 105,63 90,54" fill="rgb(83,126,162)" stroke="rgb(255,255,255)" stroke-opacity="0.5" stroke-width="1" style="--start-color: rgb(83,126,162)" />
<polygon points="90,36 105,27 120,36 120,54 105,63 90,54" fill="rgb(83,126,162)" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="1" />
</g><g>
<polygon points="120,36 135,27 150,36 150,54 135,63 120,54" fill="rgb(83,126,162)" stroke="rgb(255,255,255)" stroke-opacity="0.5" stroke-width="1" style="--start-color: rgb(83,126,162)" />
<polygon points="120,36 135,27 150,36 150,54 135,63 120,54" fill="rgb(83,126,162)" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="1" />
</g><g>
<polygon points="150,36 165,27 180,36 180,54 165,63 150,54" fill="rgb(83,126,162)" stroke="rgb(255,255,255)" stroke-opacity="0.5" stroke-width="1" style="--start-color: rgb(83,126,162)" />
<polygon points="150,36 165,27 180,36 180,54 165,63 150,54" fill="rgb(83,126,162)" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="1" />
</g><g>
<polygon points="180,36 195,27 210,36 210,54 195,63 180,54" fill="rgb(83,126,162)" stroke="rgb(255,255,255)" stroke-opacity="0.5" stroke-width="1" style="--start-color: rgb(83,126,162)" />
<polygon points="180,36 195,27 210,36 210,54 195,63 180,54" fill="rgb(83,126,162)" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="1" />
</g><g class="imageOnTop">
<polygon points="210,36 225,27 240,36 240,54 225,63 210,54" fill="rgb(83,126,162)" stroke="rgb(255,255,255)" stroke-opacity="0.5" stroke-width="1" style="--start-color: rgb(83,126,162)" />
<polygon points="210,36 225,27 240,36 240,54 225,63 210,54" fill="rgb(83,126,162)" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="1" />
</g><g>
<polygon points="15,9 30,0 45,9 45,27 30,36 15,27" fill="rgb(150,183,243)" stroke="rgb(255,255,255)" stroke-opacity="0.5" stroke-width="1" style="--start-color: rgb(150,183,243)" />
<polygon points="15,9 30,0 45,9 45,27 30,36 15,27" fill="rgb(150,183,243)" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="1" />
</g><g>
<polygon points="45,9 60,0 75,9 75,27 60,36 45,27" fill="rgb(83,126,162)" stroke="rgb(255,255,255)" stroke-opacity="0.5" stroke-width="1" style="--start-color: rgb(83,126,162)" />
<polygon points="45,9 60,0 75,9 75,27 60,36 45,27" fill="rgb(83,126,162)" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="1" />
</g><g>
<polygon points="75,9 90,0 105,9 105,27 90,36 75,27" fill="rgb(83,126,162)" stroke="rgb(255,255,255)" stroke-opacity="0.5" stroke-width="1" style="--start-color: rgb(83,126,162)" />
<polygon points="75,9 90,0 105,9 105,27 90,36 75,27" fill="rgb(83,126,162)" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="1" />
</g><g>
<polygon points="105,9 120,0 135,9 135,27 120,36 105,27" fill="rgb(83,126,162)" stroke="rgb(255,255,255)" stroke-opacity="0.5" stroke-width="1" style="--start-color: rgb(83,126,162)" />
<polygon points="105,9 120,0 135,9 135,27 120,36 105,27" fill="rgb(83,126,162)" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="1" />
</g><g>
<polygon points="135,9 150,0 165,9 165,27 150,36 135,27" fill="rgb(83,126,162)" stroke="rgb(255,255,255)" stroke-opacity="0.5" stroke-width="1" style="--start-color: rgb(83,126,162)" />
<polygon points="135,9 150,0 165,9 165,27 150,36 135,27" fill="rgb(83,126,162)" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="1" />
</g><g>
<polygon points="165,9 180,0 195,9 195,27 180,36 165,27" fill="rgb(83,126,162)" stroke="rgb(255,255,255)" stroke-opacity="0.5" stroke-width="1" style="--start-color: rgb(83,126,162)" />
<polygon points="165,9 180,0 195,9 195,27 180,36 165,27" fill="rgb(83,126,162)" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="1" />
</g><g>
<polygon points="195,9 210,0 225,9 225,27 210,36 195,27" fill="rgb(83,126,162)" stroke="rgb(255,255,255)" stroke-opacity="0.5" stroke-width="1" style="--start-color: rgb(83,126,162)" />
<polygon points="195,9 210,0 225,9 225,27 210,36 195,27" fill="rgb(83,126,162)" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="1" />
</g><g>
<polygon points="225,9 240,0 255,9 255,27 240,36 225,27" fill="rgb(83,126,162)" stroke="rgb(255,255,255)" stroke-opacity="0.5" stroke-width="1" style="--start-color: rgb(83,126,162)" />
<polygon points="225,9 240,0 255,9 255,27 240,36 225,27" fill="rgb(83,126,162)" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="1" />
</g>
</svg>
</div>
</div>
关于html - 如何在没有 div 的情况下通过 css 将图像放在内联 svg 之上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67442057/
因此,我试图在网站主体中创建导航和页脚,但 particle.js 不断覆盖这些元素。我试过 z-index 但它没有显示出来。 particle.js 不允许我触摸我的导航栏或页脚。会很感激一些帮助
我正在为我的类(class)建立一个美食车网站。我想要有一个盘子的图像,然后一旦它被点击就会有一个不同的食物图像出现在它上面。我想知道可以使用哪种 javascript 或 else/if 语句来实现
我目前正在做一个元素,我有两张人体图像,正面和背面。图像设置为 height: 80vh。我的问题是:我一直在使用 bootstrap 在屏幕较宽时使图像并排流动,在屏幕高时使图像相互叠加,使用 co
有没有办法将“处理...”语言放在 DataTable 对象的顶部而不是垂直中间?如果我有一张长 table ,它会隐藏在页面之外,因为它的默认位置在中间。 $('#example').dataTab
就目前情况而言,这个问题不太适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、民意调查或扩展讨论。如果您觉得这个问题可以改进并可能重新开放,visit
问题 我有一个表单,一旦用户填写并提交,我希望在表单上弹出一条消息,显示“现在坐下来放松一下吧……”。理想情况下,我希望此消息上有一个按钮表示“确定”。 到目前为止我有什么? 通过 ajax post
我想在 div 之上制作一个菜单,所以文本基本上位于它之上(参见示例)。我想在同一个 div 中包含菜单的文本,所以 html 是这样的: Portfolio |
我想在 div 之上制作一个菜单,所以文本基本上位于它之上(参见示例)。我想在同一个 div 中包含菜单的文本,所以 html 是这样的: Portfolio |
我想创建这样的布局: 我有 3 个不同的图像:背景、白色方 block 和 V 形符号。 当我希望盒子从一侧移动到另一侧时,如何将它们定位为照片中的位置 当 onClick 被触发时。 我已经尝试过:
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 关于您编写的代码问题的问题必须在问题本身中描述具体问题 — 并且包括有效代码 以重现它。参见 SSC
我正在尝试获取鼠标当前悬停的元素并将其返回。根据我迄今为止从研究中收集到的信息,这是执行此操作的代码: document.getElementById('theTable').onmouseo
首先,我想说声抱歉,但我在设计 Android 应用程序时遇到了问题 :D我希望该按钮位于 ListView 下方。实际上该按钮位于 ListView 上方并隐藏了下部区域。我该如何解决? scree
我正在尝试使用 Swiperefreshlayout,它工作得很好,但我需要知道用户何时位于我的 Activity 顶部。我正在阅读这个,我发现了一个名为“setOnScrollListener”的方
我想有两个按钮像页脚一样固定在底部屏幕上,其他 View 不会传递它或在两个按钮上重叠。它只会一直停留在底部。对不起我的英语不好。请帮我。顺便说一句,我不能发布图片,所以它需要 10 个声誉,这就是我
我在所有页面上都有一个由 JavaScript 创建的下拉菜单,有些列最多有 20 个元素。在 Mozilla 浏览器中,此下拉列表显示在所有内容的最上方,但在 Internet Explorer 中
如果我直接在框架上绘画,它显示得很好,但船不会出现在面板顶部... package MoonBlast; import java.awt.BorderLayout; import java.awt.
我已经着手设置我的 JFrame 的背景图像,但现在我的组件(我假设)卡在它后面。我已经尝试阅读有关顶级容器的内容,但我就是无法理解它 T_T。有人有主意吗 ?也许我需要找到另一种方式来设置背景图片?
我有一个 UIView (A),它以纵向模式显示并附加了一个 UIButton。当用户单击按钮时,第二个 UIView (B) 被初始化并显示为 UIView A 顶部的模态视图。 是否可以将第二个
我对这件事束手无策。 我有几个 div。它们都有一个向下的箭头。它应该居中在中间,棕色线上和所有东西的顶部。最后一个 div 也应该有箭头。我尝试了 z-index、绝对和相对定位,但没有任何效果。
我正在尝试使图像出现在父 div 之外,这样图像看起来就好像位于 div 上而不增加父 div 的高度。但是,无论我尝试过什么,图像都会被父 div 截断并且不会显示所有内容。 我有一个 js fid
我是一名优秀的程序员,十分优秀!