gpt4 book ai didi

css - SVG 元素列表

转载 作者:太空宇宙 更新时间:2023-11-04 01:57:31 26 4
gpt4 key购买 nike

我正在尝试做一些看起来像我添加的片段但带有 svg 圆圈的东西,我是否可以将我的 svg 圆圈放在列表中?我希望当我将鼠标悬停在我的圈子中时出现该框

ul#list_of_thrones {
list-style-type:none;
}
ul#list_of_thrones li{
position: relative;
font-size:20px;
font-family: helvetica, arial, sans-serif;
}
ul#list_of_thrones li > span{
position: relative;
display:none;
}
ul#list_of_thrones li:hover > span{
position: absolute;
top:0;
left:100px;
display:block;
background:red;
color:white;
padding:6px;
}

ul#list_of_thrones li:hover > span:after {
right: 100%;
top: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-color: rgba(136, 183, 213, 0);
border-right-color: red;
border-width: 6px;
margin-top: -6px;
}
<ul id="list_of_thrones">
<li>Tyrion<span>Lannister</span></li>
<li>Loras<span>Tyrell</span></li>
<li>Gregor<span>Clegane</span></li>
<li>Brandon<span>Stark</span></li>
<li>Daenerys<span>Targaryen</span></li>
<li>Oberyn<span>Martell</span></li>
</ul>

最佳答案

只需用 SVG 圆圈替换文本,您应该使用现有的 CSS 获得相同的功能:

<li><svg><circle cx="10" cy="10" r="10"/></svg><span>Tyrell</span></li>

片段:

ul#list_of_thrones {
list-style-type:none;
}
ul#list_of_thrones li{
position: relative;
font-size:20px;
font-family: helvetica, arial, sans-serif;
}
ul#list_of_thrones li > span{
position: relative;
display:none;
}
ul#list_of_thrones li:hover > span{
position: absolute;
top:0;
left:100px;
display:block;
background:red;
color:white;
padding:6px;
}

svg {
height: 1.5em;
}

ul#list_of_thrones li:hover > span:after {
right: 100%;
top: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-color: rgba(136, 183, 213, 0);
border-right-color: red;
border-width: 6px;
margin-top: -6px;
}
<ul id="list_of_thrones">
<li><svg><circle cx="10" cy="10" r="10"/></svg><span>Tyrell</span></li>
<li><svg><circle cx="10" cy="10" r="10"/></svg><span>Clegane</span></li>
<li><svg><circle cx="10" cy="10" r="10"/></svg><span>Stark</span></li>
<li><svg><circle cx="10" cy="10" r="10"/></svg><span>Targaryen</span></li>
<li><svg><circle cx="10" cy="10" r="10"/></svg><span>Martell</span></li>
</ul>

关于css - SVG 元素列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42329942/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com