gpt4 book ai didi

html - 图像上的图标 + y 轴定位

转载 作者:行者123 更新时间:2023-11-28 08:09:33 24 4
gpt4 key购买 nike

我正在尝试将我的 5 个 Font Awesome 图标放置在我的背景图片上并固定在一个位置。该固定位置应该允许我滚动过去而不会出现任何问题。我知道有办法,但我没有找到。

我的 HTML:

    <!--Kaffe abschnitt -->
<!--5 Icons-->
<ul>
<li><a href="#"><i class="fa fa-cog fa-5x"></i></a></li>
<li><a href="#"><i class="fa fa-rebel fa-5x"></i></a></li>
<li><a href="#"><i class="fa fa-empire fa-5x"></i></a></li>
<li><a href="#"><i class="fa fa-twitch fa-5x"></i> </a></li>
<li><a href="#"><i class="fa fa-steam fa-5x"></i> </a></li>
</ul>
<!--Ende 5 Icons-->
<!--Hintergrund-->
<img src="img/bild2.png" class="container-full">
<!--Ende Kaffe abschnitt -->

背景 CSS:

.container-full {
margin: 0 auto;
width: 100%;
z-index: -999;
}

图标 CSS:

 ul li {
list-style-type: none;
float: left;
}
ul li a span {
background: transparent;
color: #205D7A;
width: 240px;
height: 240px;
border-radius: 50%;
border: 2px solid;

text-align: center;
transition: all 0.2s ease-in-out;
z-index: 998;
}
ul li a span:hover {
opacity: .8;
}

我不是要预制的完整代码。只是操作的名称或一些简短的代码片段。

最佳答案

I am trying to get my 5 Font Awesome Icons over my background image with a fixed position.

如果你想滚动过去,你不想使用'position:fixed'。相反,请使用 position:absolute。

absolute 将根据除“position:static”之外的第一个父元素定位元素,我建议在您希望元素根据其自行定位的父元素上设置“position:relative”。

如果你想让你的“图标”位于 div 的右侧,那么它应该是这样的

#myDiv{position:relative;} //the container

.myIcons{position:absolute; right:0} //a handy class on all your icons spans/i

.icon1{top:0px} //these are just unique classes per icon
.icon2{top:20px}
.icon3{top:40px}

希望这能让你朝着正确的方向前进

关于html - 图像上的图标 + y 轴定位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29341235/

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