gpt4 book ai didi

html - 使用 CSS 在每个滚动 div 上放置固定行

转载 作者:太空宇宙 更新时间:2023-11-03 19:29:52 25 4
gpt4 key购买 nike

我有一些包含 Logo + 标签 + 箭头的 div。我会用 json 检索,所以我不知道确切的数字。我要做的是水平对齐logo+labels+arrow,如果labels会overflow-x就加上滚动条。箭头必须始终可见,并且位于 div 的底部。我做错了什么?

    body {
font-family: "Open Sans", Helvetica, sans-serif;
color: #89867e;
background: #f9f9f9;
}
.wrapper {
margin: 20px;
padding: 2em;
list-style: none;
font-size: 1.5em;
font-weight: 300;
max-height: 388px;
white-space: nowrap;
overflow-y: hidden;
overflow-x: scroll;
-webkit-overflow-scrolling: touch;
background-color: #ccc;
margin-bottom:25px;
}

.internal {
display: inline;
height: 164px;
padding: .4em 1em;
border: 2px solid rgba(255,255,255,0.1);
-webkit-border: 2px solid rgba(255,255,255,0.1);
-moz-border: 2px solid rgba(255,255,255,0.1);
-o-border: 2px solid rgba(255,255,255,0.1);
color: rgba(249, 249, 249, .9);
text-decoration: none;
font-size: 1.5em;
font-weight: 300;
margin-right: 18px;
}


.wrapper a:nth-child(6n+1) { background: #e87352; }

.wrapper a:nth-child(6n+2) { background: #ebc85e; }

.wrapper a:nth-child(6n+3) { background: #3bbec0; }

.wrapper a:nth-child(6n+4) { background: #4ad585; }

.wrapper a:nth-child(6n+5) { background: rgb(27, 54, 71); }

.wrapper a:nth-child(6n+6) { background: rgb(21, 40, 54); }


.wrapper:nth-child(6n+1) { background: rgb(208, 101, 3); }

.wrapper:nth-child(6n+2) { background: rgb(233, 147, 26); }

.wrapper:nth-child(6n+3) { background: rgb(22, 145, 190); }

.wrapper:nth-child(6n+4) { background: rgb(22, 107, 162); }

.wrapper:nth-child(6n+5) { background: rgb(27, 54, 71); }

.wrapper:nth-child(6n+6) { background: rgb(21, 40, 54); }

.trasparente {
background: transparent !important;
padding: 0;
border:none;
}

.logo {
max-width: 318px;
vertical-align: middle;
margin-right: 18px;
}

/* arrow */
.arrow-wrap {
position:absolute;
z-index:1;
left:50%;
padding: 15px 15px !important;
bottom: 30px;
margin-left:-5em;
background:#111 !important;
width: 75px;
height: 75px;
padding:4em 2em;
border-radius:50%;
-webkit-border-radius:50%;
-moz-border-radius:50%;
-o-border-radius:50%;
font-size:.6em;
display:block;
box-shadow:0px 0px 5px 0px #333;
-webkit-box-shadow:0px 0px 5px 0px #333;
-moz-box-shadow:0px 0px 5px 0px #333;
-o-box-shadow:0px 0px 5px 0px #333;
transform: rotate(-90deg);
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
}

.arrow {
float:left;
position:relative;
width: 0px;
height: 0px;
left: -6px;
top: 25px;
border-style: solid;
-webkit-border-style: solid;
-moz-border-style: solid;
-o-border-style: solid;
border-width: 3em 3em 0 3em;
-webkit-border-width: 3em 3em 0 3em;
-moz-border-width: 3em 3em 0 3em;
-o-border-width: 3em 3em 0 3em;
border-color: #ffffff transparent transparent transparent;
-webkit-border-color: #ffffff transparent transparent transparent;
-moz-border-color: #ffffff transparent transparent transparent;
-o-border-color: #ffffff transparent transparent transparent;
-webkit-transform:rotate(360deg);
}

.arrow:after {
content:'';
position:absolute;
left: -43px;
top: -46.8px;
width: 0px;
height: 0px;
border-style: solid;
-webkit-border-style: solid;
-moz-border-style: solid;
-o-border-style: solid;
border-width: 3em 3em 0 3em;
-webkit-border-width: 3em 3em 0 3em;
-moz-border-width: 3em 3em 0 3em;
-o-border-width: 3em 3em 0 3em;
border-color: #111 transparent transparent transparent;
-webkit-border-color: #111 transparent transparent transparent;
-moz-border-color: #111 transparent transparent transparent;
-o-border-color: #111 transparent transparent transparent;
-webkit-transform:rotate(360deg);
}

@-webkit-keyframes arrows {
0% { top:0; }
10% { top:12%; }
20% { top:0; }
30% { top:12%; }
40% { top:-12%; }
50% { top:12%; }
60% { top:0; }
70% { top:12%; }
80% { top:-12%; }
90% { top:12%; }
100% { top:0; }
}

.arrow-wrap .arrow {
animation: arrows 2.8s 0.4s;
animation-delay: 3s;
-webkit-animation: arrows 2.8s 0.4s;
-webkit-animation-delay: 3s;
}

.w { position: relative; }
     <div class="wrapper">
<a href="#" class="internal trasparente"><img src="https://upload.wikimedia.org/wikipedia/bar/8/86/744px-Siemens-logo_svg.png" class="logo" style="margin-top:20px" alt="logo"></a>
<a href="" class="internal">item 1</a>
<a href="" class="internal">item 2</a>
<a href="" class="internal">item 3</a>
<a href="" class="internal">item 4</a>
<a href="" class="internal">item 5</a>
<a href="" class="internal">item 6</a>
<a href="" class="internal">item 7</a>
<a href="" class="internal">item 8</a>
<a href="" class="internal">item 9</a>
<a href="" class="internal">item 10</a>
<a href="" class="internal">item 11</a>
<a href="" class="internal">item 12</a>
<a href="" class="internal">item 13</a>
<a href="" class="internal">item 14</a>
<a href="" class="internal">item 15</a>
<a href="" class="internal">item 16</a>
<a href="" class="internal">item 17</a>
<a href="" class="internal">item 18</a>
<a href="" class="internal">item 19</a>
<a href="" class="internal">item 20</a>
<a href="" class="internal">item 21</a>
<a href="" class="internal">item 22</a>
<a href="" class="internal">item 23</a>
<a href="" class="internal">item 24</a>
<a href="" class="internal">item 25</a>
<a href="" class="internal">item 26</a>
<a href="" class="internal">item 27</a>
<a href="" class="internal">item 28</a>
<a href="" class="internal">item 29</a>
<a href="" class="internal">item 30</a>
<!-- ARROW -->
<div class="w">
<a class="arrow-wrap" href="#">
<span class="arrow"></span>
</a>
</div>
</div> <!-- end wapper -->

<div class="wrapper">
<a href="#" class="internal trasparente"><img src="http://www.asborsoniww.com/media/tes_logo.png" class="logo" style="margin-top:20px" alt="logo"></a>
<a href="" class="internal">item 1</a>
<a href="" class="internal">item 2</a>
<a href="" class="internal">item 3</a>
<a href="" class="internal">item 4</a>
<a href="" class="internal">item 5</a>
<a href="" class="internal">item 6</a>
<a href="" class="internal">item 7</a>
<a href="" class="internal">item 8</a>
<a href="" class="internal">item 9</a>
<a href="" class="internal">item 10</a>
<a href="" class="internal">item 11</a>
<a href="" class="internal">item 12</a>
<a href="" class="internal">item 13</a>
<a href="" class="internal">item 14</a>
<a href="" class="internal">item 15</a>
<a href="" class="internal">item 16</a>
<a href="" class="internal">item 17</a>
<a href="" class="internal">item 18</a>
<a href="" class="internal">item 19</a>
<a href="" class="internal">item 20</a>
<a href="" class="internal">item 21</a>
<a href="" class="internal">item 22</a>
<a href="" class="internal">item 23</a>
<a href="" class="internal">item 24</a>
<a href="" class="internal">item 25</a>
<a href="" class="internal">item 26</a>
<a href="" class="internal">item 27</a>
<a href="" class="internal">item 28</a>
<a href="" class="internal">item 29</a>
<a href="" class="internal">item 30</a>
<!-- ARROW -->
<div class="w">
<a class="arrow-wrap" href="#">
<span class="arrow"></span>
</a>
</div>
</div> <!-- end wapper -->

<div class="wrapper">
<a href="" class="internal">item 1</a>
<a href="" class="internal">item 2</a>
<a href="" class="internal">item 3</a>
<a href="" class="internal">item 4</a>
<a href="" class="internal">item 5</a>
<a href="" class="internal">item 6</a>
<a href="" class="internal">item 7</a>
<a href="" class="internal">item 8</a>
<a href="" class="internal">item 9</a>
<a href="" class="internal">item 10</a>
<a href="" class="internal">item 11</a>
<a href="" class="internal">item 12</a>
<a href="" class="internal">item 13</a>
<a href="" class="internal">item 14</a>
<a href="" class="internal">item 15</a>
<a href="" class="internal">item 16</a>
<a href="" class="internal">item 17</a>
<a href="" class="internal">item 18</a>
<a href="" class="internal">item 19</a>
<a href="" class="internal">item 20</a>
<a href="" class="internal">item 21</a>
<a href="" class="internal">item 22</a>
<a href="" class="internal">item 23</a>
<a href="" class="internal">item 24</a>
<a href="" class="internal">item 25</a>
<a href="" class="internal">item 26</a>
<a href="" class="internal">item 27</a>
<a href="" class="internal">item 28</a>
<a href="" class="internal">item 29</a>
<a href="" class="internal">item 30</a>

<!-- ARROW -->
<div class="w">
<a class="arrow-wrap" href="#">
<span class="arrow"></span>
</a>
</div>
</div> <!-- end wapper -->

最佳答案

wrapper 类中取出一个箭头 HTML。 (所以它会附加到父级而不是列出自己)。

    body {
font-family: "Open Sans", Helvetica, sans-serif;
color: #89867e;
background: #f9f9f9;
}
.wrapper {
margin: 20px;
padding: 2em;
list-style: none;
font-size: 1.5em;
font-weight: 300;
max-height: 388px;
white-space: nowrap;
overflow-y: hidden;
overflow-x: scroll;
-webkit-overflow-scrolling: touch;
background-color: #ccc;
margin-bottom:25px;
}

.internal {
display: inline;
height: 164px;
padding: .4em 1em;
border: 2px solid rgba(255,255,255,0.1);
-webkit-border: 2px solid rgba(255,255,255,0.1);
-moz-border: 2px solid rgba(255,255,255,0.1);
-o-border: 2px solid rgba(255,255,255,0.1);
color: rgba(249, 249, 249, .9);
text-decoration: none;
font-size: 1.5em;
font-weight: 300;
margin-right: 18px;
}


.wrapper a:nth-child(6n+1) { background: #e87352; }

.wrapper a:nth-child(6n+2) { background: #ebc85e; }

.wrapper a:nth-child(6n+3) { background: #3bbec0; }

.wrapper a:nth-child(6n+4) { background: #4ad585; }

.wrapper a:nth-child(6n+5) { background: rgb(27, 54, 71); }

.wrapper a:nth-child(6n+6) { background: rgb(21, 40, 54); }


.wrapper:nth-child(6n+1) { background: rgb(208, 101, 3); }

.wrapper:nth-child(6n+2) { background: rgb(233, 147, 26); }

.wrapper:nth-child(6n+3) { background: rgb(22, 145, 190); }

.wrapper:nth-child(6n+4) { background: rgb(22, 107, 162); }

.wrapper:nth-child(6n+5) { background: rgb(27, 54, 71); }

.wrapper:nth-child(6n+6) { background: rgb(21, 40, 54); }

.trasparente {
background: transparent !important;
padding: 0;
border:none;
}

.logo {
max-width: 318px;
vertical-align: middle;
margin-right: 18px;
}

/* arrow */
.arrow-wrap {
position:absolute;
z-index:1;
left:50%;
padding: 15px 15px !important;
bottom: 30px;
margin-left:-5em;
background:#111 !important;
width: 75px;
height: 75px;
padding:4em 2em;
border-radius:50%;
-webkit-border-radius:50%;
-moz-border-radius:50%;
-o-border-radius:50%;
font-size:.6em;
display:block;
box-shadow:0px 0px 5px 0px #333;
-webkit-box-shadow:0px 0px 5px 0px #333;
-moz-box-shadow:0px 0px 5px 0px #333;
-o-box-shadow:0px 0px 5px 0px #333;
transform: rotate(-90deg);
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
}

.arrow {
float:left;
position:relative;
width: 0px;
height: 0px;
left: -6px;
top: 25px;
border-style: solid;
-webkit-border-style: solid;
-moz-border-style: solid;
-o-border-style: solid;
border-width: 3em 3em 0 3em;
-webkit-border-width: 3em 3em 0 3em;
-moz-border-width: 3em 3em 0 3em;
-o-border-width: 3em 3em 0 3em;
border-color: #ffffff transparent transparent transparent;
-webkit-border-color: #ffffff transparent transparent transparent;
-moz-border-color: #ffffff transparent transparent transparent;
-o-border-color: #ffffff transparent transparent transparent;
-webkit-transform:rotate(360deg);
}

.arrow:after {
content:'';
position:absolute;
left: -43px;
top: -46.8px;
width: 0px;
height: 0px;
border-style: solid;
-webkit-border-style: solid;
-moz-border-style: solid;
-o-border-style: solid;
border-width: 3em 3em 0 3em;
-webkit-border-width: 3em 3em 0 3em;
-moz-border-width: 3em 3em 0 3em;
-o-border-width: 3em 3em 0 3em;
border-color: #111 transparent transparent transparent;
-webkit-border-color: #111 transparent transparent transparent;
-moz-border-color: #111 transparent transparent transparent;
-o-border-color: #111 transparent transparent transparent;
-webkit-transform:rotate(360deg);
}

@-webkit-keyframes arrows {
0% { top:0; }
10% { top:12%; }
20% { top:0; }
30% { top:12%; }
40% { top:-12%; }
50% { top:12%; }
60% { top:0; }
70% { top:12%; }
80% { top:-12%; }
90% { top:12%; }
100% { top:0; }
}

.arrow-wrap .arrow {
animation: arrows 2.8s 0.4s;
animation-delay: 3s;
-webkit-animation: arrows 2.8s 0.4s;
-webkit-animation-delay: 3s;
}

.w { position: relative; }
     <div class="wrapper">
<a href="#" class="internal trasparente"><img src="https://upload.wikimedia.org/wikipedia/bar/8/86/744px-Siemens-logo_svg.png" class="logo" style="margin-top:20px" alt="logo"></a>
<a href="" class="internal">item 1</a>
<a href="" class="internal">item 2</a>
<a href="" class="internal">item 3</a>
<a href="" class="internal">item 4</a>
<a href="" class="internal">item 5</a>
<a href="" class="internal">item 6</a>
<a href="" class="internal">item 7</a>
<a href="" class="internal">item 8</a>
<a href="" class="internal">item 9</a>
<a href="" class="internal">item 10</a>
<a href="" class="internal">item 11</a>
<a href="" class="internal">item 12</a>
<a href="" class="internal">item 13</a>
<a href="" class="internal">item 14</a>
<a href="" class="internal">item 15</a>
<a href="" class="internal">item 16</a>
<a href="" class="internal">item 17</a>
<a href="" class="internal">item 18</a>
<a href="" class="internal">item 19</a>
<a href="" class="internal">item 20</a>
<a href="" class="internal">item 21</a>
<a href="" class="internal">item 22</a>
<a href="" class="internal">item 23</a>
<a href="" class="internal">item 24</a>
<a href="" class="internal">item 25</a>
<a href="" class="internal">item 26</a>
<a href="" class="internal">item 27</a>
<a href="" class="internal">item 28</a>
<a href="" class="internal">item 29</a>
<a href="" class="internal">item 30</a>
</div>
<!-- ARROW -->
<div class="w">
<a class="arrow-wrap" href="#">
<span class="arrow"></span>
</a>
</div> <!-- end wapper -->

关于html - 使用 CSS 在每个滚动 div 上放置固定行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35025014/

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